Merge tag 'asoc-v3.15-4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
authorTakashi Iwai <tiwai@suse.de>
Mon, 31 Mar 2014 10:33:09 +0000 (12:33 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 31 Mar 2014 10:33:09 +0000 (12:33 +0200)
ASoC: Final updates for v3.15 merge window

A few more updates from last week - use of the tdm_slot mapping from
Xiubo plus a few smaller fixes and cleanups.

296 files changed:
Documentation/DocBook/writing-an-alsa-driver.tmpl
drivers/hid/hid-prodikeys.c
drivers/media/pci/cx18/cx18-alsa-main.c
drivers/media/pci/cx23885/cx23885-alsa.c
drivers/media/pci/cx25821/cx25821-alsa.c
drivers/media/pci/cx88/cx88-alsa.c
drivers/media/pci/ivtv/ivtv-alsa-main.c
drivers/media/pci/saa7134/saa7134-alsa.c
drivers/media/usb/cx231xx/cx231xx-audio.c
drivers/media/usb/em28xx/em28xx-audio.c
drivers/media/usb/stk1160/stk1160-ac97.c
drivers/media/usb/tlg2300/pd-alsa.c
drivers/media/usb/tm6000/tm6000-alsa.c
drivers/platform/x86/thinkpad_acpi.c
drivers/staging/line6/audio.c
drivers/staging/line6/midi.c
drivers/staging/line6/pcm.c
drivers/staging/media/go7007/snd-go7007.c
drivers/staging/media/solo6x10/solo6x10-g723.c
drivers/usb/gadget/f_midi.c
drivers/usb/gadget/f_uac2.c
include/sound/core.h
include/sound/emu10k1.h
include/sound/hwdep.h
include/sound/pcm.h
include/sound/rawmidi.h
sound/aoa/aoa.h
sound/aoa/codecs/onyx.c
sound/aoa/codecs/tas.c
sound/aoa/codecs/toonie.c
sound/aoa/core/alsa.c
sound/arm/aaci.c
sound/arm/pxa2xx-ac97.c
sound/atmel/abdac.c
sound/atmel/ac97c.c
sound/core/control.c
sound/core/control_compat.c
sound/core/device.c
sound/core/hrtimer.c
sound/core/hwdep.c
sound/core/info.c
sound/core/init.c
sound/core/isadma.c
sound/core/memalloc.c
sound/core/oss/mixer_oss.c
sound/core/oss/pcm_oss.c
sound/core/pcm.c
sound/core/pcm_lib.c
sound/core/pcm_native.c
sound/core/pcm_timer.c
sound/core/rawmidi.c
sound/core/rtctimer.c
sound/core/seq/oss/seq_oss.c
sound/core/seq/oss/seq_oss_device.h
sound/core/seq/oss/seq_oss_init.c
sound/core/seq/oss/seq_oss_ioctl.c
sound/core/seq/oss/seq_oss_midi.c
sound/core/seq/oss/seq_oss_readq.c
sound/core/seq/oss/seq_oss_synth.c
sound/core/seq/oss/seq_oss_timer.c
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_device.c
sound/core/seq/seq_dummy.c
sound/core/seq/seq_fifo.c
sound/core/seq/seq_lock.c
sound/core/seq/seq_memory.c
sound/core/seq/seq_midi.c
sound/core/seq/seq_midi_emul.c
sound/core/seq/seq_ports.c
sound/core/seq/seq_prioq.c
sound/core/seq/seq_queue.c
sound/core/seq/seq_timer.c
sound/core/seq/seq_virmidi.c
sound/core/sound.c
sound/core/sound_oss.c
sound/core/timer.c
sound/core/vmaster.c
sound/drivers/aloop.c
sound/drivers/dummy.c
sound/drivers/ml403-ac97cr.c
sound/drivers/mpu401/mpu401.c
sound/drivers/mtpav.c
sound/drivers/mts64.c
sound/drivers/opl3/opl3_lib.c
sound/drivers/opl3/opl3_synth.c
sound/drivers/pcsp/pcsp.c
sound/drivers/pcsp/pcsp_input.c
sound/drivers/portman2x4.c
sound/drivers/serial-u16550.c
sound/drivers/virmidi.c
sound/firewire/dice.c
sound/firewire/isight.c
sound/firewire/scs1x.c
sound/firewire/speakers.c
sound/i2c/other/ak4113.c
sound/i2c/other/ak4114.c
sound/i2c/other/ak4117.c
sound/isa/ad1816a/ad1816a.c
sound/isa/ad1848/ad1848.c
sound/isa/adlib.c
sound/isa/als100.c
sound/isa/azt2320.c
sound/isa/cmi8328.c
sound/isa/cmi8330.c
sound/isa/cs423x/cs4231.c
sound/isa/cs423x/cs4236.c
sound/isa/es1688/es1688.c
sound/isa/es18xx.c
sound/isa/galaxy/galaxy.c
sound/isa/gus/gusclassic.c
sound/isa/gus/gusextreme.c
sound/isa/gus/gusmax.c
sound/isa/gus/interwave.c
sound/isa/msnd/msnd_pinnacle.c
sound/isa/opl3sa2.c
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/isa/sb/jazz16.c
sound/isa/sb/sb16.c
sound/isa/sb/sb8.c
sound/isa/sc6000.c
sound/isa/sscape.c
sound/isa/wavefront/wavefront.c
sound/mips/au1x00.c
sound/mips/hal2.c
sound/mips/sgio2audio.c
sound/oss/pas2.h
sound/oss/pas2_card.c
sound/parisc/harmony.c
sound/pci/Kconfig
sound/pci/ac97/ac97_codec.c
sound/pci/ac97/ac97_patch.c
sound/pci/ac97/ac97_pcm.c
sound/pci/ad1889.c
sound/pci/ali5451/ali5451.c
sound/pci/als300.c
sound/pci/als4000.c
sound/pci/asihpi/asihpi.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/au88x0/au88x0.c
sound/pci/aw2/aw2-alsa.c
sound/pci/aw2/aw2-saa7146.c
sound/pci/azt3328.c
sound/pci/bt87x.c
sound/pci/ca0106/ca0106_main.c
sound/pci/ca0106/ca_midi.c
sound/pci/cmipci.c
sound/pci/cs4281.c
sound/pci/cs46xx/cs46xx.c
sound/pci/cs46xx/cs46xx_lib.c
sound/pci/cs46xx/dsp_spos.c
sound/pci/cs46xx/dsp_spos_scb_lib.c
sound/pci/cs5530.c
sound/pci/cs5535audio/cs5535audio.c
sound/pci/cs5535audio/cs5535audio_olpc.c
sound/pci/cs5535audio/cs5535audio_pcm.c
sound/pci/cs5535audio/cs5535audio_pm.c
sound/pci/ctxfi/ctatc.c
sound/pci/ctxfi/xfi.c
sound/pci/echoaudio/echoaudio.c
sound/pci/echoaudio/echoaudio_dsp.c
sound/pci/echoaudio/midi.c
sound/pci/emu10k1/emu10k1.c
sound/pci/emu10k1/emu10k1_callback.c
sound/pci/emu10k1/emu10k1_main.c
sound/pci/emu10k1/emu10k1_patch.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/emu10k1/emufx.c
sound/pci/emu10k1/emumixer.c
sound/pci/emu10k1/emumpu401.c
sound/pci/emu10k1/emupcm.c
sound/pci/emu10k1/io.c
sound/pci/emu10k1/irq.c
sound/pci/emu10k1/memory.c
sound/pci/emu10k1/p16v.c
sound/pci/emu10k1/voice.c
sound/pci/ens1370.c
sound/pci/es1938.c
sound/pci/es1968.c
sound/pci/fm801.c
sound/pci/hda/Kconfig
sound/pci/hda/Makefile
sound/pci/hda/hda_auto_parser.c
sound/pci/hda/hda_beep.c
sound/pci/hda/hda_beep.h
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_controller.c [new file with mode: 0644]
sound/pci/hda/hda_controller.h [new file with mode: 0644]
sound/pci/hda/hda_eld.c
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_generic.h
sound/pci/hda/hda_hwdep.c
sound/pci/hda/hda_i915.c
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_local.h
sound/pci/hda/hda_priv.h [new file with mode: 0644]
sound/pci/hda/hda_sysfs.c [new file with mode: 0644]
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_ca0110.c
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_cirrus.c
sound/pci/hda/patch_cmedia.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_si3054.c
sound/pci/hda/patch_sigmatel.c
sound/pci/hda/patch_via.c
sound/pci/hda/thinkpad_helper.c
sound/pci/ice1712/aureon.c
sound/pci/ice1712/delta.c
sound/pci/ice1712/ews.c
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1724.c
sound/pci/ice1712/juli.c
sound/pci/ice1712/prodigy192.c
sound/pci/ice1712/quartet.c
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/korg1212/korg1212.c
sound/pci/lola/lola.c
sound/pci/lola/lola_clock.c
sound/pci/lola/lola_mixer.c
sound/pci/lola/lola_pcm.c
sound/pci/lx6464es/lx6464es.c
sound/pci/lx6464es/lx_core.c
sound/pci/maestro3.c
sound/pci/mixart/mixart.c
sound/pci/mixart/mixart_core.c
sound/pci/mixart/mixart_hwdep.c
sound/pci/mixart/mixart_mixer.c
sound/pci/nm256/nm256.c
sound/pci/oxygen/oxygen_io.c
sound/pci/oxygen/oxygen_lib.c
sound/pci/oxygen/xonar_hdmi.c
sound/pci/oxygen/xonar_lib.c
sound/pci/pcxhr/pcxhr.c
sound/pci/pcxhr/pcxhr_core.c
sound/pci/pcxhr/pcxhr_hwdep.c
sound/pci/pcxhr/pcxhr_mix22.c
sound/pci/pcxhr/pcxhr_mixer.c
sound/pci/riptide/riptide.c
sound/pci/rme32.c
sound/pci/rme96.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/rme9652/rme9652.c
sound/pci/sis7019.c
sound/pci/sonicvibes.c
sound/pci/trident/trident.c
sound/pci/trident/trident_main.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/vx222/vx222.c
sound/pci/vx222/vx222_ops.c
sound/pci/ymfpci/ymfpci.c
sound/pci/ymfpci/ymfpci_main.c
sound/pcmcia/pdaudiocf/pdaudiocf.c
sound/pcmcia/vx/vxpocket.c
sound/ppc/powermac.c
sound/ppc/snd_ps3.c
sound/sh/aica.c
sound/sh/sh_dac_audio.c
sound/soc/soc-core.c
sound/sparc/amd7930.c
sound/sparc/cs4231.c
sound/sparc/dbri.c
sound/spi/at73c213.c
sound/usb/6fire/chip.c
sound/usb/6fire/comm.c
sound/usb/6fire/control.c
sound/usb/6fire/firmware.c
sound/usb/6fire/midi.c
sound/usb/6fire/pcm.c
sound/usb/caiaq/device.c
sound/usb/card.c
sound/usb/clock.c
sound/usb/endpoint.c
sound/usb/format.c
sound/usb/hiface/chip.c
sound/usb/midi.c
sound/usb/misc/ua101.c
sound/usb/mixer.c
sound/usb/mixer.h
sound/usb/mixer_quirks.c
sound/usb/pcm.c
sound/usb/quirks.c
sound/usb/stream.c
sound/usb/usbaudio.h
sound/usb/usx2y/us122l.c
sound/usb/usx2y/usbusx2y.c
sound/usb/usx2y/usbusx2y.h
sound/usb/usx2y/usbusx2yaudio.c
sound/usb/usx2y/usx2yhwdeppcm.c

index 06741e9259850d43eaac5d287da48fa284992255..d0056a4e9c53fc9e455ec5eaad518074dbc5b152 100644 (file)
                   return err;
           }
 
-          snd_card_set_dev(card, &pci->dev);
-
           *rchip = chip;
           return 0;
   }
           }
 
           /* (2) */
-          err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+          err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                             0, &card);
           if (err < 0)
                   return err;
 
   struct snd_card *card;
   int err;
   ....
-  err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+  err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                     0, &card);
 ]]>
             </programlisting>
           </informalexample>
 
       <para>
         As mentioned above, to create a card instance, call
-      <function>snd_card_create()</function>.
+      <function>snd_card_new()</function>.
 
         <informalexample>
           <programlisting>
 <![CDATA[
   struct snd_card *card;
   int err;
-  err = snd_card_create(index, id, module, extra_size, &card);
+  err = snd_card_new(&pci->dev, index, id, module, extra_size, &card);
 ]]>
           </programlisting>
         </informalexample>
       </para>
 
       <para>
-        The function takes five arguments, the card-index number, the
-        id string, the module pointer (usually
+        The function takes six arguments: the parent device pointer,
+        the card-index number, the id string, the module pointer (usually
         <constant>THIS_MODULE</constant>),
         the size of extra-data space, and the pointer to return the
         card instance.  The extra_size argument is used to
         allocate card-&gt;private_data for the
         chip-specific data.  Note that these data
-        are allocated by <function>snd_card_create()</function>.
+        are allocated by <function>snd_card_new()</function>.
+      </para>
+
+      <para>
+       The first argument, the pointer of struct
+       <structname>device</structname>, specifies the parent device.
+       For PCI devices, typically &amp;pci-&gt; is passed there.
       </para>
     </section>
 
       </para>
 
       <section id="card-management-chip-specific-snd-card-new">
-        <title>1. Allocating via <function>snd_card_create()</function>.</title>
+        <title>1. Allocating via <function>snd_card_new()</function>.</title>
         <para>
           As mentioned above, you can pass the extra-data-length
-         to the 4th argument of <function>snd_card_create()</function>, i.e.
+         to the 5th argument of <function>snd_card_new()</function>, i.e.
 
           <informalexample>
             <programlisting>
 <![CDATA[
-  err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                        sizeof(struct mychip), &card);
+  err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                     sizeof(struct mychip), &card);
 ]]>
             </programlisting>
           </informalexample>
 
         <para>
           After allocating a card instance via
-          <function>snd_card_create()</function> (with
+          <function>snd_card_new()</function> (with
           <constant>0</constant> on the 4th arg), call
           <function>kzalloc()</function>. 
 
 <![CDATA[
   struct snd_card *card;
   struct mychip *chip;
-  err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+  err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                     0, &card);
   .....
   chip = kzalloc(sizeof(*chip), GFP_KERNEL);
 ]]>
                   return err;
           }
 
-          snd_card_set_dev(card, &pci->dev);
-
           *rchip = chip;
           return 0;
   }        
 
     </section>
 
-    <section id="pci-resource-device-struct">
-      <title>Registration of Device Struct</title>
-      <para>
-       At some point, typically after calling <function>snd_device_new()</function>,
-       you need to register the struct <structname>device</structname> of the chip
-       you're handling for udev and co.  ALSA provides a macro for compatibility with
-       older kernels.  Simply call like the following:
-        <informalexample>
-          <programlisting>
-<![CDATA[
-  snd_card_set_dev(card, &pci->dev);
-]]>
-          </programlisting>
-        </informalexample>
-       so that it stores the PCI's device pointer to the card.  This will be
-       referred by ALSA core functions later when the devices are registered.
-      </para>
-      <para>
-       In the case of non-PCI, pass the proper device struct pointer of the BUS
-       instead.  (In the case of legacy ISA without PnP, you don't have to do
-       anything.)
-      </para>
-    </section>
-
     <section id="pci-resource-entries">
       <title>PCI Entries</title>
       <para>
@@ -5740,7 +5721,8 @@ struct _snd_pcm_runtime {
           struct mychip *chip;
           int err;
           ....
-          err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+          err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                             0, &card);
           ....
           chip = kzalloc(sizeof(*chip), GFP_KERNEL);
           ....
@@ -5752,7 +5734,7 @@ struct _snd_pcm_runtime {
       </informalexample>
 
        When you created the chip data with
-       <function>snd_card_create()</function>, it's anyway accessible
+       <function>snd_card_new()</function>, it's anyway accessible
        via <structfield>private_data</structfield> field.
 
       <informalexample>
@@ -5766,8 +5748,8 @@ struct _snd_pcm_runtime {
           struct mychip *chip;
           int err;
           ....
-          err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                                sizeof(struct mychip), &card);
+          err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct mychip), &card);
           ....
           chip = card->private_data;
           ....
index 7ed82805641477e5556dff5f12898f2f42095559..91fab975063ce889b1ceae0bafbab2273d77186b 100644 (file)
@@ -624,7 +624,8 @@ static int pcmidi_snd_initialise(struct pcmidi_snd *pm)
 
        /* Setup sound card */
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pm->pk->hdev->dev, index[dev], id[dev],
+                          THIS_MODULE, 0, &card);
        if (err < 0) {
                pk_error("failed to create pc-midi sound card\n");
                err = -ENOMEM;
@@ -660,8 +661,6 @@ static int pcmidi_snd_initialise(struct pcmidi_snd *pm)
        snd_rawmidi_set_ops(rwmidi, SNDRV_RAWMIDI_STREAM_INPUT,
                &pcmidi_in_ops);
 
-       snd_card_set_dev(card, &pm->pk->hdev->dev);
-
        /* create sysfs variables */
        err = device_create_file(&pm->pk->hdev->dev,
                                 sysfs_device_attr_channel);
index b2c8c3439fea88ca441c435cfcb4d04387d997db..ea272bcb38df14e086f226fe024ec17e0ef98574 100644 (file)
@@ -145,11 +145,12 @@ static int snd_cx18_init(struct v4l2_device *v4l2_dev)
        /* This is a no-op for us.  We'll use the cx->instance */
 
        /* (2) Create a card instance */
-       ret = snd_card_create(SNDRV_DEFAULT_IDX1, /* use first available id */
-                             SNDRV_DEFAULT_STR1, /* xid from end of shortname*/
-                             THIS_MODULE, 0, &sc);
+       ret = snd_card_new(&cx->pci_dev->dev,
+                          SNDRV_DEFAULT_IDX1, /* use first available id */
+                          SNDRV_DEFAULT_STR1, /* xid from end of shortname*/
+                          THIS_MODULE, 0, &sc);
        if (ret) {
-               CX18_ALSA_ERR("%s: snd_card_create() failed with err %d\n",
+               CX18_ALSA_ERR("%s: snd_card_new() failed with err %d\n",
                              __func__, ret);
                goto err_exit;
        }
index c6c9bd58f8be87426ed63200cfc729428e7b417b..554798dcedd09b3a1ad86961b2fd5fde691df254 100644 (file)
@@ -489,7 +489,8 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
                return NULL;
        }
 
-       err = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+       err = snd_card_new(&dev->pci->dev,
+                          SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
                        THIS_MODULE, sizeof(struct cx23885_audio_dev), &card);
        if (err < 0)
                goto error;
@@ -500,8 +501,6 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
        chip->card = card;
        spin_lock_init(&chip->lock);
 
-       snd_card_set_dev(card, &dev->pci->dev);
-
        err = snd_cx23885_pcm(chip, 0, "CX23885 Digital");
        if (err < 0)
                goto error;
index b1e08c3e55cd5561d286700f470adcaf3e182776..2dd5bcaa7e53c4b80868b24f15683e5d07580819 100644 (file)
@@ -645,8 +645,9 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
                return -ENOENT;
        }
 
-       err = snd_card_create(index[devno], id[devno], THIS_MODULE,
-                       sizeof(struct cx25821_audio_dev), &card);
+       err = snd_card_new(&dev->pci->dev, index[devno], id[devno],
+                          THIS_MODULE,
+                          sizeof(struct cx25821_audio_dev), &card);
        if (err < 0) {
                pr_info("DEBUG ERROR: cannot create snd_card_new in %s\n",
                        __func__);
@@ -682,8 +683,6 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
                goto error;
        }
 
-       snd_card_set_dev(card, &chip->pci->dev);
-
        strcpy(card->shortname, "cx25821");
        sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name,
                chip->iobase, chip->irq);
index d014206e71762799ad007ce676af13cef333566a..a72579a9f67f15d8c2e1640f57719c32787fc00a 100644 (file)
@@ -852,8 +852,6 @@ static int snd_cx88_create(struct snd_card *card, struct pci_dev *pci,
        chip->irq = pci->irq;
        synchronize_irq(chip->irq);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        *core_ptr = core;
 
@@ -876,8 +874,8 @@ static int cx88_audio_initdev(struct pci_dev *pci,
                return (-ENOENT);
        }
 
-       err = snd_card_create(index[devno], id[devno], THIS_MODULE,
-                             sizeof(snd_cx88_card_t), &card);
+       err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE,
+                          sizeof(snd_cx88_card_t), &card);
        if (err < 0)
                return err;
 
index e970cface70edfaea231213ddafd983d379630f4..39b52929755aca482839c01f46f4fd2251183bd6 100644 (file)
@@ -145,11 +145,12 @@ static int snd_ivtv_init(struct v4l2_device *v4l2_dev)
        /* This is a no-op for us.  We'll use the itv->instance */
 
        /* (2) Create a card instance */
-       ret = snd_card_create(SNDRV_DEFAULT_IDX1, /* use first available id */
-                             SNDRV_DEFAULT_STR1, /* xid from end of shortname*/
-                             THIS_MODULE, 0, &sc);
+       ret = snd_card_new(&itv->pdev->dev,
+                          SNDRV_DEFAULT_IDX1, /* use first available id */
+                          SNDRV_DEFAULT_STR1, /* xid from end of shortname*/
+                          THIS_MODULE, 0, &sc);
        if (ret) {
-               IVTV_ALSA_ERR("%s: snd_card_create() failed with err %d\n",
+               IVTV_ALSA_ERR("%s: snd_card_new() failed with err %d\n",
                              __func__, ret);
                goto err_exit;
        }
index dd67c8a400cc5d02f20b33967d27c9698846355b..e04a4d5d66722192a9b6e1452d51ba822a803c55 100644 (file)
@@ -1072,8 +1072,8 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
        if (!enable[devnum])
                return -ENODEV;
 
-       err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
-                             sizeof(snd_card_saa7134_t), &card);
+       err = snd_card_new(&dev->pci->dev, index[devnum], id[devnum],
+                          THIS_MODULE, sizeof(snd_card_saa7134_t), &card);
        if (err < 0)
                return err;
 
@@ -1115,8 +1115,6 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
        if ((err = snd_card_saa7134_pcm(chip, 0)) < 0)
                goto __nodev;
 
-       snd_card_set_dev(card, &chip->pci->dev);
-
        /* End of "creation" */
 
        strcpy(card->shortname, "SAA7134");
index 81a1d971d797e449e0fc2a08c8f5d7511b5ae6c5..9b925874d392de05a7c44e3192aa8953e68c5a27 100644 (file)
@@ -665,8 +665,8 @@ static int cx231xx_audio_init(struct cx231xx *dev)
        cx231xx_info("cx231xx-audio.c: probing for cx231xx "
                     "non standard usbaudio\n");
 
-       err = snd_card_create(index[devnr], "Cx231xx Audio", THIS_MODULE,
-                             0, &card);
+       err = snd_card_new(&dev->udev->dev, index[devnr], "Cx231xx Audio",
+                          THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -682,7 +682,6 @@ static int cx231xx_audio_init(struct cx231xx *dev)
        pcm->info_flags = 0;
        pcm->private_data = dev;
        strcpy(pcm->name, "Conexant cx231xx Capture");
-       snd_card_set_dev(card, &dev->udev->dev);
        strcpy(card->driver, "Cx231xx-Audio");
        strcpy(card->shortname, "Cx231xx Audio");
        strcpy(card->longname, "Conexant cx231xx Audio");
index 05e9bd11a3ff016128e6c9dd05e1086cd454ce0e..1a28897af1831d1ebfc8e101a25e71e5732ba1a3 100644 (file)
@@ -900,8 +900,8 @@ static int em28xx_audio_init(struct em28xx *dev)
        printk(KERN_INFO
               "em28xx-audio.c: Copyright (C) 2007-2014 Mauro Carvalho Chehab\n");
 
-       err = snd_card_create(index[devnr], "Em28xx Audio", THIS_MODULE, 0,
-                             &card);
+       err = snd_card_new(&dev->udev->dev, index[devnr], "Em28xx Audio",
+                          THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -918,7 +918,6 @@ static int em28xx_audio_init(struct em28xx *dev)
        pcm->private_data = dev;
        strcpy(pcm->name, "Empia 28xx Capture");
 
-       snd_card_set_dev(card, &dev->udev->dev);
        strcpy(card->driver, "Em28xx-Audio");
        strcpy(card->shortname, "Em28xx Audio");
        strcpy(card->longname, "Empia Em28xx Audio");
index c8583c262c3d0b6f055cdf73a77e7d78037e2929..c46c8be896029534f2b08228eee825247398995d 100644 (file)
@@ -98,13 +98,11 @@ int stk1160_ac97_register(struct stk1160 *dev)
         * Just want a card to access ac96 controls,
         * the actual capture interface will be handled by snd-usb-audio
         */
-       rc = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
-                             THIS_MODULE, 0, &card);
+       rc = snd_card_new(dev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+                         THIS_MODULE, 0, &card);
        if (rc < 0)
                return rc;
 
-       snd_card_set_dev(card, dev->dev);
-
        /* TODO: I'm not sure where should I get these names :-( */
        snprintf(card->shortname, sizeof(card->shortname),
                 "stk1160-mixer");
index 3f3e141f70fb963547074f47a867e79ff4664e49..dd8fe100590ff88d6d202c7ecc112bb469e2bfac 100644 (file)
@@ -300,7 +300,8 @@ int poseidon_audio_init(struct poseidon *p)
        struct snd_pcm *pcm;
        int ret;
 
-       ret = snd_card_create(-1, "Telegent", THIS_MODULE, 0, &card);
+       ret = snd_card_new(&p->interface->dev, -1, "Telegent",
+                          THIS_MODULE, 0, &card);
        if (ret != 0)
                return ret;
 
index 813c1ec5360884274f5d3e31e66f9d38d91d0753..3239cd62e4529e57d1af2fbf074fffd0539bc2d9 100644 (file)
@@ -431,7 +431,8 @@ static int tm6000_audio_init(struct tm6000_core *dev)
        if (!enable[devnr])
                return -ENOENT;
 
-       rc = snd_card_create(index[devnr], "tm6000", THIS_MODULE, 0, &card);
+       rc = snd_card_new(&dev->udev->dev, index[devnr], "tm6000",
+                         THIS_MODULE, 0, &card);
        if (rc < 0) {
                snd_printk(KERN_ERR "cannot create card instance %d\n", devnr);
                return rc;
@@ -445,7 +446,6 @@ static int tm6000_audio_init(struct tm6000_core *dev)
                le16_to_cpu(dev->udev->descriptor.idVendor),
                le16_to_cpu(dev->udev->descriptor.idProduct));
        snd_component_add(card, component);
-       snd_card_set_dev(card, &dev->udev->dev);
 
        chip = kzalloc(sizeof(struct snd_tm6000_card), GFP_KERNEL);
        if (!chip) {
index defb6afc1409cc7fff0863d6829c5c26478b6a4a..94bb6157c957b495a955159ea4916769f373862f 100644 (file)
@@ -6776,8 +6776,9 @@ static int __init volume_create_alsa_mixer(void)
        struct snd_kcontrol *ctl_mute;
        int rc;
 
-       rc = snd_card_create(alsa_index, alsa_id, THIS_MODULE,
-                           sizeof(struct tpacpi_alsa_data), &card);
+       rc = snd_card_new(&tpacpi_pdev->dev,
+                         alsa_index, alsa_id, THIS_MODULE,
+                         sizeof(struct tpacpi_alsa_data), &card);
        if (rc < 0 || !card) {
                pr_err("Failed to create ALSA card structures: %d\n", rc);
                return 1;
@@ -6828,7 +6829,6 @@ static int __init volume_create_alsa_mixer(void)
        }
        data->ctl_mute_id = &ctl_mute->id;
 
-       snd_card_set_dev(card, &tpacpi_pdev->dev);
        rc = snd_card_register(card);
        if (rc < 0) {
                pr_err("Failed to register ALSA card: %d\n", rc);
index a92e21f7d55b83bb1b537e48259b1202271699fa..171d80c1b02071fdadc2e7111e34b0cde49565a6 100644 (file)
@@ -24,8 +24,9 @@ int line6_init_audio(struct usb_line6 *line6)
        struct snd_card *card;
        int err;
 
-       err = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
-                             THIS_MODULE, 0, &card);
+       err = snd_card_new(line6->ifcdev,
+                          SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+                          THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index 3f6d78c585fb925d75bb630e07dab6f67c124b95..c61cd0515baf299a244c9c44ff393dfcc0cf0cda 100644 (file)
@@ -307,8 +307,6 @@ int line6_init_midi(struct usb_line6 *line6)
        if (err < 0)
                return err;
 
-       snd_card_set_dev(line6->card, line6->ifcdev);
-
        err = snd_line6_new_midi(line6midi);
        if (err < 0)
                return err;
index df8331bce1754a71206d86d426209ba2fab33075..661080b3c39df8c2f8e1c43ed9473d4eb603cc25 100644 (file)
@@ -501,8 +501,6 @@ int line6_init_pcm(struct usb_line6 *line6,
        if (err < 0)
                return err;
 
-       snd_card_set_dev(line6->card, line6->ifcdev);
-
        err = snd_line6_new_pcm(line6pcm);
        if (err < 0)
                return err;
index 16dd64920767de37662a63dfb400ddd2298bd33b..9eb2a20ae40a97916721599bbd80bfc04190e795 100644 (file)
@@ -245,8 +245,8 @@ int go7007_snd_init(struct go7007 *go)
        spin_lock_init(&gosnd->lock);
        gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0;
        gosnd->capturing = 0;
-       ret = snd_card_create(index[dev], id[dev], THIS_MODULE, 0,
-                             &gosnd->card);
+       ret = snd_card_new(go->dev, index[dev], id[dev], THIS_MODULE, 0,
+                          &gosnd->card);
        if (ret < 0) {
                kfree(gosnd);
                return ret;
@@ -257,7 +257,6 @@ int go7007_snd_init(struct go7007 *go)
                kfree(gosnd);
                return ret;
        }
-       snd_card_set_dev(gosnd->card, go->dev);
        ret = snd_pcm_new(gosnd->card, "go7007", 0, 0, 1, &gosnd->pcm);
        if (ret < 0) {
                snd_card_free(gosnd->card);
index 1db18c7972a00cfc6db7c94d824f1e7b03676d4c..74f037b6166c2a3f15510914cfff6b70451ccedf 100644 (file)
@@ -366,8 +366,9 @@ int solo_g723_init(struct solo_dev *solo_dev)
        /* Allows for easier mapping between video and audio */
        sprintf(name, "Softlogic%d", solo_dev->vfd->num);
 
-       ret = snd_card_create(SNDRV_DEFAULT_IDX1, name, THIS_MODULE, 0,
-                             &solo_dev->snd_card);
+       ret = snd_card_new(&solo_dev->pdev->dev,
+                          SNDRV_DEFAULT_IDX1, name, THIS_MODULE, 0,
+                          &solo_dev->snd_card);
        if (ret < 0)
                return ret;
 
@@ -377,7 +378,6 @@ int solo_g723_init(struct solo_dev *solo_dev)
        strcpy(card->shortname, "SOLO-6x10 Audio");
        sprintf(card->longname, "%s on %s IRQ %d", card->shortname,
                pci_name(solo_dev->pdev), solo_dev->pdev->irq);
-       snd_card_set_dev(card, &solo_dev->pdev->dev);
 
        ret = snd_device_new(card, SNDRV_DEV_LOWLEVEL, solo_dev, &ops);
        if (ret < 0)
index 36d4bb23087f4743a9309783ab80b7d3c4d31d18..807b31c0edc31b547b079637cac1bf26a06fe6c8 100644 (file)
@@ -664,9 +664,10 @@ static int f_midi_register_card(struct f_midi *midi)
                .dev_free = f_midi_snd_free,
        };
 
-       err = snd_card_create(midi->index, midi->id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&midi->gadget->dev, midi->index, midi->id,
+                          THIS_MODULE, 0, &card);
        if (err < 0) {
-               ERROR(midi, "snd_card_create() failed\n");
+               ERROR(midi, "snd_card_new() failed\n");
                goto fail;
        }
        midi->card = card;
@@ -703,8 +704,6 @@ static int f_midi_register_card(struct f_midi *midi)
        snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &gmidi_in_ops);
        snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &gmidi_out_ops);
 
-       snd_card_set_dev(card, &midi->gadget->dev);
-
        /* register it - we're ready to go */
        err = snd_card_register(card);
        if (err < 0) {
index 2f23566e53d88bf7fd618efcc100b49447c0cf27..bc23040c7790387b4a206b2814de5860f61a3b1c 100644 (file)
@@ -394,7 +394,7 @@ static int snd_uac2_probe(struct platform_device *pdev)
        int err;
 
        /* Choose any slot, with no id */
-       err = snd_card_create(-1, NULL, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pdev->dev, -1, NULL, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -421,8 +421,6 @@ static int snd_uac2_probe(struct platform_device *pdev)
        strcpy(card->shortname, "UAC2_Gadget");
        sprintf(card->longname, "UAC2_Gadget %i", pdev->id);
 
-       snd_card_set_dev(card, &pdev->dev);
-
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
                snd_dma_continuous_data(GFP_KERNEL), 0, BUFF_SIZE_MAX);
 
index 2a14f1f02d4f6766e236b288f6173ee7391e78a2..d3f5f818e0b901909f1ad8c92f8d0930b338cd78 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+#include <linux/device.h>
 #include <linux/sched.h>               /* wake_up() */
 #include <linux/mutex.h>               /* struct mutex */
 #include <linux/rwsem.h>               /* struct rw_semaphore */
 /* forward declarations */
 struct pci_dev;
 struct module;
-struct device;
-struct device_attribute;
+struct completion;
 
 /* device allocation stuff */
 
-#define SNDRV_DEV_TYPE_RANGE_SIZE              0x1000
-
-typedef int __bitwise snd_device_type_t;
-#define        SNDRV_DEV_TOPLEVEL      ((__force snd_device_type_t) 0)
-#define        SNDRV_DEV_CONTROL       ((__force snd_device_type_t) 1)
-#define        SNDRV_DEV_LOWLEVEL_PRE  ((__force snd_device_type_t) 2)
-#define        SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000)
-#define        SNDRV_DEV_PCM           ((__force snd_device_type_t) 0x1001)
-#define        SNDRV_DEV_RAWMIDI       ((__force snd_device_type_t) 0x1002)
-#define        SNDRV_DEV_TIMER         ((__force snd_device_type_t) 0x1003)
-#define        SNDRV_DEV_SEQUENCER     ((__force snd_device_type_t) 0x1004)
-#define        SNDRV_DEV_HWDEP         ((__force snd_device_type_t) 0x1005)
-#define        SNDRV_DEV_INFO          ((__force snd_device_type_t) 0x1006)
-#define        SNDRV_DEV_BUS           ((__force snd_device_type_t) 0x1007)
-#define        SNDRV_DEV_CODEC         ((__force snd_device_type_t) 0x1008)
-#define        SNDRV_DEV_JACK          ((__force snd_device_type_t) 0x1009)
-#define        SNDRV_DEV_COMPRESS      ((__force snd_device_type_t) 0x100A)
-#define        SNDRV_DEV_LOWLEVEL      ((__force snd_device_type_t) 0x2000)
-
-typedef int __bitwise snd_device_state_t;
-#define        SNDRV_DEV_BUILD         ((__force snd_device_state_t) 0)
-#define        SNDRV_DEV_REGISTERED    ((__force snd_device_state_t) 1)
-#define        SNDRV_DEV_DISCONNECTED  ((__force snd_device_state_t) 2)
-
-typedef int __bitwise snd_device_cmd_t;
-#define        SNDRV_DEV_CMD_PRE       ((__force snd_device_cmd_t) 0)
-#define        SNDRV_DEV_CMD_NORMAL    ((__force snd_device_cmd_t) 1)  
-#define        SNDRV_DEV_CMD_POST      ((__force snd_device_cmd_t) 2)
+/* type of the object used in snd_device_*()
+ * this also defines the calling order
+ */
+enum snd_device_type {
+       SNDRV_DEV_LOWLEVEL,
+       SNDRV_DEV_CONTROL,
+       SNDRV_DEV_INFO,
+       SNDRV_DEV_BUS,
+       SNDRV_DEV_CODEC,
+       SNDRV_DEV_PCM,
+       SNDRV_DEV_COMPRESS,
+       SNDRV_DEV_RAWMIDI,
+       SNDRV_DEV_TIMER,
+       SNDRV_DEV_SEQUENCER,
+       SNDRV_DEV_HWDEP,
+       SNDRV_DEV_JACK,
+};
+
+enum snd_device_state {
+       SNDRV_DEV_BUILD,
+       SNDRV_DEV_REGISTERED,
+       SNDRV_DEV_DISCONNECTED,
+};
 
 struct snd_device;
 
@@ -86,8 +81,8 @@ struct snd_device_ops {
 struct snd_device {
        struct list_head list;          /* list of registered devices */
        struct snd_card *card;          /* card which holds this device */
-       snd_device_state_t state;       /* state of the device */
-       snd_device_type_t type;         /* device type */
+       enum snd_device_state state;    /* state of the device */
+       enum snd_device_type type;      /* device type */
        void *device_data;              /* device structure */
        struct snd_device_ops *ops;     /* operations */
 };
@@ -131,11 +126,10 @@ struct snd_card {
                                                                state */
        spinlock_t files_lock;          /* lock the files for this card */
        int shutdown;                   /* this card is going down */
-       int free_on_last_close;         /* free in context of file_release */
-       wait_queue_head_t shutdown_sleep;
-       atomic_t refcount;              /* refcount for disconnection */
+       struct completion *release_completion;
        struct device *dev;             /* device assigned to this card */
-       struct device *card_dev;        /* cardX object for sysfs */
+       struct device card_dev;         /* cardX object for sysfs */
+       bool registered;                /* card_dev is registered? */
 
 #ifdef CONFIG_PM
        unsigned int power_state;       /* power state */
@@ -149,6 +143,8 @@ struct snd_card {
 #endif
 };
 
+#define dev_to_snd_card(p)     container_of(p, struct snd_card, card_dev)
+
 #ifdef CONFIG_PM
 static inline void snd_power_lock(struct snd_card *card)
 {
@@ -197,7 +193,7 @@ struct snd_minor {
 /* return a device pointer linked to each sound device as a parent */
 static inline struct device *snd_card_get_device_link(struct snd_card *card)
 {
-       return card ? card->card_dev : NULL;
+       return card ? &card->card_dev : NULL;
 }
 
 /* sound.c */
@@ -244,13 +240,11 @@ static inline int snd_register_device(int type, struct snd_card *card, int dev,
 
 int snd_unregister_device(int type, struct snd_card *card, int dev);
 void *snd_lookup_minor_data(unsigned int minor, int type);
-int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
-                             struct device_attribute *attr);
+struct device *snd_get_device(int type, struct snd_card *card, int dev);
 
 #ifdef CONFIG_SND_OSSEMUL
 int snd_register_oss_device(int type, struct snd_card *card, int dev,
-                           const struct file_operations *f_ops, void *private_data,
-                           const char *name);
+                           const struct file_operations *f_ops, void *private_data);
 int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
 void *snd_lookup_oss_minor_data(unsigned int minor, int type);
 #endif
@@ -284,9 +278,16 @@ int snd_card_locked(int card);
 extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd);
 #endif
 
-int snd_card_create(int idx, const char *id,
-                   struct module *module, int extra_size,
-                   struct snd_card **card_ret);
+int snd_card_new(struct device *parent, int idx, const char *xid,
+                struct module *module, int extra_size,
+                struct snd_card **card_ret);
+
+static inline int __deprecated
+snd_card_create(int idx, const char *id, struct module *module, int extra_size,
+               struct snd_card **ret)
+{
+       return snd_card_new(NULL, idx, id, module, extra_size, ret);
+}
 
 int snd_card_disconnect(struct snd_card *card);
 int snd_card_free(struct snd_card *card);
@@ -298,20 +299,19 @@ int snd_card_info_done(void);
 int snd_component_add(struct snd_card *card, const char *component);
 int snd_card_file_add(struct snd_card *card, struct file *file);
 int snd_card_file_remove(struct snd_card *card, struct file *file);
-void snd_card_unref(struct snd_card *card);
+#define snd_card_unref(card)   put_device(&(card)->card_dev)
 
 #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
 
 /* device.c */
 
-int snd_device_new(struct snd_card *card, snd_device_type_t type,
+int snd_device_new(struct snd_card *card, enum snd_device_type type,
                   void *device_data, struct snd_device_ops *ops);
 int snd_device_register(struct snd_card *card, void *device_data);
 int snd_device_register_all(struct snd_card *card);
-int snd_device_disconnect(struct snd_card *card, void *device_data);
 int snd_device_disconnect_all(struct snd_card *card);
-int snd_device_free(struct snd_card *card, void *device_data);
-int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
+void snd_device_free(struct snd_card *card, void *device_data);
+void snd_device_free_all(struct snd_card *card);
 
 /* isadma.c */
 
@@ -433,7 +433,6 @@ static inline void snd_printdd(const char *format, ...) {}
 #define gameport_get_port_data(gp) (gp)->port_data
 #endif
 
-#ifdef CONFIG_PCI
 /* PCI quirk list helper */
 struct snd_pci_quirk {
        unsigned short subvendor;       /* PCI subvendor ID */
@@ -469,12 +468,26 @@ struct snd_pci_quirk {
 #define snd_pci_quirk_name(q)  ""
 #endif
 
+#ifdef CONFIG_PCI
 const struct snd_pci_quirk *
 snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
 
 const struct snd_pci_quirk *
 snd_pci_quirk_lookup_id(u16 vendor, u16 device,
                        const struct snd_pci_quirk *list);
+#else
+static inline const struct snd_pci_quirk *
+snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
+{
+       return NULL;
+}
+
+static inline const struct snd_pci_quirk *
+snd_pci_quirk_lookup_id(u16 vendor, u16 device,
+                       const struct snd_pci_quirk *list)
+{
+       return NULL;
+}
 #endif
 
 #endif /* __SOUND_CORE_H */
index dfb42ca6d0436539ada89bcd063c26e5c4e85d86..c46908c1bb3f006268222f5c57af257aa3e76ef1 100644 (file)
 #define CCCA_CURRADDR_MASK     0x00ffffff      /* Current address of the selected channel              */
 #define CCCA_CURRADDR          0x18000008
 
-/* undefine CCR to avoid conflict with the definition for SH */
-#undef CCR
 #define CCR                    0x09            /* Cache control register                               */
 #define CCR_CACHEINVALIDSIZE   0x07190009
 #define CCR_CACHEINVALIDSIZE_MASK      0xfe000000      /* Number of invalid samples cache for this channel     */
index 8c05e47a409053c69ddec36b60aee44b84907330..ae04a3ec9c774e6ba41508e595535b92216dce8e 100644 (file)
@@ -60,7 +60,6 @@ struct snd_hwdep {
        int iface;
 
 #ifdef CONFIG_SND_OSSEMUL
-       char oss_dev[32];
        int oss_type;
        int ossreg;
 #endif
@@ -69,6 +68,8 @@ struct snd_hwdep {
        wait_queue_head_t open_wait;
        void *private_data;
        void (*private_free) (struct snd_hwdep *hwdep);
+       struct device *dev;
+       const struct attribute_group **groups;
 
        struct mutex open_mutex;
        int used;                       /* reference counter */
index 4883499ab38b07834dc6b4ee3fe085bf93b0efdf..b4d6697085fef71c2d31160c58ed70ff0f350686 100644 (file)
@@ -1141,4 +1141,12 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
        return 1ULL << (__force int) pcm_format;
 }
 
+/* printk helpers */
+#define pcm_err(pcm, fmt, args...) \
+       dev_err((pcm)->card->dev, fmt, ##args)
+#define pcm_warn(pcm, fmt, args...) \
+       dev_warn((pcm)->card->dev, fmt, ##args)
+#define pcm_dbg(pcm, fmt, args...) \
+       dev_dbg((pcm)->card->dev, fmt, ##args)
+
 #endif /* __SOUND_PCM_H */
index adf0885153f358ee5697d18e640e174c024e1b72..311dafe6cc4b508ecc372ba45d8f647d55b44f9c 100644 (file)
@@ -157,10 +157,8 @@ void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
 
 /* callbacks */
 
-void snd_rawmidi_receive_reset(struct snd_rawmidi_substream *substream);
 int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
                        const unsigned char *buffer, int count);
-void snd_rawmidi_transmit_reset(struct snd_rawmidi_substream *substream);
 int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream);
 int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
                              unsigned char *buffer, int count);
index e08789484e3001e08e53acd481d97dcc37a7f88f..34c668f2779882f10b278a5e92654511eec90ec6 100644 (file)
@@ -116,7 +116,7 @@ struct aoa_card {
        struct snd_card *alsa_card;
 };
         
-extern int aoa_snd_device_new(snd_device_type_t type,
+extern int aoa_snd_device_new(enum snd_device_type type,
        void * device_data, struct snd_device_ops * ops);
 extern struct snd_card *aoa_get_card(void);
 extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
index 4cedc6950d72ffb79c329612fd91dc0fed465668..f01bffb702bc3d84544b0a29e12a158eb38805d1 100644 (file)
@@ -889,7 +889,7 @@ static int onyx_init_codec(struct aoa_codec *codec)
                return -ENODEV;
        }
 
-       if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, onyx, &ops)) {
+       if (aoa_snd_device_new(SNDRV_DEV_CODEC, onyx, &ops)) {
                printk(KERN_ERR PFX "failed to create onyx snd device!\n");
                return -ENODEV;
        }
index c491ae0f749ca42578c8fd8faf4f4b43f0fcaf55..cf3c6303b7e3ca8e3dba43f00fb3ce934620ab50 100644 (file)
@@ -826,7 +826,7 @@ static int tas_init_codec(struct aoa_codec *codec)
                return -ENODEV;
        }
 
-       if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, tas, &ops)) {
+       if (aoa_snd_device_new(SNDRV_DEV_CODEC, tas, &ops)) {
                printk(KERN_ERR PFX "failed to create tas snd device!\n");
                return -ENODEV;
        }
index 69d2cb601f2a4daa7d32d6abda14c5095b56de01..7e8c3417cd853999246f3292dd16e395f6e70e6b 100644 (file)
@@ -92,7 +92,7 @@ static int toonie_init_codec(struct aoa_codec *codec)
        if (toonie->codec.connected != 1)
                return -ENOTCONN;
 
-       if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, toonie, &ops)) {
+       if (aoa_snd_device_new(SNDRV_DEV_CODEC, toonie, &ops)) {
                printk(KERN_ERR PFX "failed to create toonie snd device!\n");
                return -ENODEV;
        }
index 0fa3855b4790e30753b7b8ea4fb29644a6e8cd1f..4a7e4e6b746fd3712cc596781346259814c2b6d4 100644 (file)
@@ -23,13 +23,12 @@ int aoa_alsa_init(char *name, struct module *mod, struct device *dev)
                /* cannot be EEXIST due to usage in aoa_fabric_register */
                return -EBUSY;
 
-       err = snd_card_create(index, name, mod, sizeof(struct aoa_card),
-                             &alsa_card);
+       err = snd_card_new(dev, index, name, mod, sizeof(struct aoa_card),
+                          &alsa_card);
        if (err < 0)
                return err;
        aoa_card = alsa_card->private_data;
        aoa_card->alsa_card = alsa_card;
-       alsa_card->dev = dev;
        strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver));
        strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname));
        strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname));
@@ -60,7 +59,7 @@ void aoa_alsa_cleanup(void)
        }
 }
 
-int aoa_snd_device_new(snd_device_type_t type,
+int aoa_snd_device_new(enum snd_device_type type,
                       void * device_data, struct snd_device_ops * ops)
 {
        struct snd_card *card = aoa_get_card();
index c421fdb3c7a12bf76a2584c21831913e57455ce9..0e83a73efb16e18dc4a5dc5982e86976dc9e2f2c 100644 (file)
@@ -899,8 +899,8 @@ static struct aaci *aaci_init_card(struct amba_device *dev)
        struct snd_card *card;
        int err;
 
-       err = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
-                             THIS_MODULE, sizeof(struct aaci), &card);
+       err = snd_card_new(&dev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+                          THIS_MODULE, sizeof(struct aaci), &card);
        if (err < 0)
                return NULL;
 
@@ -1055,8 +1055,6 @@ static int aaci_probe(struct amba_device *dev,
        if (ret)
                goto out;
 
-       snd_card_set_dev(aaci->card, &dev->dev);
-
        ret = snd_card_register(aaci->card);
        if (ret == 0) {
                dev_info(&dev->dev, "%s\n", aaci->card->longname);
index 9a2ac1e0f77addbe779e919c83cf61ad22368111..3a10df6688ee4d310d474c5babbbc6f89f9359c0 100644 (file)
@@ -179,12 +179,11 @@ static int pxa2xx_ac97_probe(struct platform_device *dev)
                goto err_dev;
        }
 
-       ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
-                             THIS_MODULE, 0, &card);
+       ret = snd_card_new(&dev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+                          THIS_MODULE, 0, &card);
        if (ret < 0)
                goto err;
 
-       card->dev = &dev->dev;
        strlcpy(card->driver, dev->dev.driver->name, sizeof(card->driver));
 
        ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm);
@@ -210,7 +209,6 @@ static int pxa2xx_ac97_probe(struct platform_device *dev)
 
        if (pdata && pdata->codec_pdata[0])
                snd_ac97_dev_add_pdata(ac97_bus->codec[0], pdata->codec_pdata[0]);
-       snd_card_set_dev(card, &dev->dev);
        ret = snd_card_register(card);
        if (ret == 0) {
                platform_set_drvdata(dev, card);
index 3519518e25a09612c71f1888bc097e9f088ca6ee..edf2ca72d518a3cef2058ffd7b66930bec154b01 100644 (file)
@@ -429,8 +429,9 @@ static int atmel_abdac_probe(struct platform_device *pdev)
        }
        clk_enable(pclk);
 
-       retval = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
-                       THIS_MODULE, sizeof(struct atmel_abdac), &card);
+       retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
+                             SNDRV_DEFAULT_STR1, THIS_MODULE,
+                             sizeof(struct atmel_abdac), &card);
        if (retval) {
                dev_dbg(&pdev->dev, "could not create sound card device\n");
                goto out_put_sample_clk;
@@ -467,8 +468,6 @@ static int atmel_abdac_probe(struct platform_device *pdev)
                goto out_unmap_regs;
        }
 
-       snd_card_set_dev(card, &pdev->dev);
-
        if (pdata->dws.dma_dev) {
                dma_cap_mask_t mask;
 
@@ -492,7 +491,7 @@ static int atmel_abdac_probe(struct platform_device *pdev)
        if (!pdata->dws.dma_dev || !dac->dma.chan) {
                dev_dbg(&pdev->dev, "DMA not available\n");
                retval = -ENODEV;
-               goto out_unset_card_dev;
+               goto out_unmap_regs;
        }
 
        strcpy(card->driver, "Atmel ABDAC");
@@ -521,9 +520,6 @@ static int atmel_abdac_probe(struct platform_device *pdev)
 out_release_dma:
        dma_release_channel(dac->dma.chan);
        dac->dma.chan = NULL;
-out_unset_card_dev:
-       snd_card_set_dev(card, NULL);
-       free_irq(irq, dac);
 out_unmap_regs:
        iounmap(dac->regs);
 out_free_card:
@@ -579,7 +575,6 @@ static int atmel_abdac_remove(struct platform_device *pdev)
 
        dma_release_channel(dac->dma.chan);
        dac->dma.chan = NULL;
-       snd_card_set_dev(card, NULL);
        iounmap(dac->regs);
        free_irq(dac->irq, dac);
        snd_card_free(card);
index c5f0ddd729b35a5ea0292b3c7a9347cb8aa04271..05ec049c9faf1edf799fd77f1ef606d18ee40c63 100644 (file)
@@ -945,8 +945,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
        }
        clk_enable(pclk);
 
-       retval = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
-                       THIS_MODULE, sizeof(struct atmel_ac97c), &card);
+       retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
+                             SNDRV_DEFAULT_STR1, THIS_MODULE,
+                             sizeof(struct atmel_ac97c), &card);
        if (retval) {
                dev_dbg(&pdev->dev, "could not create sound card device\n");
                goto err_snd_card_new;
@@ -990,8 +991,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
                chip->reset_pin = -EINVAL;
        }
 
-       snd_card_set_dev(card, &pdev->dev);
-
        atmel_ac97c_reset(chip);
 
        /* Enable overrun interrupt from codec channel */
@@ -1113,8 +1112,6 @@ err_dma:
                chip->dma.tx_chan = NULL;
        }
 err_ac97_bus:
-       snd_card_set_dev(card, NULL);
-
        if (gpio_is_valid(chip->reset_pin))
                gpio_free(chip->reset_pin);
 
@@ -1195,7 +1192,6 @@ static int atmel_ac97c_remove(struct platform_device *pdev)
                chip->dma.tx_chan = NULL;
        }
 
-       snd_card_set_dev(card, NULL);
        snd_card_free(card);
 
        return 0;
index d8aa206e8bdece19a337175ee1e4a9f83b8e8569..f038f5afafe2bfb596af4e4c7f4abec306dba443 100644 (file)
@@ -151,7 +151,7 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
        if (snd_BUG_ON(!card || !id))
                return;
        read_lock(&card->ctl_files_rwlock);
-#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
        card->mixer_oss_change_count++;
 #endif
        list_for_each_entry(ctl, &card->ctl_files, list) {
@@ -170,7 +170,7 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
                        ev->mask = mask;
                        list_add_tail(&ev->list, &ctl->events);
                } else {
-                       snd_printk(KERN_ERR "No memory available to allocate event\n");
+                       dev_err(card->dev, "No memory available to allocate event\n");
                }
        _found:
                wake_up(&ctl->change_sleep);
@@ -206,7 +206,7 @@ static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control,
 
        kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL);
        if (kctl == NULL) {
-               snd_printk(KERN_ERR "Cannot allocate control instance\n");
+               pr_err("ALSA: Cannot allocate control instance\n");
                return NULL;
        }
        *kctl = *control;
@@ -241,9 +241,8 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
        if (ncontrol->name) {
                strlcpy(kctl.id.name, ncontrol->name, sizeof(kctl.id.name));
                if (strcmp(ncontrol->name, kctl.id.name) != 0)
-                       snd_printk(KERN_WARNING
-                                  "Control name '%s' truncated to '%s'\n",
-                                  ncontrol->name, kctl.id.name);
+                       pr_warn("ALSA: Control name '%s' truncated to '%s'\n",
+                               ncontrol->name, kctl.id.name);
        }
        kctl.id.index = ncontrol->index;
        kctl.count = ncontrol->count ? ncontrol->count : 1;
@@ -306,7 +305,7 @@ static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
        while (snd_ctl_remove_numid_conflict(card, count)) {
                if (--iter == 0) {
                        /* this situation is very unlikely */
-                       snd_printk(KERN_ERR "unable to allocate new control numid\n");
+                       dev_err(card->dev, "unable to allocate new control numid\n");
                        return -ENOMEM;
                }
        }
@@ -341,7 +340,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
        down_write(&card->controls_rwsem);
        if (snd_ctl_find_id(card, &id)) {
                up_write(&card->controls_rwsem);
-               snd_printd(KERN_ERR "control %i:%i:%i:%s:%i is already present\n",
+               dev_err(card->dev, "control %i:%i:%i:%s:%i is already present\n",
                                        id.iface,
                                        id.device,
                                        id.subdevice,
@@ -1406,7 +1405,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
                }
        }
        up_read(&snd_ioctl_rwsem);
-       snd_printdd("unknown ioctl = 0x%x\n", cmd);
+       dev_dbg(card->dev, "unknown ioctl = 0x%x\n", cmd);
        return -ENOTTY;
 }
 
index 2bb95a7a8809fed3a042e8796b5431ce2afbee46..b9c0910fb8c4ead97559c7f9c1737e76b2d5cf7f 100644 (file)
@@ -247,7 +247,7 @@ static int copy_ctl_value_from_user(struct snd_card *card,
        } else {
                size = get_elem_size(type, count);
                if (size < 0) {
-                       printk(KERN_ERR "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
+                       dev_err(card->dev, "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
                        return -EINVAL;
                }
                if (copy_from_user(data->value.bytes.data,
index df88defed176a5592642ad6a91876add70c5f22a..41bec3075ae5b829c6f032520da7062c6214f662 100644 (file)
  *
  * Return: Zero if successful, or a negative error code on failure.
  */
-int snd_device_new(struct snd_card *card, snd_device_type_t type,
+int snd_device_new(struct snd_card *card, enum snd_device_type type,
                   void *device_data, struct snd_device_ops *ops)
 {
        struct snd_device *dev;
+       struct list_head *p;
 
        if (snd_BUG_ON(!card || !device_data || !ops))
                return -ENXIO;
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (dev == NULL) {
-               snd_printk(KERN_ERR "Cannot allocate device\n");
+               dev_err(card->dev, "Cannot allocate device, type=%d\n", type);
                return -ENOMEM;
        }
+       INIT_LIST_HEAD(&dev->list);
        dev->card = card;
        dev->type = type;
        dev->state = SNDRV_DEV_BUILD;
        dev->device_data = device_data;
        dev->ops = ops;
-       list_add(&dev->list, &card->devices);   /* add to the head of list */
+
+       /* insert the entry in an incrementally sorted list */
+       list_for_each_prev(p, &card->devices) {
+               struct snd_device *pdev = list_entry(p, struct snd_device, list);
+               if ((unsigned int)pdev->type <= (unsigned int)type)
+                       break;
+       }
+
+       list_add(&dev->list, p);
        return 0;
 }
-
 EXPORT_SYMBOL(snd_device_new);
 
+static int __snd_device_disconnect(struct snd_device *dev)
+{
+       if (dev->state == SNDRV_DEV_REGISTERED) {
+               if (dev->ops->dev_disconnect &&
+                   dev->ops->dev_disconnect(dev))
+                       dev_err(dev->card->dev, "device disconnect failure\n");
+               dev->state = SNDRV_DEV_DISCONNECTED;
+       }
+       return 0;
+}
+
+static void __snd_device_free(struct snd_device *dev)
+{
+       /* unlink */
+       list_del(&dev->list);
+
+       __snd_device_disconnect(dev);
+       if (dev->ops->dev_free) {
+               if (dev->ops->dev_free(dev))
+                       dev_err(dev->card->dev, "device free failure\n");
+       }
+       kfree(dev);
+}
+
+static struct snd_device *look_for_dev(struct snd_card *card, void *device_data)
+{
+       struct snd_device *dev;
+
+       list_for_each_entry(dev, &card->devices, list)
+               if (dev->device_data == device_data)
+                       return dev;
+
+       return NULL;
+}
+
 /**
  * snd_device_free - release the device from the card
  * @card: the card instance
@@ -72,73 +116,33 @@ EXPORT_SYMBOL(snd_device_new);
  * Removes the device from the list on the card and invokes the
  * callbacks, dev_disconnect and dev_free, corresponding to the state.
  * Then release the device.
- *
- * Return: Zero if successful, or a negative error code on failure or if the
- * device not found.
  */
-int snd_device_free(struct snd_card *card, void *device_data)
+void snd_device_free(struct snd_card *card, void *device_data)
 {
        struct snd_device *dev;
        
        if (snd_BUG_ON(!card || !device_data))
-               return -ENXIO;
-       list_for_each_entry(dev, &card->devices, list) {
-               if (dev->device_data != device_data)
-                       continue;
-               /* unlink */
-               list_del(&dev->list);
-               if (dev->state == SNDRV_DEV_REGISTERED &&
-                   dev->ops->dev_disconnect)
-                       if (dev->ops->dev_disconnect(dev))
-                               snd_printk(KERN_ERR
-                                          "device disconnect failure\n");
-               if (dev->ops->dev_free) {
-                       if (dev->ops->dev_free(dev))
-                               snd_printk(KERN_ERR "device free failure\n");
-               }
-               kfree(dev);
-               return 0;
-       }
-       snd_printd("device free %p (from %pF), not found\n", device_data,
-                  __builtin_return_address(0));
-       return -ENXIO;
+               return;
+       dev = look_for_dev(card, device_data);
+       if (dev)
+               __snd_device_free(dev);
+       else
+               dev_dbg(card->dev, "device free %p (from %pF), not found\n",
+                       device_data, __builtin_return_address(0));
 }
-
 EXPORT_SYMBOL(snd_device_free);
 
-/**
- * snd_device_disconnect - disconnect the device
- * @card: the card instance
- * @device_data: the data pointer to disconnect
- *
- * Turns the device into the disconnection state, invoking
- * dev_disconnect callback, if the device was already registered.
- *
- * Usually called from snd_card_disconnect().
- *
- * Return: Zero if successful, or a negative error code on failure or if the
- * device not found.
- */
-int snd_device_disconnect(struct snd_card *card, void *device_data)
+static int __snd_device_register(struct snd_device *dev)
 {
-       struct snd_device *dev;
-
-       if (snd_BUG_ON(!card || !device_data))
-               return -ENXIO;
-       list_for_each_entry(dev, &card->devices, list) {
-               if (dev->device_data != device_data)
-                       continue;
-               if (dev->state == SNDRV_DEV_REGISTERED &&
-                   dev->ops->dev_disconnect) {
-                       if (dev->ops->dev_disconnect(dev))
-                               snd_printk(KERN_ERR "device disconnect failure\n");
-                       dev->state = SNDRV_DEV_DISCONNECTED;
+       if (dev->state == SNDRV_DEV_BUILD) {
+               if (dev->ops->dev_register) {
+                       int err = dev->ops->dev_register(dev);
+                       if (err < 0)
+                               return err;
                }
-               return 0;
+               dev->state = SNDRV_DEV_REGISTERED;
        }
-       snd_printd("device disconnect %p (from %pF), not found\n", device_data,
-                  __builtin_return_address(0));
-       return -ENXIO;
+       return 0;
 }
 
 /**
@@ -157,26 +161,15 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
 int snd_device_register(struct snd_card *card, void *device_data)
 {
        struct snd_device *dev;
-       int err;
 
        if (snd_BUG_ON(!card || !device_data))
                return -ENXIO;
-       list_for_each_entry(dev, &card->devices, list) {
-               if (dev->device_data != device_data)
-                       continue;
-               if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
-                       if ((err = dev->ops->dev_register(dev)) < 0)
-                               return err;
-                       dev->state = SNDRV_DEV_REGISTERED;
-                       return 0;
-               }
-               snd_printd("snd_device_register busy\n");
-               return -EBUSY;
-       }
+       dev = look_for_dev(card, device_data);
+       if (dev)
+               return __snd_device_register(dev);
        snd_BUG();
        return -ENXIO;
 }
-
 EXPORT_SYMBOL(snd_device_register);
 
 /*
@@ -191,11 +184,9 @@ int snd_device_register_all(struct snd_card *card)
        if (snd_BUG_ON(!card))
                return -ENXIO;
        list_for_each_entry(dev, &card->devices, list) {
-               if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
-                       if ((err = dev->ops->dev_register(dev)) < 0)
-                               return err;
-                       dev->state = SNDRV_DEV_REGISTERED;
-               }
+               err = __snd_device_register(dev);
+               if (err < 0)
+                       return err;
        }
        return 0;
 }
@@ -211,8 +202,8 @@ int snd_device_disconnect_all(struct snd_card *card)
 
        if (snd_BUG_ON(!card))
                return -ENXIO;
-       list_for_each_entry(dev, &card->devices, list) {
-               if (snd_device_disconnect(card, dev->device_data) < 0)
+       list_for_each_entry_reverse(dev, &card->devices, list) {
+               if (__snd_device_disconnect(dev) < 0)
                        err = -ENXIO;
        }
        return err;
@@ -222,24 +213,12 @@ int snd_device_disconnect_all(struct snd_card *card)
  * release all the devices on the card.
  * called from init.c
  */
-int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
+void snd_device_free_all(struct snd_card *card)
 {
-       struct snd_device *dev;
-       int err;
-       unsigned int range_low, range_high, type;
+       struct snd_device *dev, *next;
 
        if (snd_BUG_ON(!card))
-               return -ENXIO;
-       range_low = (__force unsigned int)cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
-       range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
-      __again:
-       list_for_each_entry(dev, &card->devices, list) {
-               type = (__force unsigned int)dev->type;
-               if (type >= range_low && type <= range_high) {
-                       if ((err = snd_device_free(card, dev->device_data)) < 0)
-                               return err;
-                       goto __again;
-               }
-       }
-       return 0;
+               return;
+       list_for_each_entry_safe_reverse(dev, next, &card->devices, list)
+               __snd_device_free(dev);
 }
index b8b31c433d640279b9f4e13a9b46ca90d9a6452d..886be7da989d1ab52d647105ef3648a8045facbe 100644 (file)
@@ -126,8 +126,7 @@ static int __init snd_hrtimer_init(void)
 
        hrtimer_get_res(CLOCK_MONOTONIC, &tp);
        if (tp.tv_sec > 0 || !tp.tv_nsec) {
-               snd_printk(KERN_ERR
-                          "snd-hrtimer: Invalid resolution %u.%09u",
+               pr_err("snd-hrtimer: Invalid resolution %u.%09u",
                           (unsigned)tp.tv_sec, (unsigned)tp.tv_nsec);
                return -EINVAL;
        }
index d105073298cb536148214fd04edb318220825e13..69459e5f712e9e50c51f5d3aedb360616afe5c1b 100644 (file)
@@ -375,7 +375,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,
                *rhwdep = NULL;
        hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL);
        if (hwdep == NULL) {
-               snd_printk(KERN_ERR "hwdep: cannot allocate\n");
+               dev_err(card->dev, "hwdep: cannot allocate\n");
                return -ENOMEM;
        }
        hwdep->card = card;
@@ -395,6 +395,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,
                *rhwdep = hwdep;
        return 0;
 }
+EXPORT_SYMBOL(snd_hwdep_new);
 
 static int snd_hwdep_free(struct snd_hwdep *hwdep)
 {
@@ -415,37 +416,61 @@ static int snd_hwdep_dev_free(struct snd_device *device)
 static int snd_hwdep_dev_register(struct snd_device *device)
 {
        struct snd_hwdep *hwdep = device->device_data;
+       struct snd_card *card = hwdep->card;
+       struct device *dev;
        int err;
        char name[32];
 
        mutex_lock(&register_mutex);
-       if (snd_hwdep_search(hwdep->card, hwdep->device)) {
+       if (snd_hwdep_search(card, hwdep->device)) {
                mutex_unlock(&register_mutex);
                return -EBUSY;
        }
        list_add_tail(&hwdep->list, &snd_hwdep_devices);
        sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device);
-       if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
-                                      hwdep->card, hwdep->device,
-                                      &snd_hwdep_f_ops, hwdep, name)) < 0) {
-               snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
-                          hwdep->card->number, hwdep->device);
+       dev = hwdep->dev;
+       if (!dev)
+               dev = snd_card_get_device_link(hwdep->card);
+       err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP,
+                                         hwdep->card, hwdep->device,
+                                         &snd_hwdep_f_ops, hwdep, name, dev);
+       if (err < 0) {
+               dev_err(dev,
+                       "unable to register hardware dependent device %i:%i\n",
+                       card->number, hwdep->device);
                list_del(&hwdep->list);
                mutex_unlock(&register_mutex);
                return err;
        }
+
+       if (hwdep->groups) {
+               struct device *d = snd_get_device(SNDRV_DEVICE_TYPE_HWDEP,
+                                                 hwdep->card, hwdep->device);
+               if (d) {
+                       if (hwdep->private_data)
+                               dev_set_drvdata(d, hwdep->private_data);
+                       err = sysfs_create_groups(&d->kobj, hwdep->groups);
+                       if (err < 0)
+                               dev_warn(dev,
+                                        "hwdep %d:%d: cannot create sysfs groups\n",
+                                        card->number, hwdep->device);
+                       put_device(d);
+               }
+       }
+
 #ifdef CONFIG_SND_OSSEMUL
        hwdep->ossreg = 0;
        if (hwdep->oss_type >= 0) {
                if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->device != 0)) {
-                       snd_printk (KERN_WARNING "only hwdep device 0 can be registered as OSS direct FM device!\n");
+                       dev_warn(dev,
+                                "only hwdep device 0 can be registered as OSS direct FM device!\n");
                } else {
                        if (snd_register_oss_device(hwdep->oss_type,
-                                                   hwdep->card, hwdep->device,
-                                                   &snd_hwdep_f_ops, hwdep,
-                                                   hwdep->oss_dev) < 0) {
-                               snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n",
-                                          hwdep->card->number, hwdep->device);
+                                                   card, hwdep->device,
+                                                   &snd_hwdep_f_ops, hwdep) < 0) {
+                               dev_err(dev,
+                                       "unable to register OSS compatibility device %i:%i\n",
+                                       card->number, hwdep->device);
                        } else
                                hwdep->ossreg = 1;
                }
@@ -543,5 +568,3 @@ static void __exit alsa_hwdep_exit(void)
 
 module_init(alsa_hwdep_init)
 module_exit(alsa_hwdep_exit)
-
-EXPORT_SYMBOL(snd_hwdep_new);
index e79baa11b60eb15526ba3679537720b2f29d0de6..051d55b05521216d31a1d011d58560744e930672 100644 (file)
@@ -418,9 +418,14 @@ static int snd_info_entry_release(struct inode *inode, struct file *file)
                        if (entry->c.text.write) {
                                entry->c.text.write(entry, data->wbuffer);
                                if (data->wbuffer->error) {
-                                       snd_printk(KERN_WARNING "data write error to %s (%i)\n",
-                                               entry->name,
-                                               data->wbuffer->error);
+                                       if (entry->card)
+                                               dev_warn(entry->card->dev, "info: data write error to %s (%i)\n",
+                                                        entry->name,
+                                                        data->wbuffer->error);
+                                       else
+                                               pr_warn("ALSA: info: data write error to %s (%i)\n",
+                                                       entry->name,
+                                                       data->wbuffer->error);
                                }
                        }
                        kfree(data->wbuffer->buffer);
@@ -540,7 +545,7 @@ int __init snd_info_init(void)
                snd_oss_root = entry;
        }
 #endif
-#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
+#if IS_ENABLED(CONFIG_SND_SEQUENCER)
        {
                struct snd_info_entry *entry;
                if ((entry = snd_info_create_module_entry(THIS_MODULE, "seq", NULL)) == NULL)
@@ -567,7 +572,7 @@ int __exit snd_info_done(void)
        snd_minor_info_done();
        snd_info_version_done();
        if (snd_proc_root) {
-#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
+#if IS_ENABLED(CONFIG_SND_SEQUENCER)
                snd_info_free_entry(snd_seq_root);
 #endif
 #ifdef CONFIG_SND_OSSEMUL
index 0d42fcda0de2805235ea7fd3a685633050132f23..5ee83845c5de578aa2f9fc70684f95061679197a 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/time.h>
 #include <linux/ctype.h>
 #include <linux/pm.h>
+#include <linux/completion.h>
 
 #include <sound/core.h>
 #include <sound/control.h>
@@ -94,7 +95,7 @@ static int module_slot_match(struct module *module, int idx)
        return match;
 }
 
-#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
 int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
 EXPORT_SYMBOL(snd_mixer_oss_notify_callback);
 #endif
@@ -112,11 +113,11 @@ static inline int init_info_for_card(struct snd_card *card)
        struct snd_info_entry *entry;
 
        if ((err = snd_info_card_register(card)) < 0) {
-               snd_printd("unable to create card info\n");
+               dev_dbg(card->dev, "unable to create card info\n");
                return err;
        }
        if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) {
-               snd_printd("unable to create card entry\n");
+               dev_dbg(card->dev, "unable to create card entry\n");
                return err;
        }
        entry->c.text.read = snd_card_id_read;
@@ -156,8 +157,17 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int),
        return mask; /* unchanged */
 }
 
+static int snd_card_do_free(struct snd_card *card);
+static const struct attribute_group *card_dev_attr_groups[];
+
+static void release_card_device(struct device *dev)
+{
+       snd_card_do_free(dev_to_snd_card(dev));
+}
+
 /**
- *  snd_card_create - create and initialize a soundcard structure
+ *  snd_card_new - create and initialize a soundcard structure
+ *  @parent: the parent device object
  *  @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
  *  @xid: card identification (ASCII string)
  *  @module: top level module for locking
@@ -172,7 +182,7 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int),
  *
  *  Return: Zero if successful or a negative error code.
  */
-int snd_card_create(int idx, const char *xid,
+int snd_card_new(struct device *parent, int idx, const char *xid,
                    struct module *module, int extra_size,
                    struct snd_card **card_ret)
 {
@@ -188,6 +198,8 @@ int snd_card_create(int idx, const char *xid,
        card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL);
        if (!card)
                return -ENOMEM;
+       if (extra_size > 0)
+               card->private_data = (char *)card + sizeof(struct snd_card);
        if (xid)
                strlcpy(card->id, xid, sizeof(card->id));
        err = 0;
@@ -205,14 +217,16 @@ int snd_card_create(int idx, const char *xid,
                err = -ENODEV;
        if (err < 0) {
                mutex_unlock(&snd_card_mutex);
-               snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i), error: %d\n",
+               dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n",
                         idx, snd_ecards_limit - 1, err);
-               goto __error;
+               kfree(card);
+               return err;
        }
        set_bit(idx, snd_cards_lock);           /* lock it */
        if (idx >= snd_ecards_limit)
                snd_ecards_limit = idx + 1; /* increase the limit */
        mutex_unlock(&snd_card_mutex);
+       card->dev = parent;
        card->number = idx;
        card->module = module;
        INIT_LIST_HEAD(&card->devices);
@@ -222,36 +236,42 @@ int snd_card_create(int idx, const char *xid,
        INIT_LIST_HEAD(&card->ctl_files);
        spin_lock_init(&card->files_lock);
        INIT_LIST_HEAD(&card->files_list);
-       init_waitqueue_head(&card->shutdown_sleep);
-       atomic_set(&card->refcount, 0);
 #ifdef CONFIG_PM
        mutex_init(&card->power_lock);
        init_waitqueue_head(&card->power_sleep);
 #endif
+
+       device_initialize(&card->card_dev);
+       card->card_dev.parent = parent;
+       card->card_dev.class = sound_class;
+       card->card_dev.release = release_card_device;
+       card->card_dev.groups = card_dev_attr_groups;
+       err = kobject_set_name(&card->card_dev.kobj, "card%d", idx);
+       if (err < 0)
+               goto __error;
+
        /* the control interface cannot be accessed from the user space until */
        /* snd_cards_bitmask and snd_cards are set with snd_card_register */
        err = snd_ctl_create(card);
        if (err < 0) {
-               snd_printk(KERN_ERR "unable to register control minors\n");
+               dev_err(parent, "unable to register control minors\n");
                goto __error;
        }
        err = snd_info_card_create(card);
        if (err < 0) {
-               snd_printk(KERN_ERR "unable to create card info\n");
+               dev_err(parent, "unable to create card info\n");
                goto __error_ctl;
        }
-       if (extra_size > 0)
-               card->private_data = (char *)card + sizeof(struct snd_card);
        *card_ret = card;
        return 0;
 
       __error_ctl:
-       snd_device_free_all(card, SNDRV_DEV_CMD_PRE);
+       snd_device_free_all(card);
       __error:
-       kfree(card);
+       put_device(&card->card_dev);
        return err;
 }
-EXPORT_SYMBOL(snd_card_create);
+EXPORT_SYMBOL(snd_card_new);
 
 /* return non-zero if a card is already locked */
 int snd_card_locked(int card)
@@ -394,7 +414,7 @@ int snd_card_disconnect(struct snd_card *card)
        /* phase 3: notify all connected devices about disconnection */
        /* at this point, they cannot respond to any calls except release() */
 
-#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
        if (snd_mixer_oss_notify_callback)
                snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_DISCONNECT);
 #endif
@@ -402,12 +422,12 @@ int snd_card_disconnect(struct snd_card *card)
        /* notify all devices that we are disconnected */
        err = snd_device_disconnect_all(card);
        if (err < 0)
-               snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number);
+               dev_err(card->dev, "not all devices for card %i can be disconnected\n", card->number);
 
        snd_info_card_disconnect(card);
-       if (card->card_dev) {
-               device_unregister(card->card_dev);
-               card->card_dev = NULL;
+       if (card->registered) {
+               device_del(&card->card_dev);
+               card->registered = false;
        }
 #ifdef CONFIG_PM
        wake_up(&card->power_sleep);
@@ -430,81 +450,48 @@ EXPORT_SYMBOL(snd_card_disconnect);
  */
 static int snd_card_do_free(struct snd_card *card)
 {
-#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
        if (snd_mixer_oss_notify_callback)
                snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE);
 #endif
-       if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) {
-               snd_printk(KERN_ERR "unable to free all devices (pre)\n");
-               /* Fatal, but this situation should never occur */
-       }
-       if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) {
-               snd_printk(KERN_ERR "unable to free all devices (normal)\n");
-               /* Fatal, but this situation should never occur */
-       }
-       if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) {
-               snd_printk(KERN_ERR "unable to free all devices (post)\n");
-               /* Fatal, but this situation should never occur */
-       }
+       snd_device_free_all(card);
        if (card->private_free)
                card->private_free(card);
        snd_info_free_entry(card->proc_id);
        if (snd_info_card_free(card) < 0) {
-               snd_printk(KERN_WARNING "unable to free card info\n");
+               dev_warn(card->dev, "unable to free card info\n");
                /* Not fatal error */
        }
+       if (card->release_completion)
+               complete(card->release_completion);
        kfree(card);
        return 0;
 }
 
-/**
- * snd_card_unref - release the reference counter
- * @card: the card instance
- *
- * Decrements the reference counter.  When it reaches to zero, wake up
- * the sleeper and call the destructor if needed.
- */
-void snd_card_unref(struct snd_card *card)
-{
-       if (atomic_dec_and_test(&card->refcount)) {
-               wake_up(&card->shutdown_sleep);
-               if (card->free_on_last_close)
-                       snd_card_do_free(card);
-       }
-}
-EXPORT_SYMBOL(snd_card_unref);
-
 int snd_card_free_when_closed(struct snd_card *card)
 {
-       int ret;
-
-       atomic_inc(&card->refcount);
-       ret = snd_card_disconnect(card);
-       if (ret) {
-               atomic_dec(&card->refcount);
+       int ret = snd_card_disconnect(card);
+       if (ret)
                return ret;
-       }
-
-       card->free_on_last_close = 1;
-       if (atomic_dec_and_test(&card->refcount))
-               snd_card_do_free(card);
+       put_device(&card->card_dev);
        return 0;
 }
-
 EXPORT_SYMBOL(snd_card_free_when_closed);
 
 int snd_card_free(struct snd_card *card)
 {
-       int ret = snd_card_disconnect(card);
+       struct completion released;
+       int ret;
+
+       init_completion(&released);
+       card->release_completion = &released;
+       ret = snd_card_free_when_closed(card);
        if (ret)
                return ret;
-
        /* wait, until all devices are ready for the free operation */
-       wait_event(card->shutdown_sleep, !atomic_read(&card->refcount));
-       snd_card_do_free(card);
+       wait_for_completion(&released);
        return 0;
 }
-
 EXPORT_SYMBOL(snd_card_free);
 
 /* retrieve the last word of shortname or longname */
@@ -598,7 +585,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src,
                goto again;
        }
        /* last resort... */
-       snd_printk(KERN_ERR "unable to set card id (%s)\n", id);
+       dev_err(card->dev, "unable to set card id (%s)\n", id);
        if (card->proc_root->name)
                strlcpy(card->id, card->proc_root->name, sizeof(card->id));
 }
@@ -626,15 +613,15 @@ static ssize_t
 card_id_show_attr(struct device *dev,
                  struct device_attribute *attr, char *buf)
 {
-       struct snd_card *card = dev_get_drvdata(dev);
-       return snprintf(buf, PAGE_SIZE, "%s\n", card ? card->id : "(null)");
+       struct snd_card *card = container_of(dev, struct snd_card, card_dev);
+       return snprintf(buf, PAGE_SIZE, "%s\n", card->id);
 }
 
 static ssize_t
 card_id_store_attr(struct device *dev, struct device_attribute *attr,
                   const char *buf, size_t count)
 {
-       struct snd_card *card = dev_get_drvdata(dev);
+       struct snd_card *card = container_of(dev, struct snd_card, card_dev);
        char buf1[sizeof(card->id)];
        size_t copy = count > sizeof(card->id) - 1 ?
                                        sizeof(card->id) - 1 : count;
@@ -660,19 +647,32 @@ card_id_store_attr(struct device *dev, struct device_attribute *attr,
        return count;
 }
 
-static struct device_attribute card_id_attrs =
-       __ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr);
+static DEVICE_ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr);
 
 static ssize_t
 card_number_show_attr(struct device *dev,
                     struct device_attribute *attr, char *buf)
 {
-       struct snd_card *card = dev_get_drvdata(dev);
-       return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1);
+       struct snd_card *card = container_of(dev, struct snd_card, card_dev);
+       return snprintf(buf, PAGE_SIZE, "%i\n", card->number);
 }
 
-static struct device_attribute card_number_attrs =
-       __ATTR(number, S_IRUGO, card_number_show_attr, NULL);
+static DEVICE_ATTR(number, S_IRUGO, card_number_show_attr, NULL);
+
+static struct attribute *card_dev_attrs[] = {
+       &dev_attr_id.attr,
+       &dev_attr_number.attr,
+       NULL
+};
+
+static struct attribute_group card_dev_attr_group = {
+       .attrs  = card_dev_attrs,
+};
+
+static const struct attribute_group *card_dev_attr_groups[] = {
+       &card_dev_attr_group,
+       NULL
+};
 
 /**
  *  snd_card_register - register the soundcard
@@ -692,12 +692,11 @@ int snd_card_register(struct snd_card *card)
        if (snd_BUG_ON(!card))
                return -EINVAL;
 
-       if (!card->card_dev) {
-               card->card_dev = device_create(sound_class, card->dev,
-                                              MKDEV(0, 0), card,
-                                              "card%i", card->number);
-               if (IS_ERR(card->card_dev))
-                       card->card_dev = NULL;
+       if (!card->registered) {
+               err = device_add(&card->card_dev);
+               if (err < 0)
+                       return err;
+               card->registered = true;
        }
 
        if ((err = snd_device_register_all(card)) < 0)
@@ -723,19 +722,10 @@ int snd_card_register(struct snd_card *card)
        snd_cards[card->number] = card;
        mutex_unlock(&snd_card_mutex);
        init_info_for_card(card);
-#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
        if (snd_mixer_oss_notify_callback)
                snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
 #endif
-       if (card->card_dev) {
-               err = device_create_file(card->card_dev, &card_id_attrs);
-               if (err < 0)
-                       return err;
-               err = device_create_file(card->card_dev, &card_number_attrs);
-               if (err < 0)
-                       return err;
-       }
-
        return 0;
 }
 
@@ -908,7 +898,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file)
                return -ENODEV;
        }
        list_add(&mfile->list, &card->files_list);
-       atomic_inc(&card->refcount);
+       get_device(&card->card_dev);
        spin_unlock(&card->files_lock);
        return 0;
 }
@@ -947,11 +937,11 @@ int snd_card_file_remove(struct snd_card *card, struct file *file)
        }
        spin_unlock(&card->files_lock);
        if (!found) {
-               snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file);
+               dev_err(card->dev, "card file remove problem (%p)\n", file);
                return -ENOENT;
        }
        kfree(found);
-       snd_card_unref(card);
+       put_device(&card->card_dev);
        return 0;
 }
 
index e2b386156a4c300ed0f78b50fa1bebc71d54689a..31e8544d7f2d760320d9db504cafa398d70bda49 100644 (file)
@@ -106,7 +106,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
                result = result1;
 #ifdef CONFIG_SND_DEBUG
        if (result > size)
-               snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
+               pr_err("ALSA: pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
 #endif
        if (result >= size || result == 0)
                return 0;
index 4595f93d151e0e5fb82073a788ebe6a725826296..082509eb805d5395ed356ef0e9378432f891b96e 100644 (file)
@@ -207,7 +207,7 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
                break;
 #endif
        default:
-               printk(KERN_ERR "snd-malloc: invalid device type %d\n", type);
+               pr_err("snd-malloc: invalid device type %d\n", type);
                dmab->area = NULL;
                dmab->addr = 0;
                return -ENXIO;
@@ -284,7 +284,7 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
                break;
 #endif
        default:
-               printk(KERN_ERR "snd-malloc: invalid device type %d\n", dmab->dev.type);
+               pr_err("snd-malloc: invalid device type %d\n", dmab->dev.type);
        }
 }
 
index e8a1d18774b2073f997746f6d6f16881a1ecc4bc..5e6349f00ecd770a3c572ef950454ec04f13e1c8 100644 (file)
@@ -1187,7 +1187,8 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
                        if (oss_mixer_names[ch] && strcmp(oss_mixer_names[ch], str) == 0)
                                break;
                if (ch >= SNDRV_OSS_MAX_MIXERS) {
-                       snd_printk(KERN_ERR "mixer_oss: invalid OSS volume '%s'\n", str);
+                       pr_err("ALSA: mixer_oss: invalid OSS volume '%s'\n",
+                              str);
                        continue;
                }
                cptr = snd_info_get_str(str, cptr, sizeof(str));
@@ -1201,7 +1202,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
                snd_info_get_str(idxstr, cptr, sizeof(idxstr));
                idx = simple_strtoul(idxstr, NULL, 10);
                if (idx >= 0x4000) { /* too big */
-                       snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx);
+                       pr_err("ALSA: mixer_oss: invalid index %d\n", idx);
                        continue;
                }
                mutex_lock(&mixer->reg_mutex);
@@ -1212,7 +1213,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
                        goto __unlock;
                tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
                if (! tbl) {
-                       snd_printk(KERN_ERR "mixer_oss: no memory\n");
+                       pr_err("ALSA: mixer_oss: no memory\n");
                        goto __unlock;
                }
                tbl->oss_id = ch;
@@ -1343,20 +1344,18 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
        struct snd_mixer_oss *mixer;
 
        if (cmd == SND_MIXER_OSS_NOTIFY_REGISTER) {
-               char name[128];
                int idx, err;
 
                mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL);
                if (mixer == NULL)
                        return -ENOMEM;
                mutex_init(&mixer->reg_mutex);
-               sprintf(name, "mixer%i%i", card->number, 0);
                if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
                                                   card, 0,
-                                                  &snd_mixer_oss_f_ops, card,
-                                                  name)) < 0) {
-                       snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n",
-                                  card->number, 0);
+                                                  &snd_mixer_oss_f_ops, card)) < 0) {
+                       dev_err(card->dev,
+                               "unable to register OSS mixer device %i:%i\n",
+                               card->number, 0);
                        kfree(mixer);
                        return err;
                }
@@ -1365,7 +1364,8 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
                if (*card->mixername)
                        strlcpy(mixer->name, card->mixername, sizeof(mixer->name));
                else
-                       strlcpy(mixer->name, name, sizeof(mixer->name));
+                       snprintf(mixer->name, sizeof(mixer->name),
+                                "mixer%i", card->number);
 #ifdef SNDRV_OSS_INFO_DEV_MIXERS
                snd_oss_info_register(SNDRV_OSS_INFO_DEV_MIXERS,
                                      card->number,
index 4c1cc51772e6f18e9ab03671069c738471ca8c04..ada69d7a8d70a077c18abfa2aa7bf26ee8125b27 100644 (file)
@@ -854,7 +854,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
        params = kmalloc(sizeof(*params), GFP_KERNEL);
        sparams = kmalloc(sizeof(*sparams), GFP_KERNEL);
        if (!sw_params || !params || !sparams) {
-               snd_printd("No memory\n");
+               pcm_dbg(substream->pcm, "No memory\n");
                err = -ENOMEM;
                goto failure;
        }
@@ -877,7 +877,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
        }
        err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask);
        if (err < 0) {
-               snd_printd("No usable accesses\n");
+               pcm_dbg(substream->pcm, "No usable accesses\n");
                err = -EINVAL;
                goto failure;
        }
@@ -902,7 +902,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
                                break;
                }
                if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
-                       snd_printd("Cannot find a format!!!\n");
+                       pcm_dbg(substream->pcm, "Cannot find a format!!!\n");
                        err = -EINVAL;
                        goto failure;
                }
@@ -942,14 +942,16 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
                if ((err = snd_pcm_plug_format_plugins(substream,
                                                       params, 
                                                       sparams)) < 0) {
-                       snd_printd("snd_pcm_plug_format_plugins failed: %i\n", err);
+                       pcm_dbg(substream->pcm,
+                               "snd_pcm_plug_format_plugins failed: %i\n", err);
                        snd_pcm_oss_plugin_clear(substream);
                        goto failure;
                }
                if (runtime->oss.plugin_first) {
                        struct snd_pcm_plugin *plugin;
                        if ((err = snd_pcm_plugin_build_io(substream, sparams, &plugin)) < 0) {
-                               snd_printd("snd_pcm_plugin_build_io failed: %i\n", err);
+                               pcm_dbg(substream->pcm,
+                                       "snd_pcm_plugin_build_io failed: %i\n", err);
                                snd_pcm_oss_plugin_clear(substream);
                                goto failure;
                        }
@@ -983,7 +985,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
        snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
 
        if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams)) < 0) {
-               snd_printd("HW_PARAMS failed: %i\n", err);
+               pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err);
                goto failure;
        }
 
@@ -1016,7 +1018,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
        }
 
        if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params)) < 0) {
-               snd_printd("SW_PARAMS failed: %i\n", err);
+               pcm_dbg(substream->pcm, "SW_PARAMS failed: %i\n", err);
                goto failure;
        }
 
@@ -1110,7 +1112,8 @@ static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream)
 
        err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL);
        if (err < 0) {
-               snd_printd("snd_pcm_oss_prepare: SNDRV_PCM_IOCTL_PREPARE failed\n");
+               pcm_dbg(substream->pcm,
+                       "snd_pcm_oss_prepare: SNDRV_PCM_IOCTL_PREPARE failed\n");
                return err;
        }
        runtime->oss.prepare = 0;
@@ -1175,12 +1178,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
                if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
 #ifdef OSS_DEBUG
-                       if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
-                               printk(KERN_DEBUG "pcm_oss: write: "
-                                      "recovering from XRUN\n");
-                       else
-                               printk(KERN_DEBUG "pcm_oss: write: "
-                                      "recovering from SUSPEND\n");
+                       pcm_dbg(substream->pcm,
+                               "pcm_oss: write: recovering from %s\n",
+                               runtime->status->state == SNDRV_PCM_STATE_XRUN ?
+                               "XRUN" : "SUSPEND");
 #endif
                        ret = snd_pcm_oss_prepare(substream);
                        if (ret < 0)
@@ -1213,12 +1214,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
                if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
 #ifdef OSS_DEBUG
-                       if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
-                               printk(KERN_DEBUG "pcm_oss: read: "
-                                      "recovering from XRUN\n");
-                       else
-                               printk(KERN_DEBUG "pcm_oss: read: "
-                                      "recovering from SUSPEND\n");
+                       pcm_dbg(substream->pcm,
+                               "pcm_oss: read: recovering from %s\n",
+                               runtime->status->state == SNDRV_PCM_STATE_XRUN ?
+                               "XRUN" : "SUSPEND");
 #endif
                        ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
                        if (ret < 0)
@@ -1261,12 +1260,10 @@ snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void
                if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
 #ifdef OSS_DEBUG
-                       if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
-                               printk(KERN_DEBUG "pcm_oss: writev: "
-                                      "recovering from XRUN\n");
-                       else
-                               printk(KERN_DEBUG "pcm_oss: writev: "
-                                      "recovering from SUSPEND\n");
+                       pcm_dbg(substream->pcm,
+                               "pcm_oss: writev: recovering from %s\n",
+                               runtime->status->state == SNDRV_PCM_STATE_XRUN ?
+                               "XRUN" : "SUSPEND");
 #endif
                        ret = snd_pcm_oss_prepare(substream);
                        if (ret < 0)
@@ -1299,12 +1296,10 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void *
                if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
 #ifdef OSS_DEBUG
-                       if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
-                               printk(KERN_DEBUG "pcm_oss: readv: "
-                                      "recovering from XRUN\n");
-                       else
-                               printk(KERN_DEBUG "pcm_oss: readv: "
-                                      "recovering from SUSPEND\n");
+                       pcm_dbg(substream->pcm,
+                               "pcm_oss: readv: recovering from %s\n",
+                               runtime->status->state == SNDRV_PCM_STATE_XRUN ?
+                               "XRUN" : "SUSPEND");
 #endif
                        ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
                        if (ret < 0)
@@ -1561,7 +1556,7 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
        init_waitqueue_entry(&wait, current);
        add_wait_queue(&runtime->sleep, &wait);
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "sync1: size = %li\n", size);
+       pcm_dbg(substream->pcm, "sync1: size = %li\n", size);
 #endif
        while (1) {
                result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1);
@@ -1587,7 +1582,8 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
                        break;
                }
                if (res == 0) {
-                       snd_printk(KERN_ERR "OSS sync error - DMA timeout\n");
+                       pcm_err(substream->pcm,
+                               "OSS sync error - DMA timeout\n");
                        result = -EIO;
                        break;
                }
@@ -1618,7 +1614,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
                mutex_lock(&runtime->oss.params_lock);
                if (runtime->oss.buffer_used > 0) {
 #ifdef OSS_DEBUG
-                       printk(KERN_DEBUG "sync: buffer_used\n");
+                       pcm_dbg(substream->pcm, "sync: buffer_used\n");
 #endif
                        size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width;
                        snd_pcm_format_set_silence(format,
@@ -1631,7 +1627,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
                        }
                } else if (runtime->oss.period_ptr > 0) {
 #ifdef OSS_DEBUG
-                       printk(KERN_DEBUG "sync: period_ptr\n");
+                       pcm_dbg(substream->pcm, "sync: period_ptr\n");
 #endif
                        size = runtime->oss.period_bytes - runtime->oss.period_ptr;
                        snd_pcm_format_set_silence(format,
@@ -1983,7 +1979,7 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
        int err, cmd;
 
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "pcm_oss: trigger = 0x%x\n", trigger);
+       pcm_dbg(substream->pcm, "pcm_oss: trigger = 0x%x\n", trigger);
 #endif
        
        psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
@@ -2203,9 +2199,9 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
        }
 
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "pcm_oss: space: bytes = %i, fragments = %i, "
-              "fragstotal = %i, fragsize = %i\n",
-              info.bytes, info.fragments, info.fragstotal, info.fragsize);
+       pcm_dbg(substream->pcm,
+               "pcm_oss: space: bytes = %i, fragments = %i, fragstotal = %i, fragsize = %i\n",
+               info.bytes, info.fragments, info.fragstotal, info.fragsize);
 #endif
        if (copy_to_user(_info, &info, sizeof(info)))
                return -EFAULT;
@@ -2215,7 +2211,7 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
 static int snd_pcm_oss_get_mapbuf(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct buffmem_desc __user * _info)
 {
        // it won't be probably implemented
-       // snd_printd("TODO: snd_pcm_oss_get_mapbuf\n");
+       // pr_debug("TODO: snd_pcm_oss_get_mapbuf\n");
        return -EINVAL;
 }
 
@@ -2519,7 +2515,7 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
        if (((cmd >> 8) & 0xff) != 'P')
                return -EINVAL;
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "pcm_oss: ioctl = 0x%x\n", cmd);
+       pr_debug("pcm_oss: ioctl = 0x%x\n", cmd);
 #endif
        switch (cmd) {
        case SNDCTL_DSP_RESET:
@@ -2646,7 +2642,7 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
        case SNDCTL_DSP_PROFILE:
                return 0;       /* silently ignore */
        default:
-               snd_printd("pcm_oss: unknown command = 0x%x\n", cmd);
+               pr_debug("pcm_oss: unknown command = 0x%x\n", cmd);
        }
        return -EINVAL;
 }
@@ -2673,8 +2669,9 @@ static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t coun
 #else
        {
                ssize_t res = snd_pcm_oss_read1(substream, buf, count);
-               printk(KERN_DEBUG "pcm_oss: read %li bytes "
-                      "(returned %li bytes)\n", (long)count, (long)res);
+               pcm_dbg(substream->pcm,
+                       "pcm_oss: read %li bytes (returned %li bytes)\n",
+                       (long)count, (long)res);
                return res;
        }
 #endif
@@ -2693,7 +2690,7 @@ static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size
        substream->f_flags = file->f_flags & O_NONBLOCK;
        result = snd_pcm_oss_write1(substream, buf, count);
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "pcm_oss: write %li bytes (wrote %li bytes)\n",
+       pcm_dbg(substream->pcm, "pcm_oss: write %li bytes (wrote %li bytes)\n",
               (long)count, (long)result);
 #endif
        return result;
@@ -2772,7 +2769,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
        int err;
 
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "pcm_oss: mmap begin\n");
+       pr_debug("pcm_oss: mmap begin\n");
 #endif
        pcm_oss_file = file->private_data;
        switch ((area->vm_flags & (VM_READ | VM_WRITE))) {
@@ -2822,7 +2819,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
        runtime->silence_threshold = 0;
        runtime->silence_size = 0;
 #ifdef OSS_DEBUG
-       printk(KERN_DEBUG "pcm_oss: mmap ok, bytes = 0x%x\n",
+       pr_debug("pcm_oss: mmap ok, bytes = 0x%x\n",
               runtime->oss.mmap_bytes);
 #endif
        /* In mmap mode we never stop */
@@ -3007,12 +3004,10 @@ static const struct file_operations snd_pcm_oss_f_reg =
 
 static void register_oss_dsp(struct snd_pcm *pcm, int index)
 {
-       char name[128];
-       sprintf(name, "dsp%i%i", pcm->card->number, pcm->device);
        if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM,
                                    pcm->card, index, &snd_pcm_oss_f_reg,
-                                   pcm, name) < 0) {
-               snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n",
+                                   pcm) < 0) {
+               pcm_err(pcm, "unable to register OSS PCM device %i:%i\n",
                           pcm->card->number, pcm->device);
        }
 }
@@ -3093,12 +3088,12 @@ static int __init alsa_pcm_oss_init(void)
        /* check device map table */
        for (i = 0; i < SNDRV_CARDS; i++) {
                if (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_PCM_DEVICES) {
-                       snd_printk(KERN_ERR "invalid dsp_map[%d] = %d\n",
+                       pr_err("ALSA: pcm_oss: invalid dsp_map[%d] = %d\n",
                                   i, dsp_map[i]);
                        dsp_map[i] = 0;
                }
                if (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_PCM_DEVICES) {
-                       snd_printk(KERN_ERR "invalid adsp_map[%d] = %d\n",
+                       pr_err("ALSA: pcm_oss: invalid adsp_map[%d] = %d\n",
                                   i, adsp_map[i]);
                        adsp_map[i] = 1;
                }
index e1e9e0c999fefa854a507e623b821371ebf00b78..43932e8dce669a57a0908ffbd57585a858d1616b 100644 (file)
@@ -295,7 +295,7 @@ static const char *snd_pcm_state_name(snd_pcm_state_t state)
        return snd_pcm_state_names[(__force int)state];
 }
 
-#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
 #include <linux/soundcard.h>
 
 static const char *snd_pcm_oss_format_name(int format)
@@ -338,7 +338,8 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
 
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (! info) {
-               printk(KERN_DEBUG "snd_pcm_proc_info_read: cannot malloc\n");
+               pcm_dbg(substream->pcm,
+                       "snd_pcm_proc_info_read: cannot malloc\n");
                return;
        }
 
@@ -398,7 +399,7 @@ static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "rate: %u (%u/%u)\n", runtime->rate, runtime->rate_num, runtime->rate_den); 
        snd_iprintf(buffer, "period_size: %lu\n", runtime->period_size);        
        snd_iprintf(buffer, "buffer_size: %lu\n", runtime->buffer_size);        
-#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
        if (substream->oss.oss) {
                snd_iprintf(buffer, "OSS format: %s\n", snd_pcm_oss_format_name(runtime->oss.format));
                snd_iprintf(buffer, "OSS channels: %u\n", runtime->oss.channels);       
@@ -651,7 +652,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        struct snd_pcm_str *pstr = &pcm->streams[stream];
        struct snd_pcm_substream *substream, *prev;
 
-#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
        mutex_init(&pstr->oss.setup_mutex);
 #endif
        pstr->stream = stream;
@@ -660,7 +661,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        if (substream_count > 0 && !pcm->internal) {
                err = snd_pcm_stream_proc_init(pstr);
                if (err < 0) {
-                       snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
+                       pcm_err(pcm, "Error in snd_pcm_stream_proc_init\n");
                        return err;
                }
        }
@@ -668,7 +669,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        for (idx = 0, prev = NULL; idx < substream_count; idx++) {
                substream = kzalloc(sizeof(*substream), GFP_KERNEL);
                if (substream == NULL) {
-                       snd_printk(KERN_ERR "Cannot allocate PCM substream\n");
+                       pcm_err(pcm, "Cannot allocate PCM substream\n");
                        return -ENOMEM;
                }
                substream->pcm = pcm;
@@ -685,7 +686,8 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
                if (!pcm->internal) {
                        err = snd_pcm_substream_proc_init(substream);
                        if (err < 0) {
-                               snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
+                               pcm_err(pcm,
+                                       "Error in snd_pcm_stream_proc_init\n");
                                if (prev == NULL)
                                        pstr->substream = NULL;
                                else
@@ -724,7 +726,7 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
                *rpcm = NULL;
        pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
        if (pcm == NULL) {
-               snd_printk(KERN_ERR "Cannot allocate PCM\n");
+               dev_err(card->dev, "Cannot allocate PCM\n");
                return -ENOMEM;
        }
        pcm->card = card;
@@ -807,7 +809,7 @@ EXPORT_SYMBOL(snd_pcm_new_internal);
 static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
 {
        struct snd_pcm_substream *substream, *substream_next;
-#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
        struct snd_pcm_oss_setup *setup, *setupn;
 #endif
        substream = pstr->substream;
@@ -819,7 +821,7 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
                substream = substream_next;
        }
        snd_pcm_stream_proc_done(pstr);
-#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
        for (setup = pstr->oss.setup_list; setup; setup = setupn) {
                setupn = setup->next;
                kfree(setup->task_name);
@@ -1016,8 +1018,20 @@ static ssize_t show_pcm_class(struct device *dev,
         return snprintf(buf, PAGE_SIZE, "%s\n", str);
 }
 
-static struct device_attribute pcm_attrs =
-       __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
+static DEVICE_ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
+static struct attribute *pcm_dev_attrs[] = {
+       &dev_attr_pcm_class.attr,
+       NULL
+};
+
+static struct attribute_group pcm_dev_attr_group = {
+       .attrs  = pcm_dev_attrs,
+};
+
+static const struct attribute_group *pcm_dev_attr_groups[] = {
+       &pcm_dev_attr_group,
+       NULL
+};
 
 static int snd_pcm_dev_register(struct snd_device *device)
 {
@@ -1067,8 +1081,18 @@ static int snd_pcm_dev_register(struct snd_device *device)
                        mutex_unlock(&register_mutex);
                        return err;
                }
-               snd_add_device_sysfs_file(devtype, pcm->card, pcm->device,
-                                         &pcm_attrs);
+
+               dev = snd_get_device(devtype, pcm->card, pcm->device);
+               if (dev) {
+                       err = sysfs_create_groups(&dev->kobj,
+                                                 pcm_dev_attr_groups);
+                       if (err < 0)
+                               dev_warn(dev,
+                                        "pcm %d:%d: cannot create sysfs groups\n",
+                                        pcm->card->number, pcm->device);
+                       put_device(dev);
+               }
+
                for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
                        snd_pcm_timer_init(substream);
        }
index 5dcf88bed9b785e38dd01eecf5121f09e1d43255..ce83def9f43bf9d30755e48f1129d25af81792a9 100644 (file)
@@ -174,7 +174,7 @@ static void xrun(struct snd_pcm_substream *substream)
        if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {
                char name[16];
                snd_pcm_debug_name(substream, name, sizeof(name));
-               snd_printd(KERN_DEBUG "XRUN: %s\n", name);
+               pcm_warn(substream->pcm, "XRUN: %s\n", name);
                dump_stack_on_xrun(substream);
        }
 }
@@ -184,9 +184,7 @@ static void xrun(struct snd_pcm_substream *substream)
        do {                                                            \
                if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {          \
                        xrun_log_show(substream);                       \
-                       if (snd_printd_ratelimit()) {                   \
-                               snd_printd("PCM: " fmt, ##args);        \
-                       }                                               \
+                       pr_err_ratelimited("ALSA: PCM: " fmt, ##args);  \
                        dump_stack_on_xrun(substream);                  \
                }                                                       \
        } while (0)
@@ -253,7 +251,7 @@ static void xrun_log_show(struct snd_pcm_substream *substream)
                entry = &log->entries[idx];
                if (entry->period_size == 0)
                        break;
-               snd_printd("hwptr log: %s: %sj=%lu, pos=%ld/%ld/%ld, "
+               pr_info("hwptr log: %s: %sj=%lu, pos=%ld/%ld/%ld, "
                           "hwptr=%ld/%ld\n",
                           name, entry->in_interrupt ? "[Q] " : "",
                           entry->jiffies,
@@ -342,14 +340,14 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
                return -EPIPE;
        }
        if (pos >= runtime->buffer_size) {
-               if (snd_printd_ratelimit()) {
+               if (printk_ratelimit()) {
                        char name[16];
                        snd_pcm_debug_name(substream, name, sizeof(name));
                        xrun_log_show(substream);
-                       snd_printd(KERN_ERR  "BUG: %s, pos = %ld, "
-                                  "buffer size = %ld, period size = %ld\n",
-                                  name, pos, runtime->buffer_size,
-                                  runtime->period_size);
+                       pcm_err(substream->pcm,
+                               "BUG: %s, pos = %ld, buffer size = %ld, period size = %ld\n",
+                               name, pos, runtime->buffer_size,
+                               runtime->period_size);
                }
                pos = 0;
        }
@@ -394,8 +392,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
                        XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) {
                char name[16];
                snd_pcm_debug_name(substream, name, sizeof(name));
-               snd_printd("%s_update: %s: pos=%u/%u/%u, "
-                          "hwptr=%ld/%ld/%ld/%ld\n",
+               pcm_dbg(substream->pcm,
+                       "%s_update: %s: pos=%u/%u/%u, hwptr=%ld/%ld/%ld/%ld\n",
                           in_interrupt ? "period" : "hwptr",
                           name,
                           (unsigned int)pos,
@@ -1942,8 +1940,9 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
                        continue;
                }
                if (!tout) {
-                       snd_printd("%s write error (DMA or IRQ trouble?)\n",
-                                  is_playback ? "playback" : "capture");
+                       pcm_dbg(substream->pcm,
+                               "%s write error (DMA or IRQ trouble?)\n",
+                               is_playback ? "playback" : "capture");
                        err = -EIO;
                        break;
                }
index 01a5e05ede95cddbbcaa6be3ddb4bcf13e3786ce..b653ab001fbac0778547b933815dff289240f7cf 100644 (file)
@@ -190,12 +190,12 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
                if (!(params->rmask & (1 << k)))
                        continue;
 #ifdef RULES_DEBUG
-               printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]);
-               printk("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
+               pr_debug("%s = ", snd_pcm_hw_param_names[k]);
+               pr_cont("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
 #endif
                changed = snd_mask_refine(m, constrs_mask(constrs, k));
 #ifdef RULES_DEBUG
-               printk("%04x%04x%04x%04x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
+               pr_cont("%04x%04x%04x%04x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
 #endif
                if (changed)
                        params->cmask |= 1 << k;
@@ -210,21 +210,21 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
                if (!(params->rmask & (1 << k)))
                        continue;
 #ifdef RULES_DEBUG
-               printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]);
+               pr_debug("%s = ", snd_pcm_hw_param_names[k]);
                if (i->empty)
-                       printk("empty");
+                       pr_cont("empty");
                else
-                       printk("%c%u %u%c", 
+                       pr_cont("%c%u %u%c",
                               i->openmin ? '(' : '[', i->min,
                               i->max, i->openmax ? ')' : ']');
-               printk(" -> ");
+               pr_cont(" -> ");
 #endif
                changed = snd_interval_refine(i, constrs_interval(constrs, k));
 #ifdef RULES_DEBUG
                if (i->empty)
-                       printk("empty\n");
+                       pr_cont("empty\n");
                else 
-                       printk("%c%u %u%c\n", 
+                       pr_cont("%c%u %u%c\n",
                               i->openmin ? '(' : '[', i->min,
                               i->max, i->openmax ? ')' : ']');
 #endif
@@ -255,18 +255,18 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
                        if (!doit)
                                continue;
 #ifdef RULES_DEBUG
-                       printk(KERN_DEBUG "Rule %d [%p]: ", k, r->func);
+                       pr_debug("Rule %d [%p]: ", k, r->func);
                        if (r->var >= 0) {
-                               printk("%s = ", snd_pcm_hw_param_names[r->var]);
+                               pr_cont("%s = ", snd_pcm_hw_param_names[r->var]);
                                if (hw_is_mask(r->var)) {
                                        m = hw_param_mask(params, r->var);
-                                       printk("%x", *m->bits);
+                                       pr_cont("%x", *m->bits);
                                } else {
                                        i = hw_param_interval(params, r->var);
                                        if (i->empty)
-                                               printk("empty");
+                                               pr_cont("empty");
                                        else
-                                               printk("%c%u %u%c", 
+                                               pr_cont("%c%u %u%c",
                                                       i->openmin ? '(' : '[', i->min,
                                                       i->max, i->openmax ? ')' : ']');
                                }
@@ -275,19 +275,19 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
                        changed = r->func(params, r);
 #ifdef RULES_DEBUG
                        if (r->var >= 0) {
-                               printk(" -> ");
+                               pr_cont(" -> ");
                                if (hw_is_mask(r->var))
-                                       printk("%x", *m->bits);
+                                       pr_cont("%x", *m->bits);
                                else {
                                        if (i->empty)
-                                               printk("empty");
+                                               pr_cont("empty");
                                        else
-                                               printk("%c%u %u%c", 
+                                               pr_cont("%c%u %u%c",
                                                       i->openmin ? '(' : '[', i->min,
                                                       i->max, i->openmax ? ')' : ']');
                                }
                        }
-                       printk("\n");
+                       pr_cont("\n");
 #endif
                        rstamps[k] = stamp;
                        if (changed && r->var >= 0) {
@@ -399,7 +399,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
                return -EBADFD;
        }
        snd_pcm_stream_unlock_irq(substream);
-#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
        if (!substream->oss.oss)
 #endif
                if (atomic_read(&substream->mmap_count))
@@ -954,7 +954,7 @@ static struct action_ops snd_pcm_action_stop = {
  *
  * The state of each stream is then changed to the given state unconditionally.
  *
- * Return: Zero if succesful, or a negative error code.
+ * Return: Zero if successful, or a negative error code.
  */
 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)
 {
@@ -1541,7 +1541,8 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
                        if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
                                result = -ESTRPIPE;
                        else {
-                               snd_printd("playback drain error (DMA or IRQ trouble?)\n");
+                               dev_dbg(substream->pcm->card->dev,
+                                       "playback drain error (DMA or IRQ trouble?)\n");
                                snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
                                result = -EIO;
                        }
@@ -2066,7 +2067,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
 
        err = snd_pcm_hw_constraints_init(substream);
        if (err < 0) {
-               snd_printd("snd_pcm_hw_constraints_init failed\n");
+               pcm_dbg(pcm, "snd_pcm_hw_constraints_init failed\n");
                goto error;
        }
 
@@ -2077,7 +2078,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
 
        err = snd_pcm_hw_constraints_complete(substream);
        if (err < 0) {
-               snd_printd("snd_pcm_hw_constraints_complete failed\n");
+               pcm_dbg(pcm, "snd_pcm_hw_constraints_complete failed\n");
                goto error;
        }
 
@@ -2609,7 +2610,7 @@ static int snd_pcm_common_ioctl1(struct file *file,
                return res;
        }
        }
-       snd_printd("unknown ioctl = 0x%x\n", cmd);
+       pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd);
        return -ENOTTY;
 }
 
index b01d9481d632c4245d3403a445e6e641b9b2e2aa..20ecd8f180808cf62b0b129902e3f89f7a59e5ff 100644 (file)
@@ -53,7 +53,9 @@ void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream)
                post *= 2;
        }
        if (rate == 0) {
-               snd_printk(KERN_ERR "pcm timer resolution out of range (rate = %u, period_size = %lu)\n", runtime->rate, runtime->period_size);
+               pcm_err(substream->pcm,
+                       "pcm timer resolution out of range (rate = %u, period_size = %lu)\n",
+                       runtime->rate, runtime->period_size);
                runtime->timer_resolution = -1;
                return;
        }
index 7b596b5751dbcea07a075685017cef6c7e0cb364..6fc71a4c8a5177c63094333093de18a70b3159ac 100644 (file)
@@ -56,6 +56,13 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device);
 static LIST_HEAD(snd_rawmidi_devices);
 static DEFINE_MUTEX(register_mutex);
 
+#define rmidi_err(rmidi, fmt, args...) \
+       dev_err((rmidi)->card->dev, fmt, ##args)
+#define rmidi_warn(rmidi, fmt, args...) \
+       dev_warn((rmidi)->card->dev, fmt, ##args)
+#define rmidi_dbg(rmidi, fmt, args...) \
+       dev_dbg((rmidi)->card->dev, fmt, ##args)
+
 static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
 {
        struct snd_rawmidi *rawmidi;
@@ -165,6 +172,7 @@ int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream)
        spin_unlock_irqrestore(&runtime->lock, flags);
        return 0;
 }
+EXPORT_SYMBOL(snd_rawmidi_drop_output);
 
 int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream)
 {
@@ -180,7 +188,9 @@ int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream)
        if (signal_pending(current))
                err = -ERESTARTSYS;
        if (runtime->avail < runtime->buffer_size && !timeout) {
-               snd_printk(KERN_WARNING "rawmidi drain error (avail = %li, buffer_size = %li)\n", (long)runtime->avail, (long)runtime->buffer_size);
+               rmidi_warn(substream->rmidi,
+                          "rawmidi drain error (avail = %li, buffer_size = %li)\n",
+                          (long)runtime->avail, (long)runtime->buffer_size);
                err = -EIO;
        }
        runtime->drain = 0;
@@ -194,6 +204,7 @@ int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream)
        }
        return err;
 }
+EXPORT_SYMBOL(snd_rawmidi_drain_output);
 
 int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream)
 {
@@ -208,6 +219,7 @@ int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream)
        spin_unlock_irqrestore(&runtime->lock, flags);
        return 0;
 }
+EXPORT_SYMBOL(snd_rawmidi_drain_input);
 
 /* look for an available substream for the given stream direction;
  * if a specific subdevice is given, try to assign it
@@ -345,6 +357,7 @@ int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
                module_put(rmidi->card->module);
        return err;
 }
+EXPORT_SYMBOL(snd_rawmidi_kernel_open);
 
 static int snd_rawmidi_open(struct inode *inode, struct file *file)
 {
@@ -523,6 +536,7 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile)
        module_put(rmidi->card->module);
        return 0;
 }
+EXPORT_SYMBOL(snd_rawmidi_kernel_release);
 
 static int snd_rawmidi_release(struct inode *inode, struct file *file)
 {
@@ -599,6 +613,7 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
        }
        return -ENXIO;
 }
+EXPORT_SYMBOL(snd_rawmidi_info_select);
 
 static int snd_rawmidi_info_select_user(struct snd_card *card,
                                        struct snd_rawmidi_info __user *_info)
@@ -646,6 +661,7 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
        substream->active_sensing = !params->no_active_sensing;
        return 0;
 }
+EXPORT_SYMBOL(snd_rawmidi_output_params);
 
 int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
                             struct snd_rawmidi_params * params)
@@ -671,6 +687,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
        runtime->avail_min = params->avail_min;
        return 0;
 }
+EXPORT_SYMBOL(snd_rawmidi_input_params);
 
 static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
                                     struct snd_rawmidi_status * status)
@@ -802,10 +819,9 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
                        return -EINVAL;
                }
        }
-#ifdef CONFIG_SND_DEBUG
        default:
-               snd_printk(KERN_WARNING "rawmidi: unknown command = 0x%x\n", cmd);
-#endif
+               rmidi_dbg(rfile->rmidi,
+                         "rawmidi: unknown command = 0x%x\n", cmd);
        }
        return -ENOTTY;
 }
@@ -875,7 +891,8 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
        if (!substream->opened)
                return -EBADFD;
        if (runtime->buffer == NULL) {
-               snd_printd("snd_rawmidi_receive: input is not active!!!\n");
+               rmidi_dbg(substream->rmidi,
+                         "snd_rawmidi_receive: input is not active!!!\n");
                return -EINVAL;
        }
        spin_lock_irqsave(&runtime->lock, flags);
@@ -926,6 +943,7 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
        spin_unlock_irqrestore(&runtime->lock, flags);
        return result;
 }
+EXPORT_SYMBOL(snd_rawmidi_receive);
 
 static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
                                     unsigned char __user *userbuf,
@@ -968,6 +986,7 @@ long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
        snd_rawmidi_input_trigger(substream, 1);
        return snd_rawmidi_kernel_read1(substream, NULL/*userbuf*/, buf, count);
 }
+EXPORT_SYMBOL(snd_rawmidi_kernel_read);
 
 static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t count,
                                loff_t *offset)
@@ -1034,7 +1053,8 @@ int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream)
        unsigned long flags;
 
        if (runtime->buffer == NULL) {
-               snd_printd("snd_rawmidi_transmit_empty: output is not active!!!\n");
+               rmidi_dbg(substream->rmidi,
+                         "snd_rawmidi_transmit_empty: output is not active!!!\n");
                return 1;
        }
        spin_lock_irqsave(&runtime->lock, flags);
@@ -1042,6 +1062,7 @@ int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream)
        spin_unlock_irqrestore(&runtime->lock, flags);
        return result;          
 }
+EXPORT_SYMBOL(snd_rawmidi_transmit_empty);
 
 /**
  * snd_rawmidi_transmit_peek - copy data from the internal buffer
@@ -1065,7 +1086,8 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
        struct snd_rawmidi_runtime *runtime = substream->runtime;
 
        if (runtime->buffer == NULL) {
-               snd_printd("snd_rawmidi_transmit_peek: output is not active!!!\n");
+               rmidi_dbg(substream->rmidi,
+                         "snd_rawmidi_transmit_peek: output is not active!!!\n");
                return -EINVAL;
        }
        result = 0;
@@ -1097,11 +1119,12 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
        spin_unlock_irqrestore(&runtime->lock, flags);
        return result;
 }
+EXPORT_SYMBOL(snd_rawmidi_transmit_peek);
 
 /**
  * snd_rawmidi_transmit_ack - acknowledge the transmission
  * @substream: the rawmidi substream
- * @count: the tranferred count
+ * @count: the transferred count
  *
  * Advances the hardware pointer for the internal output buffer with
  * the given size and updates the condition.
@@ -1115,7 +1138,8 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count)
        struct snd_rawmidi_runtime *runtime = substream->runtime;
 
        if (runtime->buffer == NULL) {
-               snd_printd("snd_rawmidi_transmit_ack: output is not active!!!\n");
+               rmidi_dbg(substream->rmidi,
+                         "snd_rawmidi_transmit_ack: output is not active!!!\n");
                return -EINVAL;
        }
        spin_lock_irqsave(&runtime->lock, flags);
@@ -1131,6 +1155,7 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count)
        spin_unlock_irqrestore(&runtime->lock, flags);
        return count;
 }
+EXPORT_SYMBOL(snd_rawmidi_transmit_ack);
 
 /**
  * snd_rawmidi_transmit - copy from the buffer to the device
@@ -1152,6 +1177,7 @@ int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
                return count;
        return snd_rawmidi_transmit_ack(substream, count);
 }
+EXPORT_SYMBOL(snd_rawmidi_transmit);
 
 static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
                                      const unsigned char __user *userbuf,
@@ -1213,6 +1239,7 @@ long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream,
 {
        return snd_rawmidi_kernel_write1(substream, NULL, buf, count);
 }
+EXPORT_SYMBOL(snd_rawmidi_kernel_write);
 
 static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
                                 size_t count, loff_t *offset)
@@ -1413,7 +1440,7 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
        for (idx = 0; idx < count; idx++) {
                substream = kzalloc(sizeof(*substream), GFP_KERNEL);
                if (substream == NULL) {
-                       snd_printk(KERN_ERR "rawmidi: cannot allocate substream\n");
+                       rmidi_err(rmidi, "rawmidi: cannot allocate substream\n");
                        return -ENOMEM;
                }
                substream->stream = direction;
@@ -1458,7 +1485,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
                *rrawmidi = NULL;
        rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL);
        if (rmidi == NULL) {
-               snd_printk(KERN_ERR "rawmidi: cannot allocate\n");
+               dev_err(card->dev, "rawmidi: cannot allocate\n");
                return -ENOMEM;
        }
        rmidi->card = card;
@@ -1492,6 +1519,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
                *rrawmidi = rmidi;
        return 0;
 }
+EXPORT_SYMBOL(snd_rawmidi_new);
 
 static void snd_rawmidi_free_substreams(struct snd_rawmidi_str *stream)
 {
@@ -1557,7 +1585,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
        if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
                                       rmidi->card, rmidi->device,
                                       &snd_rawmidi_f_ops, rmidi, name)) < 0) {
-               snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
+               rmidi_err(rmidi, "unable to register rawmidi device %i:%i\n",
+                         rmidi->card->number, rmidi->device);
                list_del(&rmidi->list);
                mutex_unlock(&register_mutex);
                return err;
@@ -1574,8 +1603,10 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
        if ((int)rmidi->device == midi_map[rmidi->card->number]) {
                if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
                                            rmidi->card, 0, &snd_rawmidi_f_ops,
-                                           rmidi, name) < 0) {
-                       snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
+                                           rmidi) < 0) {
+                       rmidi_err(rmidi,
+                                 "unable to register OSS rawmidi device %i:%i\n",
+                                 rmidi->card->number, 0);
                } else {
                        rmidi->ossreg++;
 #ifdef SNDRV_OSS_INFO_DEV_MIDI
@@ -1586,8 +1617,10 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
        if ((int)rmidi->device == amidi_map[rmidi->card->number]) {
                if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
                                            rmidi->card, 1, &snd_rawmidi_f_ops,
-                                           rmidi, name) < 0) {
-                       snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
+                                           rmidi) < 0) {
+                       rmidi_err(rmidi,
+                                 "unable to register OSS rawmidi device %i:%i\n",
+                                 rmidi->card->number, 1);
                } else {
                        rmidi->ossreg++;
                }
@@ -1670,6 +1703,7 @@ void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
        list_for_each_entry(substream, &rmidi->streams[stream].substreams, list)
                substream->ops = ops;
 }
+EXPORT_SYMBOL(snd_rawmidi_set_ops);
 
 /*
  *  ENTRY functions
@@ -1685,11 +1719,13 @@ static int __init alsa_rawmidi_init(void)
        /* check device map table */
        for (i = 0; i < SNDRV_CARDS; i++) {
                if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
-                       snd_printk(KERN_ERR "invalid midi_map[%d] = %d\n", i, midi_map[i]);
+                       pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
+                              i, midi_map[i]);
                        midi_map[i] = 0;
                }
                if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
-                       snd_printk(KERN_ERR "invalid amidi_map[%d] = %d\n", i, amidi_map[i]);
+                       pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
+                              i, amidi_map[i]);
                        amidi_map[i] = 1;
                }
        }
@@ -1706,21 +1742,3 @@ static void __exit alsa_rawmidi_exit(void)
 
 module_init(alsa_rawmidi_init)
 module_exit(alsa_rawmidi_exit)
-
-EXPORT_SYMBOL(snd_rawmidi_output_params);
-EXPORT_SYMBOL(snd_rawmidi_input_params);
-EXPORT_SYMBOL(snd_rawmidi_drop_output);
-EXPORT_SYMBOL(snd_rawmidi_drain_output);
-EXPORT_SYMBOL(snd_rawmidi_drain_input);
-EXPORT_SYMBOL(snd_rawmidi_receive);
-EXPORT_SYMBOL(snd_rawmidi_transmit_empty);
-EXPORT_SYMBOL(snd_rawmidi_transmit_peek);
-EXPORT_SYMBOL(snd_rawmidi_transmit_ack);
-EXPORT_SYMBOL(snd_rawmidi_transmit);
-EXPORT_SYMBOL(snd_rawmidi_new);
-EXPORT_SYMBOL(snd_rawmidi_set_ops);
-EXPORT_SYMBOL(snd_rawmidi_info_select);
-EXPORT_SYMBOL(snd_rawmidi_kernel_open);
-EXPORT_SYMBOL(snd_rawmidi_kernel_release);
-EXPORT_SYMBOL(snd_rawmidi_kernel_read);
-EXPORT_SYMBOL(snd_rawmidi_kernel_write);
index e85e72baff9e8535c9cbd7a56ba0e4d65ddd1ac1..f3420d11a12fea53547caba81d0e7b8775ce1878 100644 (file)
@@ -27,7 +27,7 @@
 #include <sound/core.h>
 #include <sound/timer.h>
 
-#if defined(CONFIG_RTC) || defined(CONFIG_RTC_MODULE)
+#if IS_ENABLED(CONFIG_RTC)
 
 #include <linux/mc146818rtc.h>
 
@@ -132,8 +132,7 @@ static int __init rtctimer_init(void)
 
        if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
            !is_power_of_2(rtctimer_freq)) {
-               snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n",
-                          rtctimer_freq);
+               pr_err("ALSA: rtctimer: invalid frequency %d\n", rtctimer_freq);
                return -EINVAL;
        }
 
@@ -185,4 +184,4 @@ MODULE_LICENSE("GPL");
 
 MODULE_ALIAS("snd-timer-" __stringify(SNDRV_TIMER_GLOBAL_RTC));
 
-#endif /* CONFIG_RTC || CONFIG_RTC_MODULE */
+#endif /* IS_ENABLED(CONFIG_RTC) */
index 8d4d5e853efec94716cf5585a94321c097144eb9..16d42679e43fc29e380612274e9f597f9899dc91 100644 (file)
@@ -39,12 +39,6 @@ MODULE_LICENSE("GPL");
 MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_SEQUENCER);
 MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MUSIC);
 
-#ifdef SNDRV_SEQ_OSS_DEBUG
-module_param(seq_oss_debug, int, 0644);
-MODULE_PARM_DESC(seq_oss_debug, "debug option");
-int seq_oss_debug = 0;
-#endif
-
 
 /*
  * prototypes
@@ -231,22 +225,19 @@ register_device(void)
        mutex_lock(&register_mutex);
        if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
                                          NULL, 0,
-                                         &seq_oss_f_ops, NULL,
-                                         SNDRV_SEQ_OSS_DEVNAME)) < 0) {
-               snd_printk(KERN_ERR "can't register device seq\n");
+                                         &seq_oss_f_ops, NULL)) < 0) {
+               pr_err("ALSA: seq_oss: can't register device seq\n");
                mutex_unlock(&register_mutex);
                return rc;
        }
        if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
                                          NULL, 0,
-                                         &seq_oss_f_ops, NULL,
-                                         SNDRV_SEQ_OSS_DEVNAME)) < 0) {
-               snd_printk(KERN_ERR "can't register device music\n");
+                                         &seq_oss_f_ops, NULL)) < 0) {
+               pr_err("ALSA: seq_oss: can't register device music\n");
                snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
                mutex_unlock(&register_mutex);
                return rc;
        }
-       debug_printk(("device registered\n"));
        mutex_unlock(&register_mutex);
        return 0;
 }
@@ -255,11 +246,10 @@ static void
 unregister_device(void)
 {
        mutex_lock(&register_mutex);
-       debug_printk(("device unregistered\n"));
        if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0)                
-               snd_printk(KERN_ERR "error unregister device music\n");
+               pr_err("ALSA: seq_oss: error unregister device music\n");
        if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0)
-               snd_printk(KERN_ERR "error unregister device seq\n");
+               pr_err("ALSA: seq_oss: error unregister device seq\n");
        mutex_unlock(&register_mutex);
 }
 
index c0154a959d55373969c0e4eb608099f1e71098a7..b43924325249c01b0cdd11fc1164572a50369f98 100644 (file)
@@ -31,9 +31,6 @@
 #include <sound/seq_kernel.h>
 #include <sound/info.h>
 
-/* enable debug print */
-#define SNDRV_SEQ_OSS_DEBUG
-
 /* max. applications */
 #define SNDRV_SEQ_OSS_MAX_CLIENTS      16
 #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS   16
@@ -46,7 +43,6 @@
 #define SNDRV_SEQ_OSS_VERSION_STR      "0.1.8"
 
 /* device and proc interface name */
-#define SNDRV_SEQ_OSS_DEVNAME          "seq_oss"
 #define SNDRV_SEQ_OSS_PROCNAME         "oss"
 
 
@@ -177,13 +173,4 @@ snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
 /* misc. functions for proc interface */
 char *enabled_str(int bool);
 
-
-/* for debug */
-#ifdef SNDRV_SEQ_OSS_DEBUG
-extern int seq_oss_debug;
-#define debug_printk(x)        do { if (seq_oss_debug > 0) snd_printd x; } while (0)
-#else
-#define debug_printk(x)        /**/
-#endif
-
 #endif /* __SEQ_OSS_DEVICE_H */
index b3f39b5ed74234ff92d31162fc3af067a523c1ba..b9184d20c39ffb05057b5f74755fa49b37b088ba 100644 (file)
@@ -92,7 +92,6 @@ snd_seq_oss_create_client(void)
                goto __error;
 
        system_client = rc;
-       debug_printk(("new client = %d\n", rc));
 
        /* create annoucement receiver port */
        memset(port, 0, sizeof(*port));
@@ -190,10 +189,9 @@ snd_seq_oss_open(struct file *file, int level)
 
        dp = kzalloc(sizeof(*dp), GFP_KERNEL);
        if (!dp) {
-               snd_printk(KERN_ERR "can't malloc device info\n");
+               pr_err("ALSA: seq_oss: can't malloc device info\n");
                return -ENOMEM;
        }
-       debug_printk(("oss_open: dp = %p\n", dp));
 
        dp->cseq = system_client;
        dp->port = -1;
@@ -206,7 +204,7 @@ snd_seq_oss_open(struct file *file, int level)
 
        dp->index = i;
        if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) {
-               snd_printk(KERN_ERR "too many applications\n");
+               pr_err("ALSA: seq_oss: too many applications\n");
                rc = -ENOMEM;
                goto _error;
        }
@@ -216,21 +214,19 @@ snd_seq_oss_open(struct file *file, int level)
        snd_seq_oss_midi_setup(dp);
 
        if (dp->synth_opened == 0 && dp->max_mididev == 0) {
-               /* snd_printk(KERN_ERR "no device found\n"); */
+               /* pr_err("ALSA: seq_oss: no device found\n"); */
                rc = -ENODEV;
                goto _error;
        }
 
        /* create port */
-       debug_printk(("create new port\n"));
        rc = create_port(dp);
        if (rc < 0) {
-               snd_printk(KERN_ERR "can't create port\n");
+               pr_err("ALSA: seq_oss: can't create port\n");
                goto _error;
        }
 
        /* allocate queue */
-       debug_printk(("allocate queue\n"));
        rc = alloc_seq_queue(dp);
        if (rc < 0)
                goto _error;
@@ -247,7 +243,6 @@ snd_seq_oss_open(struct file *file, int level)
        dp->file_mode = translate_mode(file);
 
        /* initialize read queue */
-       debug_printk(("initialize read queue\n"));
        if (is_read_mode(dp->file_mode)) {
                dp->readq = snd_seq_oss_readq_new(dp, maxqlen);
                if (!dp->readq) {
@@ -257,7 +252,6 @@ snd_seq_oss_open(struct file *file, int level)
        }
 
        /* initialize write queue */
-       debug_printk(("initialize write queue\n"));
        if (is_write_mode(dp->file_mode)) {
                dp->writeq = snd_seq_oss_writeq_new(dp, maxqlen);
                if (!dp->writeq) {
@@ -267,14 +261,12 @@ snd_seq_oss_open(struct file *file, int level)
        }
 
        /* initialize timer */
-       debug_printk(("initialize timer\n"));
        dp->timer = snd_seq_oss_timer_new(dp);
        if (!dp->timer) {
-               snd_printk(KERN_ERR "can't alloc timer\n");
+               pr_err("ALSA: seq_oss: can't alloc timer\n");
                rc = -ENOMEM;
                goto _error;
        }
-       debug_printk(("timer initialized\n"));
 
        /* set private data pointer */
        file->private_data = dp;
@@ -288,7 +280,6 @@ snd_seq_oss_open(struct file *file, int level)
        client_table[dp->index] = dp;
        num_clients++;
 
-       debug_printk(("open done\n"));
        return 0;
 
  _error:
@@ -347,7 +338,6 @@ create_port(struct seq_oss_devinfo *dp)
                return rc;
 
        dp->port = port.addr.port;
-       debug_printk(("new port = %d\n", port.addr.port));
 
        return 0;
 }
@@ -363,7 +353,6 @@ delete_port(struct seq_oss_devinfo *dp)
                return 0;
        }
 
-       debug_printk(("delete_port %i\n", dp->port));
        return snd_seq_event_port_detach(dp->cseq, dp->port);
 }
 
@@ -401,7 +390,7 @@ delete_seq_queue(int queue)
        qinfo.queue = queue;
        rc = call_ctl(SNDRV_SEQ_IOCTL_DELETE_QUEUE, &qinfo);
        if (rc < 0)
-               printk(KERN_ERR "seq-oss: unable to delete queue %d (%d)\n", queue, rc);
+               pr_err("ALSA: seq_oss: unable to delete queue %d (%d)\n", queue, rc);
        return rc;
 }
 
@@ -438,21 +427,16 @@ snd_seq_oss_release(struct seq_oss_devinfo *dp)
        client_table[dp->index] = NULL;
        num_clients--;
 
-       debug_printk(("resetting..\n"));
        snd_seq_oss_reset(dp);
 
-       debug_printk(("cleaning up..\n"));
        snd_seq_oss_synth_cleanup(dp);
        snd_seq_oss_midi_cleanup(dp);
 
        /* clear slot */
-       debug_printk(("releasing resource..\n"));
        queue = dp->queue;
        if (dp->port >= 0)
                delete_port(dp);
        delete_seq_queue(queue);
-
-       debug_printk(("release done\n"));
 }
 
 
@@ -466,7 +450,6 @@ snd_seq_oss_drain_write(struct seq_oss_devinfo *dp)
                return;
        if (is_write_mode(dp->file_mode) && !is_nonblock_mode(dp->file_mode) &&
            dp->writeq) {
-               debug_printk(("syncing..\n"));
                while (snd_seq_oss_writeq_sync(dp->writeq))
                        ;
        }
index 5ac701c903c1f394f99776b9ff987c11f374c8ef..5b8520177b0ec9a67a848ccff39a8f9a80d73ee6 100644 (file)
@@ -90,12 +90,10 @@ snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long ca
                return snd_seq_oss_timer_ioctl(dp->timer, cmd, arg);
 
        case SNDCTL_SEQ_PANIC:
-               debug_printk(("panic\n"));
                snd_seq_oss_reset(dp);
                return -EINVAL;
 
        case SNDCTL_SEQ_SYNC:
-               debug_printk(("sync\n"));
                if (! is_write_mode(dp->file_mode) || dp->writeq == NULL)
                        return 0;
                while (snd_seq_oss_writeq_sync(dp->writeq))
@@ -105,55 +103,45 @@ snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long ca
                return 0;
 
        case SNDCTL_SEQ_RESET:
-               debug_printk(("reset\n"));
                snd_seq_oss_reset(dp);
                return 0;
 
        case SNDCTL_SEQ_TESTMIDI:
-               debug_printk(("test midi\n"));
                if (get_user(dev, p))
                        return -EFAULT;
                return snd_seq_oss_midi_open(dp, dev, dp->file_mode);
 
        case SNDCTL_SEQ_GETINCOUNT:
-               debug_printk(("get in count\n"));
                if (dp->readq == NULL || ! is_read_mode(dp->file_mode))
                        return 0;
                return put_user(dp->readq->qlen, p) ? -EFAULT : 0;
 
        case SNDCTL_SEQ_GETOUTCOUNT:
-               debug_printk(("get out count\n"));
                if (! is_write_mode(dp->file_mode) || dp->writeq == NULL)
                        return 0;
                return put_user(snd_seq_oss_writeq_get_free_size(dp->writeq), p) ? -EFAULT : 0;
 
        case SNDCTL_SEQ_GETTIME:
-               debug_printk(("get time\n"));
                return put_user(snd_seq_oss_timer_cur_tick(dp->timer), p) ? -EFAULT : 0;
 
        case SNDCTL_SEQ_RESETSAMPLES:
-               debug_printk(("reset samples\n"));
                if (get_user(dev, p))
                        return -EFAULT;
                return snd_seq_oss_synth_ioctl(dp, dev, cmd, carg);
 
        case SNDCTL_SEQ_NRSYNTHS:
-               debug_printk(("nr synths\n"));
                return put_user(dp->max_synthdev, p) ? -EFAULT : 0;
 
        case SNDCTL_SEQ_NRMIDIS:
-               debug_printk(("nr midis\n"));
                return put_user(dp->max_mididev, p) ? -EFAULT : 0;
 
        case SNDCTL_SYNTH_MEMAVL:
-               debug_printk(("mem avail\n"));
                if (get_user(dev, p))
                        return -EFAULT;
                val = snd_seq_oss_synth_ioctl(dp, dev, cmd, carg);
                return put_user(val, p) ? -EFAULT : 0;
 
        case SNDCTL_FM_4OP_ENABLE:
-               debug_printk(("4op\n"));
                if (get_user(dev, p))
                        return -EFAULT;
                snd_seq_oss_synth_ioctl(dp, dev, cmd, carg);
@@ -161,19 +149,15 @@ snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long ca
 
        case SNDCTL_SYNTH_INFO:
        case SNDCTL_SYNTH_ID:
-               debug_printk(("synth info\n"));
                return snd_seq_oss_synth_info_user(dp, arg);
 
        case SNDCTL_SEQ_OUTOFBAND:
-               debug_printk(("out of band\n"));
                return snd_seq_oss_oob_user(dp, arg);
 
        case SNDCTL_MIDI_INFO:
-               debug_printk(("midi info\n"));
                return snd_seq_oss_midi_info_user(dp, arg);
 
        case SNDCTL_SEQ_THRESHOLD:
-               debug_printk(("threshold\n"));
                if (! is_write_mode(dp->file_mode))
                        return 0;
                if (get_user(val, p))
@@ -186,7 +170,6 @@ snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long ca
                return 0;
 
        case SNDCTL_MIDI_PRETIME:
-               debug_printk(("pretime\n"));
                if (dp->readq == NULL || !is_read_mode(dp->file_mode))
                        return 0;
                if (get_user(val, p))
@@ -199,7 +182,6 @@ snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long ca
                return put_user(val, p) ? -EFAULT : 0;
 
        default:
-               debug_printk(("others\n"));
                if (! is_write_mode(dp->file_mode))
                        return -EIO;
                return snd_seq_oss_synth_ioctl(dp, 0, cmd, carg);
index 862d84893ee871c0467f5baf4667d769d6f7203e..3a4569669efa4b561b2751d9d1170e69ee2f4b47 100644 (file)
@@ -153,7 +153,6 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)
        struct seq_oss_midi *mdev;
        unsigned long flags;
 
-       debug_printk(("check for MIDI client %d port %d\n", pinfo->addr.client, pinfo->addr.port));
        /* the port must include generic midi */
        if (! (pinfo->type & SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC))
                return 0;
@@ -175,7 +174,7 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)
         * allocate midi info record
         */
        if ((mdev = kzalloc(sizeof(*mdev), GFP_KERNEL)) == NULL) {
-               snd_printk(KERN_ERR "can't malloc midi info\n");
+               pr_err("ALSA: seq_oss: can't malloc midi info\n");
                return -ENOMEM;
        }
 
@@ -191,7 +190,7 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)
 
        /* create MIDI coder */
        if (snd_midi_event_new(MAX_MIDI_EVENT_BUF, &mdev->coder) < 0) {
-               snd_printk(KERN_ERR "can't malloc midi coder\n");
+               pr_err("ALSA: seq_oss: can't malloc midi coder\n");
                kfree(mdev);
                return -ENOMEM;
        }
@@ -406,7 +405,6 @@ snd_seq_oss_midi_close(struct seq_oss_devinfo *dp, int dev)
                return 0;
        }
 
-       debug_printk(("closing client %d port %d mode %d\n", mdev->client, mdev->port, mdev->opened));
        memset(&subs, 0, sizeof(subs));
        if (mdev->opened & PERM_WRITE) {
                subs.sender = dp->addr;
@@ -470,7 +468,6 @@ snd_seq_oss_midi_reset(struct seq_oss_devinfo *dp, int dev)
                struct snd_seq_event ev;
                int c;
 
-               debug_printk(("resetting client %d port %d\n", mdev->client, mdev->port));
                memset(&ev, 0, sizeof(ev));
                ev.dest.client = mdev->client;
                ev.dest.port = mdev->port;
index 73661c4ab82aabefc2f26382db55854c704c8534..654d17a5023c8a23e2ec5f799298d91dc0c7f457 100644 (file)
@@ -48,12 +48,12 @@ snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen)
        struct seq_oss_readq *q;
 
        if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) {
-               snd_printk(KERN_ERR "can't malloc read queue\n");
+               pr_err("ALSA: seq_oss: can't malloc read queue\n");
                return NULL;
        }
 
        if ((q->q = kcalloc(maxlen, sizeof(union evrec), GFP_KERNEL)) == NULL) {
-               snd_printk(KERN_ERR "can't malloc read queue buffer\n");
+               pr_err("ALSA: seq_oss: can't malloc read queue buffer\n");
                kfree(q);
                return NULL;
        }
index c5b773a1eea9324ec7a1c70a0a7dc926031f87a3..701feb71b700c7e223633b07827e954a804e5825 100644 (file)
@@ -106,7 +106,7 @@ snd_seq_oss_synth_register(struct snd_seq_device *dev)
        unsigned long flags;
 
        if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL) {
-               snd_printk(KERN_ERR "can't malloc synth info\n");
+               pr_err("ALSA: seq_oss: can't malloc synth info\n");
                return -ENOMEM;
        }
        rec->seq_device = -1;
@@ -130,7 +130,7 @@ snd_seq_oss_synth_register(struct snd_seq_device *dev)
        if (i >= max_synth_devs) {
                if (max_synth_devs >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS) {
                        spin_unlock_irqrestore(&register_lock, flags);
-                       snd_printk(KERN_ERR "no more synth slot\n");
+                       pr_err("ALSA: seq_oss: no more synth slot\n");
                        kfree(rec);
                        return -ENOMEM;
                }
@@ -138,7 +138,6 @@ snd_seq_oss_synth_register(struct snd_seq_device *dev)
        }
        rec->seq_device = i;
        synth_devs[i] = rec;
-       debug_printk(("synth %s registered %d\n", rec->name, i));
        spin_unlock_irqrestore(&register_lock, flags);
        dev->driver_data = rec;
 #ifdef SNDRV_OSS_INFO_DEV_SYNTH
@@ -163,7 +162,7 @@ snd_seq_oss_synth_unregister(struct snd_seq_device *dev)
        }
        if (index >= max_synth_devs) {
                spin_unlock_irqrestore(&register_lock, flags);
-               snd_printk(KERN_ERR "can't unregister synth\n");
+               pr_err("ALSA: seq_oss: can't unregister synth\n");
                return -EINVAL;
        }
        synth_devs[index] = NULL;
@@ -248,7 +247,7 @@ snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp)
                if (info->nr_voices > 0) {
                        info->ch = kcalloc(info->nr_voices, sizeof(struct seq_oss_chinfo), GFP_KERNEL);
                        if (!info->ch) {
-                               snd_printk(KERN_ERR "Cannot malloc\n");
+                               pr_err("ALSA: seq_oss: Cannot malloc voices\n");
                                rec->oper.close(&info->arg);
                                module_put(rec->oper.owner);
                                snd_use_lock_free(&rec->use_lock);
@@ -256,7 +255,6 @@ snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp)
                        }
                        reset_channels(info);
                }
-               debug_printk(("synth %d assigned\n", i));
                info->opened++;
                rec->opened++;
                dp->synth_opened++;
@@ -326,7 +324,6 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp)
                        if (rec == NULL)
                                continue;
                        if (rec->opened > 0) {
-                               debug_printk(("synth %d closed\n", i));
                                rec->oper.close(&info->arg);
                                module_put(rec->oper.owner);
                                rec->opened = 0;
index ab59cbfbcaf20b4263faebb55d092ef93c2a4923..4f24ea9fad935ace703f61cd8ce084d0510ba3b7 100644 (file)
@@ -233,7 +233,6 @@ snd_seq_oss_timer_ioctl(struct seq_oss_timer *timer, unsigned int cmd, int __use
        int value;
 
        if (cmd == SNDCTL_SEQ_CTRLRATE) {
-               debug_printk(("ctrl rate\n"));
                /* if *arg == 0, just return the current rate */
                if (get_user(value, arg))
                        return -EFAULT;
@@ -248,21 +247,16 @@ snd_seq_oss_timer_ioctl(struct seq_oss_timer *timer, unsigned int cmd, int __use
 
        switch (cmd) {
        case SNDCTL_TMR_START:
-               debug_printk(("timer start\n"));
                return snd_seq_oss_timer_start(timer);
        case SNDCTL_TMR_STOP:
-               debug_printk(("timer stop\n"));
                return snd_seq_oss_timer_stop(timer);
        case SNDCTL_TMR_CONTINUE:
-               debug_printk(("timer continue\n"));
                return snd_seq_oss_timer_continue(timer);
        case SNDCTL_TMR_TEMPO:
-               debug_printk(("timer tempo\n"));
                if (get_user(value, arg))
                        return -EFAULT;
                return snd_seq_oss_timer_tempo(timer, value);
        case SNDCTL_TMR_TIMEBASE:
-               debug_printk(("timer timebase\n"));
                if (get_user(value, arg))
                        return -EFAULT;
                if (value < MIN_OSS_TIMEBASE)
@@ -276,7 +270,6 @@ snd_seq_oss_timer_ioctl(struct seq_oss_timer *timer, unsigned int cmd, int __use
        case SNDCTL_TMR_METRONOME:
        case SNDCTL_TMR_SELECT:
        case SNDCTL_TMR_SOURCE:
-               debug_printk(("timer XXX\n"));
                /* not supported */
                return 0;
        }
index 4dc6bae80e15b92a005325f845f0cc16fcd67ce0..9ca5e647e54bf80a7a68552b0ade15ae4f5599cb 100644 (file)
@@ -123,7 +123,7 @@ static inline int snd_seq_write_pool_allocated(struct snd_seq_client *client)
 static struct snd_seq_client *clientptr(int clientid)
 {
        if (clientid < 0 || clientid >= SNDRV_SEQ_MAX_CLIENTS) {
-               snd_printd("Seq: oops. Trying to get pointer to client %d\n",
+               pr_debug("ALSA: seq: oops. Trying to get pointer to client %d\n",
                           clientid);
                return NULL;
        }
@@ -136,7 +136,7 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid)
        struct snd_seq_client *client;
 
        if (clientid < 0 || clientid >= SNDRV_SEQ_MAX_CLIENTS) {
-               snd_printd("Seq: oops. Trying to get pointer to client %d\n",
+               pr_debug("ALSA: seq: oops. Trying to get pointer to client %d\n",
                           clientid);
                return NULL;
        }
@@ -291,8 +291,8 @@ static void seq_free_client(struct snd_seq_client * client)
        mutex_lock(&register_mutex);
        switch (client->type) {
        case NO_CLIENT:
-               snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n",
-                          client->number);
+               pr_warn("ALSA: seq: Trying to free unused client %d\n",
+                       client->number);
                break;
        case USER_CLIENT:
        case KERNEL_CLIENT:
@@ -301,7 +301,7 @@ static void seq_free_client(struct snd_seq_client * client)
                break;
 
        default:
-               snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n",
+               pr_err("ALSA: seq: Trying to free client %d with undefined type = %d\n",
                           client->number, client->type);
        }
        mutex_unlock(&register_mutex);
@@ -773,7 +773,7 @@ static int broadcast_event(struct snd_seq_client *client,
 static int multicast_event(struct snd_seq_client *client, struct snd_seq_event *event,
                           int atomic, int hop)
 {
-       snd_printd("seq: multicast not supported yet.\n");
+       pr_debug("ALSA: seq: multicast not supported yet.\n");
        return 0; /* ignored */
 }
 #endif /* SUPPORT_BROADCAST */
@@ -794,7 +794,7 @@ static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_e
 
        hop++;
        if (hop >= SNDRV_SEQ_MAX_HOPS) {
-               snd_printd("too long delivery path (%d:%d->%d:%d)\n",
+               pr_debug("ALSA: seq: too long delivery path (%d:%d->%d:%d)\n",
                           event->source.client, event->source.port,
                           event->dest.client, event->dest.port);
                return -EMLINK;
@@ -2196,7 +2196,7 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd,
                if (p->cmd == cmd)
                        return p->func(client, arg);
        }
-       snd_printd("seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
+       pr_debug("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
                   cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
        return -ENOTTY;
 }
index 040c60e1da28f346aa049737802a43ce853940d3..91a786a783e1e7cd563f516df09b9c94e64214eb 100644 (file)
@@ -168,7 +168,7 @@ void snd_seq_device_load_drivers(void)
 
 /*
  * register a sequencer device
- * card = card info (NULL allowed)
+ * card = card info
  * device = device number (if any)
  * id = id of driver
  * result = return pointer (NULL allowed if unnecessary)
@@ -325,7 +325,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
                return -ENOMEM;
        }
        if (ops->driver & DRIVER_LOADED) {
-               snd_printk(KERN_WARNING "driver_register: driver '%s' already exists\n", id);
+               pr_warn("ALSA: seq: driver_register: driver '%s' already exists\n", id);
                unlock_driver(ops);
                snd_seq_autoload_unlock();
                return -EBUSY;
@@ -398,7 +398,7 @@ int snd_seq_device_unregister_driver(char *id)
                return -ENXIO;
        if (! (ops->driver & DRIVER_LOADED) ||
            (ops->driver & DRIVER_LOCKED)) {
-               snd_printk(KERN_ERR "driver_unregister: cannot unload driver '%s': status=%x\n",
+               pr_err("ALSA: seq: driver_unregister: cannot unload driver '%s': status=%x\n",
                           id, ops->driver);
                unlock_driver(ops);
                return -EBUSY;
@@ -413,7 +413,7 @@ int snd_seq_device_unregister_driver(char *id)
 
        ops->driver = 0;
        if (ops->num_init_devices > 0)
-               snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n",
+               pr_err("ALSA: seq: free_driver: init_devices > 0!! (%d)\n",
                           ops->num_init_devices);
        mutex_unlock(&ops->reg_mutex);
 
@@ -459,7 +459,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
        if (dev->status != SNDRV_SEQ_DEVICE_FREE)
                return 0; /* already initialized */
        if (ops->argsize != dev->argsize) {
-               snd_printk(KERN_ERR "incompatible device '%s' for plug-in '%s' (%d %d)\n",
+               pr_err("ALSA: seq: incompatible device '%s' for plug-in '%s' (%d %d)\n",
                           dev->name, ops->id, ops->argsize, dev->argsize);
                return -EINVAL;
        }
@@ -467,7 +467,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
                dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
                ops->num_init_devices++;
        } else {
-               snd_printk(KERN_ERR "init_device failed: %s: %s\n",
+               pr_err("ALSA: seq: init_device failed: %s: %s\n",
                           dev->name, dev->id);
        }
 
@@ -486,7 +486,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
        if (dev->status != SNDRV_SEQ_DEVICE_REGISTERED)
                return 0; /* not registered */
        if (ops->argsize != dev->argsize) {
-               snd_printk(KERN_ERR "incompatible device '%s' for plug-in '%s' (%d %d)\n",
+               pr_err("ALSA: seq: incompatible device '%s' for plug-in '%s' (%d %d)\n",
                           dev->name, ops->id, ops->argsize, dev->argsize);
                return -EINVAL;
        }
@@ -495,7 +495,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
                dev->driver_data = NULL;
                ops->num_init_devices--;
        } else {
-               snd_printk(KERN_ERR "free_device failed: %s: %s\n",
+               pr_err("ALSA: seq: free_device failed: %s: %s\n",
                           dev->name, dev->id);
        }
 
@@ -559,7 +559,7 @@ static void __exit alsa_seq_device_exit(void)
        snd_info_free_entry(info_entry);
 #endif
        if (num_ops)
-               snd_printk(KERN_ERR "drivers not released (%d)\n", num_ops);
+               pr_err("ALSA: seq: drivers not released (%d)\n", num_ops);
 }
 
 module_init(alsa_seq_device_init)
index dbc55071679081568e6e3e89e256d78eccc74b55..ec667f158f192c4467e020164ecd4adf30a5ce04 100644 (file)
@@ -198,7 +198,7 @@ register_client(void)
        int i;
 
        if (ports < 1) {
-               snd_printk(KERN_ERR "invalid number of ports %d\n", ports);
+               pr_err("ALSA: seq_dummy: invalid number of ports %d\n", ports);
                return -EINVAL;
        }
 
index 0d75afa786bc6ffebe8ffd8dc5bde065397c00a8..559989992bef6ba7f35f7c63731bb6d40b5bd463 100644 (file)
@@ -34,7 +34,7 @@ struct snd_seq_fifo *snd_seq_fifo_new(int poolsize)
 
        f = kzalloc(sizeof(*f), GFP_KERNEL);
        if (f == NULL) {
-               snd_printd("malloc failed for snd_seq_fifo_new() \n");
+               pr_debug("ALSA: seq: malloc failed for snd_seq_fifo_new() \n");
                return NULL;
        }
 
index 2cfe50c71a9d3d62b580f5132a8faf154689b30d..3b693e924db745c0ec8be74171bb189f17dfc53d 100644 (file)
@@ -31,12 +31,12 @@ void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)
        int max_count = 5 * HZ;
 
        if (atomic_read(lockp) < 0) {
-               printk(KERN_WARNING "seq_lock: lock trouble [counter = %d] in %s:%d\n", atomic_read(lockp), file, line);
+               pr_warn("ALSA: seq_lock: lock trouble [counter = %d] in %s:%d\n", atomic_read(lockp), file, line);
                return;
        }
        while (atomic_read(lockp) > 0) {
                if (max_count == 0) {
-                       snd_printk(KERN_WARNING "seq_lock: timeout [%d left] in %s:%d\n", atomic_read(lockp), file, line);
+                       pr_warn("ALSA: seq_lock: timeout [%d left] in %s:%d\n", atomic_read(lockp), file, line);
                        break;
                }
                schedule_timeout_uninterruptible(1);
index f478f770bf5213f11663bad4041ad256664e6fe6..1e206de0c2dd1f904b8b6f402e8d03733b6ed81a 100644 (file)
@@ -236,7 +236,7 @@ static int snd_seq_cell_alloc(struct snd_seq_pool *pool,
        init_waitqueue_entry(&wait, current);
        spin_lock_irqsave(&pool->lock, flags);
        if (pool->ptr == NULL) {        /* not initialized */
-               snd_printd("seq: pool is not initialized\n");
+               pr_debug("ALSA: seq: pool is not initialized\n");
                err = -EINVAL;
                goto __error;
        }
@@ -388,7 +388,7 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
 
        pool->ptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size);
        if (pool->ptr == NULL) {
-               snd_printd("seq: malloc for sequencer events failed\n");
+               pr_debug("ALSA: seq: malloc for sequencer events failed\n");
                return -ENOMEM;
        }
 
@@ -431,7 +431,7 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)
 
        while (atomic_read(&pool->counter) > 0) {
                if (max_count == 0) {
-                       snd_printk(KERN_WARNING "snd_seq_pool_done timeout: %d cells remain\n", atomic_read(&pool->counter));
+                       pr_warn("ALSA: snd_seq_pool_done timeout: %d cells remain\n", atomic_read(&pool->counter));
                        break;
                }
                schedule_timeout_uninterruptible(1);
@@ -464,7 +464,7 @@ struct snd_seq_pool *snd_seq_pool_new(int poolsize)
        /* create pool block */
        pool = kzalloc(sizeof(*pool), GFP_KERNEL);
        if (pool == NULL) {
-               snd_printd("seq: malloc failed for pool\n");
+               pr_debug("ALSA: seq: malloc failed for pool\n");
                return NULL;
        }
        spin_lock_init(&pool->lock);
index 64069dbf89ca383bfb8500cedf90ed9959f29fa4..3e05c55a28801a423411cc5c61b7d9d57096ce29 100644 (file)
@@ -121,7 +121,7 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, i
        runtime = substream->runtime;
        if ((tmp = runtime->avail) < count) {
                if (printk_ratelimit())
-                       snd_printk(KERN_ERR "MIDI output buffer overrun\n");
+                       pr_err("ALSA: seq_midi: MIDI output buffer overrun\n");
                return -ENOMEM;
        }
        if (snd_rawmidi_kernel_write(substream, buf, count) < count)
@@ -145,7 +145,7 @@ static int event_process_midi(struct snd_seq_event *ev, int direct,
        if (ev->type == SNDRV_SEQ_EVENT_SYSEX) {        /* special case, to save space */
                if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARIABLE) {
                        /* invalid event */
-                       snd_printd("seq_midi: invalid sysex event flags = 0x%x\n", ev->flags);
+                       pr_debug("ALSA: seq_midi: invalid sysex event flags = 0x%x\n", ev->flags);
                        return 0;
                }
                snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)dump_midi, substream);
@@ -189,7 +189,7 @@ static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribe
                                           msynth->subdevice,
                                           SNDRV_RAWMIDI_LFLG_INPUT,
                                           &msynth->input_rfile)) < 0) {
-               snd_printd("midi input open failed!!!\n");
+               pr_debug("ALSA: seq_midi: midi input open failed!!!\n");
                return err;
        }
        runtime = msynth->input_rfile.input->runtime;
@@ -231,7 +231,7 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info
                                           msynth->subdevice,
                                           SNDRV_RAWMIDI_LFLG_OUTPUT,
                                           &msynth->output_rfile)) < 0) {
-               snd_printd("midi output open failed!!!\n");
+               pr_debug("ALSA: seq_midi: midi output open failed!!!\n");
                return err;
        }
        memset(&params, 0, sizeof(params));
index 6f64471ddde3df24811e3c1d1b5998780843bbbe..9b6470cdcf246f6e89ecf428d84dee0a25ad361e 100644 (file)
@@ -89,7 +89,7 @@ snd_midi_process_event(struct snd_midi_op *ops,
        int dest_channel = 0;
 
        if (ev == NULL || chanset == NULL) {
-               snd_printd("ev or chanbase NULL (snd_midi_process_event)\n");
+               pr_debug("ALSA: seq_midi_emul: ev or chanbase NULL (snd_midi_process_event)\n");
                return;
        }
        if (chanset->channels == NULL)
@@ -98,7 +98,7 @@ snd_midi_process_event(struct snd_midi_op *ops,
        if (snd_seq_ev_is_channel_type(ev)) {
                dest_channel = ev->data.note.channel;
                if (dest_channel >= chanset->max_channels) {
-                       snd_printd("dest channel is %d, max is %d\n",
+                       pr_debug("ALSA: seq_midi_emul: dest channel is %d, max is %d\n",
                                   dest_channel, chanset->max_channels);
                        return;
                }
@@ -232,7 +232,7 @@ snd_midi_process_event(struct snd_midi_op *ops,
        case SNDRV_SEQ_EVENT_ECHO:
        not_yet:
        default:
-               /*snd_printd("Unimplemented event %d\n", ev->type);*/
+               /*pr_debug("ALSA: seq_midi_emul: Unimplemented event %d\n", ev->type);*/
                break;
        }
 }
index 9516e5ce3aadd8cb50e857a187a469284cb91550..794a341bf0e560d7d5b69d37dc665fd9e571b294 100644 (file)
@@ -135,14 +135,14 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
                return NULL;
 
        if (client->num_ports >= SNDRV_SEQ_MAX_PORTS - 1) {
-               snd_printk(KERN_WARNING "too many ports for client %d\n", client->number);
+               pr_warn("ALSA: seq: too many ports for client %d\n", client->number);
                return NULL;
        }
 
        /* create a new port */
        new_port = kzalloc(sizeof(*new_port), GFP_KERNEL);
        if (! new_port) {
-               snd_printd("malloc failed for registering client port\n");
+               pr_debug("ALSA: seq: malloc failed for registering client port\n");
                return NULL;    /* failure, out of memory */
        }
        /* init port data */
index 29896ab23403a219283920ab0dd204e545047440..021b02bc9330f5770fa2ef0072ed844de25b677a 100644 (file)
@@ -60,7 +60,7 @@ struct snd_seq_prioq *snd_seq_prioq_new(void)
 
        f = kzalloc(sizeof(*f), GFP_KERNEL);
        if (f == NULL) {
-               snd_printd("oops: malloc failed for snd_seq_prioq_new()\n");
+               pr_debug("ALSA: seq: malloc failed for snd_seq_prioq_new()\n");
                return NULL;
        }
        
@@ -79,7 +79,7 @@ void snd_seq_prioq_delete(struct snd_seq_prioq **fifo)
        *fifo = NULL;
 
        if (f == NULL) {
-               snd_printd("oops: snd_seq_prioq_delete() called with NULL prioq\n");
+               pr_debug("ALSA: seq: snd_seq_prioq_delete() called with NULL prioq\n");
                return;
        }
 
@@ -197,7 +197,7 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f,
                cur = cur->next;
                if (! --count) {
                        spin_unlock_irqrestore(&f->lock, flags);
-                       snd_printk(KERN_ERR "cannot find a pointer.. infinite loop?\n");
+                       pr_err("ALSA: seq: cannot find a pointer.. infinite loop?\n");
                        return -EINVAL;
                }
        }
@@ -223,7 +223,7 @@ struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f)
        unsigned long flags;
 
        if (f == NULL) {
-               snd_printd("oops: snd_seq_prioq_cell_in() called with NULL prioq\n");
+               pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n");
                return NULL;
        }
        spin_lock_irqsave(&f->lock, flags);
@@ -248,7 +248,7 @@ struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f)
 int snd_seq_prioq_avail(struct snd_seq_prioq * f)
 {
        if (f == NULL) {
-               snd_printd("oops: snd_seq_prioq_cell_in() called with NULL prioq\n");
+               pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n");
                return 0;
        }
        return f->cells;
@@ -259,7 +259,7 @@ int snd_seq_prioq_avail(struct snd_seq_prioq * f)
 struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq * f)
 {
        if (f == NULL) {
-               snd_printd("oops: snd_seq_prioq_cell_in() called with NULL prioq\n");
+               pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n");
                return NULL;
        }
        return f->head;
@@ -321,7 +321,7 @@ void snd_seq_prioq_leave(struct snd_seq_prioq * f, int client, int timestamp)
                        freeprev = cell;
                } else {
 #if 0
-                       printk(KERN_DEBUG "type = %i, source = %i, dest = %i, "
+                       pr_debug("ALSA: seq: type = %i, source = %i, dest = %i, "
                               "client = %i\n",
                                cell->event.type,
                                cell->event.source.client,
index f9077361c119d1a4a5eed6135a3d2e4042c812e5..aad4878cee5579f2556524db0f61a069cc07fef5 100644 (file)
@@ -112,7 +112,7 @@ static struct snd_seq_queue *queue_new(int owner, int locked)
 
        q = kzalloc(sizeof(*q), GFP_KERNEL);
        if (q == NULL) {
-               snd_printd("malloc failed for snd_seq_queue_new()\n");
+               pr_debug("ALSA: seq: malloc failed for snd_seq_queue_new()\n");
                return NULL;
        }
 
index 24d44b2f61acda72453e5be78958aae15b8afccf..e73605393eee5351bed9d4472150fd0b63335e5d 100644 (file)
@@ -57,7 +57,7 @@ struct snd_seq_timer *snd_seq_timer_new(void)
        
        tmr = kzalloc(sizeof(*tmr), GFP_KERNEL);
        if (tmr == NULL) {
-               snd_printd("malloc failed for snd_seq_timer_new() \n");
+               pr_debug("ALSA: seq: malloc failed for snd_seq_timer_new() \n");
                return NULL;
        }
        spin_lock_init(&tmr->lock);
@@ -78,7 +78,7 @@ void snd_seq_timer_delete(struct snd_seq_timer **tmr)
        *tmr = NULL;
 
        if (t == NULL) {
-               snd_printd("oops: snd_seq_timer_delete() called with NULL timer\n");
+               pr_debug("ALSA: seq: snd_seq_timer_delete() called with NULL timer\n");
                return;
        }
        t->running = 0;
@@ -199,7 +199,7 @@ int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq)
                /* refuse to change ppq on running timers */
                /* because it will upset the song position (ticks) */
                spin_unlock_irqrestore(&tmr->lock, flags);
-               snd_printd("seq: cannot change ppq of a running timer\n");
+               pr_debug("ALSA: seq: cannot change ppq of a running timer\n");
                return -EBUSY;
        }
 
@@ -252,7 +252,7 @@ int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew,
 
        /* FIXME */
        if (base != SKEW_BASE) {
-               snd_printd("invalid skew base 0x%x\n", base);
+               pr_debug("ALSA: seq: invalid skew base 0x%x\n", base);
                return -EINVAL;
        }
        spin_lock_irqsave(&tmr->lock, flags);
@@ -292,7 +292,7 @@ int snd_seq_timer_open(struct snd_seq_queue *q)
                }
        }
        if (err < 0) {
-               snd_printk(KERN_ERR "seq fatal error: cannot create timer (%i)\n", err);
+               pr_err("ALSA: seq fatal error: cannot create timer (%i)\n", err);
                return err;
        }
        t->callback = snd_seq_timer_interrupt;
index 4b50e604276d8dec6adb47bee6b870a1fe52f8c0..56e0f4cd3f8299837053961747a64b8a736b3867 100644 (file)
@@ -446,7 +446,7 @@ static int snd_virmidi_dev_register(struct snd_rawmidi *rmidi)
                /* should check presence of port more strictly.. */
                break;
        default:
-               snd_printk(KERN_ERR "seq_mode is not set: %d\n", rdev->seq_mode);
+               pr_err("ALSA: seq_virmidi: seq_mode is not set: %d\n", rdev->seq_mode);
                return -EINVAL;
        }
        return 0;
index 437c25ea640363b5d38d8214e873cb236f1aec43..38ad1a0dd3f70fc68435309dd75b1d4c45bf3c42 100644 (file)
@@ -118,7 +118,7 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
        if (mreg && mreg->type == type) {
                private_data = mreg->private_data;
                if (private_data && mreg->card_ptr)
-                       atomic_inc(&mreg->card_ptr->refcount);
+                       get_device(&mreg->card_ptr->card_dev);
        } else
                private_data = NULL;
        mutex_unlock(&sound_mutex);
@@ -355,22 +355,25 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
 
 EXPORT_SYMBOL(snd_unregister_device);
 
-int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
-                             struct device_attribute *attr)
+/* get the assigned device to the given type and device number;
+ * the caller needs to release it via put_device() after using it
+ */
+struct device *snd_get_device(int type, struct snd_card *card, int dev)
 {
-       int minor, ret = -EINVAL;
-       struct device *d;
+       int minor;
+       struct device *d = NULL;
 
        mutex_lock(&sound_mutex);
        minor = find_snd_minor(type, card, dev);
-       if (minor >= 0 && (d = snd_minors[minor]->dev) != NULL)
-               ret = device_create_file(d, attr);
+       if (minor >= 0) {
+               d = snd_minors[minor]->dev;
+               if (d)
+                       get_device(d);
+       }
        mutex_unlock(&sound_mutex);
-       return ret;
-
+       return d;
 }
-
-EXPORT_SYMBOL(snd_add_device_sysfs_file);
+EXPORT_SYMBOL(snd_get_device);
 
 #ifdef CONFIG_PROC_FS
 /*
@@ -458,7 +461,7 @@ static int __init alsa_sound_init(void)
        snd_major = major;
        snd_ecards_limit = cards_limit;
        if (register_chrdev(major, "alsa", &snd_fops)) {
-               snd_printk(KERN_ERR "unable to register native major device number %d\n", major);
+               pr_err("ALSA core: unable to register native major device number %d\n", major);
                return -EIO;
        }
        if (snd_info_init() < 0) {
@@ -467,7 +470,7 @@ static int __init alsa_sound_init(void)
        }
        snd_info_minor_register();
 #ifndef MODULE
-       printk(KERN_INFO "Advanced Linux Sound Architecture Driver Initialized.\n");
+       pr_info("Advanced Linux Sound Architecture Driver Initialized.\n");
 #endif
        return 0;
 }
index 726a49ac97253d50634313265abc5699480c7e71..573a65eb2b796961ed72b2999dc4b63fb05326ef 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifdef CONFIG_SND_OSSEMUL
 
-#if !defined(CONFIG_SOUND) && !(defined(MODULE) && defined(CONFIG_SOUND_MODULE))
+#if !IS_ENABLED(CONFIG_SOUND)
 #error "Enable the OSS soundcore multiplexer (CONFIG_SOUND) in the kernel."
 #endif
 
@@ -55,7 +55,7 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
        if (mreg && mreg->type == type) {
                private_data = mreg->private_data;
                if (private_data && mreg->card_ptr)
-                       atomic_inc(&mreg->card_ptr->refcount);
+                       get_device(&mreg->card_ptr->card_dev);
        } else
                private_data = NULL;
        mutex_unlock(&sound_oss_mutex);
@@ -105,8 +105,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
 }
 
 int snd_register_oss_device(int type, struct snd_card *card, int dev,
-                           const struct file_operations *f_ops, void *private_data,
-                           const char *name)
+                           const struct file_operations *f_ops, void *private_data)
 {
        int minor = snd_oss_kernel_minor(type, card, dev);
        int minor_unit;
index 6ddcf06f52f9a0c710cfbd65157915e5d90b14a4..cfd455a8ac1af366fb1ed63ae05497035b528b29 100644 (file)
@@ -35,9 +35,9 @@
 #include <sound/initval.h>
 #include <linux/kmod.h>
 
-#if defined(CONFIG_SND_HRTIMER) || defined(CONFIG_SND_HRTIMER_MODULE)
+#if IS_ENABLED(CONFIG_SND_HRTIMER)
 #define DEFAULT_TIMER_LIMIT 4
-#elif defined(CONFIG_SND_RTCTIMER) || defined(CONFIG_SND_RTCTIMER_MODULE)
+#elif IS_ENABLED(CONFIG_SND_RTCTIMER)
 #define DEFAULT_TIMER_LIMIT 2
 #else
 #define DEFAULT_TIMER_LIMIT 1
@@ -240,7 +240,8 @@ int snd_timer_open(struct snd_timer_instance **ti,
                /* open a slave instance */
                if (tid->dev_sclass <= SNDRV_TIMER_SCLASS_NONE ||
                    tid->dev_sclass > SNDRV_TIMER_SCLASS_OSS_SEQUENCER) {
-                       snd_printd("invalid slave class %i\n", tid->dev_sclass);
+                       pr_debug("ALSA: timer: invalid slave class %i\n",
+                                tid->dev_sclass);
                        return -EINVAL;
                }
                mutex_lock(&register_mutex);
@@ -774,7 +775,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid,
                *rtimer = NULL;
        timer = kzalloc(sizeof(*timer), GFP_KERNEL);
        if (timer == NULL) {
-               snd_printk(KERN_ERR "timer: cannot allocate\n");
+               pr_err("ALSA: timer: cannot allocate\n");
                return -ENOMEM;
        }
        timer->tmr_class = tid->dev_class;
@@ -813,7 +814,7 @@ static int snd_timer_free(struct snd_timer *timer)
        if (! list_empty(&timer->open_list_head)) {
                struct list_head *p, *n;
                struct snd_timer_instance *ti;
-               snd_printk(KERN_WARNING "timer %p is busy?\n", timer);
+               pr_warn("ALSA: timer %p is busy?\n", timer);
                list_for_each_safe(p, n, &timer->open_list_head) {
                        list_del_init(p);
                        ti = list_entry(p, struct snd_timer_instance, open_list);
@@ -1955,12 +1956,10 @@ static int __init alsa_timer_init(void)
 #endif
 
        if ((err = snd_timer_register_system()) < 0)
-               snd_printk(KERN_ERR "unable to register system timer (%i)\n",
-                          err);
+               pr_err("ALSA: unable to register system timer (%i)\n", err);
        if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0,
                                       &snd_timer_f_ops, NULL, "timer")) < 0)
-               snd_printk(KERN_ERR "unable to register timer device (%i)\n",
-                          err);
+               pr_err("ALSA: unable to register timer device (%i)\n", err);
        snd_timer_proc_init();
        return 0;
 }
index 842a97d5fc3a1ec104fcd691597e07095c3fa76d..6c58e6f73a013bd33e47cc9a7ea8c1b46b7f17df 100644 (file)
@@ -101,7 +101,7 @@ static int slave_init(struct link_slave *slave)
        if (slave->info.count > 2  ||
            (slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER &&
             slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) {
-               snd_printk(KERN_ERR "invalid slave element\n");
+               pr_err("ALSA: vmaster: invalid slave element\n");
                kfree(uinfo);
                return -EINVAL;
        }
index f7589923effa08f25094b87423e559414e7f8aaf..2a16c86a60b3c8bac7dbf3697c17f4bcfa013ee3 100644 (file)
@@ -1142,8 +1142,8 @@ static int loopback_probe(struct platform_device *devptr)
        int dev = devptr->id;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct loopback), &card);
+       err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct loopback), &card);
        if (err < 0)
                return err;
        loopback = card->private_data;
index 915b4d7fbb23fe8c1309e05c17ff525a6d7e7d78..fab90bd2bd5151ae1fcf44f8a7f9b444e1e323fe 100644 (file)
@@ -1054,8 +1054,8 @@ static int snd_dummy_probe(struct platform_device *devptr)
        int idx, err;
        int dev = devptr->id;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_dummy), &card);
+       err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_dummy), &card);
        if (err < 0)
                return err;
        dummy = card->private_data;
@@ -1114,8 +1114,6 @@ static int snd_dummy_probe(struct platform_device *devptr)
 
        dummy_proc_init(dummy);
 
-       snd_card_set_dev(card, &devptr->dev);
-
        err = snd_card_register(card);
        if (err == 0) {
                platform_set_drvdata(devptr, card);
index 95ea4a153ea43afb916de2ad86ffd2990650d355..33ed76530d0bc31402dae0c77405934ff1209b66 100644 (file)
@@ -1280,7 +1280,8 @@ static int snd_ml403_ac97cr_probe(struct platform_device *pfdev)
        if (!enable[dev])
                return -ENOENT;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pfdev->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        err = snd_ml403_ac97cr_create(card, pfdev, &ml403_ac97cr);
@@ -1310,8 +1311,6 @@ static int snd_ml403_ac97cr_probe(struct platform_device *pfdev)
                (unsigned long)ml403_ac97cr->port, ml403_ac97cr->irq,
                ml403_ac97cr->capture_irq, dev + 1);
 
-       snd_card_set_dev(card, &pfdev->dev);
-
        err = snd_card_register(card);
        if (err < 0) {
                snd_card_free(card);
index 90a3a7b38a2a01eee908c7975f1dedce783a2948..83014b83a44e32d1979413bc226a78b6ef14f466 100644 (file)
@@ -64,7 +64,8 @@ static struct platform_device *platform_devices[SNDRV_CARDS];
 static int pnp_registered;
 static unsigned int snd_mpu401_devices;
 
-static int snd_mpu401_create(int dev, struct snd_card **rcard)
+static int snd_mpu401_create(struct device *devptr, int dev,
+                            struct snd_card **rcard)
 {
        struct snd_card *card;
        int err;
@@ -73,7 +74,8 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard)
                snd_printk(KERN_ERR "the uart_enter option is obsolete; remove it\n");
 
        *rcard = NULL;
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        strcpy(card->driver, "MPU-401 UART");
@@ -114,10 +116,9 @@ static int snd_mpu401_probe(struct platform_device *devptr)
                snd_printk(KERN_ERR "specify or disable IRQ\n");
                return -EINVAL;
        }
-       err = snd_mpu401_create(dev, &card);
+       err = snd_mpu401_create(&devptr->dev, dev, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, &devptr->dev);
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
                return err;
@@ -194,14 +195,13 @@ static int snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev,
                err = snd_mpu401_pnp(dev, pnp_dev, id);
                if (err < 0)
                        return err;
-               err = snd_mpu401_create(dev, &card);
+               err = snd_mpu401_create(&pnp_dev->dev, dev, &card);
                if (err < 0)
                        return err;
                if ((err = snd_card_register(card)) < 0) {
                        snd_card_free(card);
                        return err;
                }
-               snd_card_set_dev(card, &pnp_dev->dev);
                pnp_set_drvdata(pnp_dev, card);
                snd_mpu401_devices++;
                ++dev;
index e5ec7eb27dec5f873c36b6c6f5e3e79a44fdddfe..4b66c7f22af797332059e2a1ef57ae7c0e6a9f06 100644 (file)
@@ -697,7 +697,8 @@ static int snd_mtpav_probe(struct platform_device *dev)
        int err;
        struct mtpav *mtp_card;
 
-       err = snd_card_create(index, id, THIS_MODULE, sizeof(*mtp_card), &card);
+       err = snd_card_new(&dev->dev, index, id, THIS_MODULE,
+                          sizeof(*mtp_card), &card);
        if (err < 0)
                return err;
 
@@ -732,7 +733,6 @@ static int snd_mtpav_probe(struct platform_device *dev)
 
        snd_mtpav_portscan(mtp_card);
 
-       snd_card_set_dev(card, &dev->dev);
        err = snd_card_register(mtp_card->card);
        if (err < 0)
                goto __error;
index 4e0dd22ba08eddbd7aa744c12069d4417d4f7307..f5fd448dbc5700b96f061c1800ea369e8bcbf9f1 100644 (file)
@@ -959,7 +959,8 @@ static int snd_mts64_probe(struct platform_device *pdev)
        if ((err = snd_mts64_probe_port(p)) < 0)
                return err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
                snd_printd("Cannot create card\n");
                return err;
@@ -1009,8 +1010,6 @@ static int snd_mts64_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, card);
 
-       snd_card_set_dev(card, &pdev->dev);
-
        /* At this point card will be usable */
        if ((err = snd_card_register(card)) < 0) {
                snd_printd("Cannot register card\n");
index 33d9a857a2625e443808df63e0d0092632871562..f66af5884c4066cadcad107378e8ca30b32f0f69 100644 (file)
@@ -501,10 +501,8 @@ int snd_opl3_hwdep_new(struct snd_opl3 * opl3,
        hw->private_data = opl3;
        hw->exclusive = 1;
 #ifdef CONFIG_SND_OSSEMUL
-       if (device == 0) {
+       if (device == 0)
                hw->oss_type = SNDRV_OSS_DEVICE_TYPE_DMFM;
-               sprintf(hw->oss_dev, "dmfm%i", card->number);
-       }
 #endif
        strcpy(hw->name, hw->id);
        switch (opl3->hardware & OPL3_HW_MASK) {
index 742a4b642fd9ea19adfcd195244c8fbc9bfa5fb1..ddcc1a325a618124b9206a9f0c0c9a23774938ed 100644 (file)
@@ -24,7 +24,7 @@
 #include <sound/opl3.h>
 #include <sound/asound_fm.h>
 
-#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
+#if IS_ENABLED(CONFIG_SND_SEQUENCER)
 #define OPL3_SUPPORT_SYNTH
 #endif
 
index 328bd29264ce555e048da881af2dcc7e60e289d6..36808cdab06f23b8869a0bcf52336539e737a3cd 100644 (file)
@@ -105,7 +105,7 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
        hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        pcsp_chip.timer.function = pcsp_do_timer;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -127,8 +127,6 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
                return err;
        }
 
-       snd_card_set_dev(pcsp_chip.card, dev);
-
        strcpy(card->driver, "PC-Speaker");
        strcpy(card->shortname, "pcsp");
        sprintf(card->longname, "Internal PC-Speaker at port 0x%x",
index b874b0ad99cd2ba7cd8fea316c53ad225a2220d1..0ecf8a453e0112cb56a76ec2035ad2c196fec87f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/input.h>
 #include <asm/io.h>
 #include "pcsp.h"
+#include "pcsp_input.h"
 
 static void pcspkr_do_sound(unsigned int count)
 {
index 991018df7131d957341ed11e2c5bde91ea34d8cd..78ccfa4555272fa9e1fdd3a266b1ab6c7a7db425 100644 (file)
@@ -748,7 +748,8 @@ static int snd_portman_probe(struct platform_device *pdev)
        if ((err = snd_portman_probe_port(p)) < 0)
                return err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
                snd_printd("Cannot create card\n");
                return err;
@@ -798,8 +799,6 @@ static int snd_portman_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, card);
 
-       snd_card_set_dev(card, &pdev->dev);
-
        /* At this point card will be usable */
        if ((err = snd_card_register(card)) < 0) {
                snd_printd("Cannot register card\n");
index e0bf5e77b43ae757d1f607b5c86a3636a4e371df..9ad4414fa25cf06b89abc1399584b134bb9a4970 100644 (file)
@@ -942,7 +942,8 @@ static int snd_serial_probe(struct platform_device *devptr)
                return -ENODEV;
        }
 
-       err  = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err  = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
+                           0, &card);
        if (err < 0)
                return err;
 
@@ -969,8 +970,6 @@ static int snd_serial_probe(struct platform_device *devptr)
                uart->base,
                uart->irq);
 
-       snd_card_set_dev(card, &devptr->dev);
-
        if ((err = snd_card_register(card)) < 0)
                goto _err;
 
index ace3879e8d9649fb95a8d65a4c3481e0ce0e49a4..b178724295f37f4a29d0a0a51494af6e763589c8 100644 (file)
@@ -90,8 +90,8 @@ static int snd_virmidi_probe(struct platform_device *devptr)
        int idx, err;
        int dev = devptr->id;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_card_virmidi), &card);
+       err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_card_virmidi), &card);
        if (err < 0)
                return err;
        vmidi = card->private_data;
@@ -118,8 +118,6 @@ static int snd_virmidi_probe(struct platform_device *devptr)
        strcpy(card->shortname, "VirMIDI");
        sprintf(card->longname, "Virtual MIDI Card %i", dev + 1);
 
-       snd_card_set_dev(card, &devptr->dev);
-
        if ((err = snd_card_register(card)) == 0) {
                platform_set_drvdata(devptr, card);
                return 0;
index c0aa64941cee0bd927450a6b69314d14f2f02bce..0c3948630cf7ec2d5e4b5829f089e422121f93f8 100644 (file)
@@ -1326,10 +1326,10 @@ static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
        if (err < 0)
                return err;
 
-       err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*dice), &card);
+       err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
+                          sizeof(*dice), &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, &unit->device);
 
        dice = card->private_data;
        dice->card = card;
index fd42e6b315e69d90e39deda16d553fc0baf97395..7ac94439e7584d8e973796dbc07a7032909f64c9 100644 (file)
@@ -631,10 +631,10 @@ static int isight_probe(struct fw_unit *unit,
        struct isight *isight;
        int err;
 
-       err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card);
+       err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
+                          sizeof(*isight), &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, &unit->device);
 
        isight = card->private_data;
        isight->card = card;
index 858023cf4298c0cbf6022e16824ab26f085f2b59..2dba848a781fd19f1fb2ca8c25bf2ff56fb0eabd 100644 (file)
@@ -391,10 +391,10 @@ static int scs_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
        struct scs *scs;
        int err;
 
-       err = snd_card_create(-16, NULL, THIS_MODULE, sizeof(*scs), &card);
+       err = snd_card_new(&unit->device, -16, NULL, THIS_MODULE,
+                          sizeof(*scs), &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, &unit->device);
 
        scs = card->private_data;
        scs->card = card;
index cc8bc3a51bc147ab7a13c0a38ec84134b55f9da3..9f7ef219b109d52037c89672a608df990bab0c5c 100644 (file)
@@ -668,10 +668,10 @@ static int fwspk_probe(struct fw_unit *unit,
        u32 firmware;
        int err;
 
-       err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card);
+       err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
+                          sizeof(*fwspk), &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, &unit->device);
 
        fwspk = card->private_data;
        fwspk->card = card;
index e04e750a77ed4bac80875bf05e979bbd946f2219..1a3a6fa27158b0096de715c8e322ec0cddeb62ec 100644 (file)
@@ -98,7 +98,7 @@ int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read,
                        AK4113_CINT | AK4113_STC);
        chip->rcs1 = reg_read(chip, AK4113_REG_RCS1);
        chip->rcs2 = reg_read(chip, AK4113_REG_RCS2);
-       err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+       err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops);
        if (err < 0)
                goto __fail;
 
index 15ae0250eacec065d90c4093127f4604bec84a99..c7f56339415d31052812e1c3d6066c275298411e 100644 (file)
@@ -111,7 +111,7 @@ int snd_ak4114_create(struct snd_card *card,
        chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
        chip->rcs1 = reg_read(chip, AK4114_REG_RCS1);
 
-       if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
+       if ((err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops)) < 0)
                goto __fail;
 
        if (r_ak4114)
index 40e33c9f2b095f1eb7488729afe20f1f991d994f..88452e899bd94124ddffe1ad3485d7b9896aeddf 100644 (file)
@@ -62,7 +62,7 @@ static void reg_dump(struct ak4117 *ak4117)
 
 static void snd_ak4117_free(struct ak4117 *chip)
 {
-       del_timer(&chip->timer);
+       del_timer_sync(&chip->timer);
        kfree(chip);
 }
 
index 26ce26a5884d7254e6b61ca0f6fd1df2acba545c..f481a41e027eb132a2acfd1632f8351fe4daa8b6 100644 (file)
@@ -144,8 +144,9 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
        struct snd_opl3 *opl3;
        struct snd_timer *timer;
 
-       error = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                               sizeof(struct snd_ad1816a), &card);
+       error = snd_card_new(&pcard->card->dev,
+                            index[dev], id[dev], THIS_MODULE,
+                            sizeof(struct snd_ad1816a), &card);
        if (error < 0)
                return error;
        chip = card->private_data;
@@ -154,7 +155,6 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
                snd_card_free(card);
                return error;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
 
        if ((error = snd_ad1816a_create(card, port[dev],
                                        irq[dev],
index e3f455bd85cd55c12ac8d561ef0793ba96ab8c4f..093f22a464d7494e373bf6e64c5842613ea8f971 100644 (file)
@@ -91,7 +91,7 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n)
        struct snd_pcm *pcm;
        int error;
 
-       error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
+       error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
        if (error < 0)
                return error;
 
@@ -119,8 +119,6 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n)
        if (thinkpad[n])
                strcat(card->longname, " [Thinkpad]");
 
-       snd_card_set_dev(card, dev);
-
        error = snd_card_register(card);
        if (error < 0)
                goto out;
index 35659218710f93f1d738b327f4f43c650b8043cc..120c524bb2a05bd01d4704ccf443f20285bf5fe0 100644 (file)
@@ -53,7 +53,7 @@ static int snd_adlib_probe(struct device *dev, unsigned int n)
        struct snd_opl3 *opl3;
        int error;
 
-       error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
+       error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
        if (error < 0) {
                dev_err(dev, "could not create card\n");
                return error;
@@ -83,8 +83,6 @@ static int snd_adlib_probe(struct device *dev, unsigned int n)
                goto out;
        }
 
-       snd_card_set_dev(card, dev);
-
        error = snd_card_register(card);
        if (error < 0) {
                dev_err(dev, "could not register card\n");
index 10f08a18fe3ba7b9bd7789a343f40575a4a4cf43..32d01525211d34432229c1ca2f90bacc9ccf5665 100644 (file)
@@ -193,8 +193,9 @@ static int snd_card_als100_probe(int dev,
        struct snd_card_als100 *acard;
        struct snd_opl3 *opl3;
 
-       error = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                               sizeof(struct snd_card_als100), &card);
+       error = snd_card_new(&pcard->card->dev,
+                            index[dev], id[dev], THIS_MODULE,
+                            sizeof(struct snd_card_als100), &card);
        if (error < 0)
                return error;
        acard = card->private_data;
@@ -203,7 +204,6 @@ static int snd_card_als100_probe(int dev,
                snd_card_free(card);
                return error;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
 
        if (pid->driver_data == SB_HW_DT019X)
                dma16[dev] = -1;
index db301ff94ec2ec43611beb6a86c495fc6e475fa6..0ea75fc620725599b817736482dfef306f5de285 100644 (file)
@@ -184,8 +184,9 @@ static int snd_card_azt2320_probe(int dev,
        struct snd_wss *chip;
        struct snd_opl3 *opl3;
 
-       error = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                               sizeof(struct snd_card_azt2320), &card);
+       error = snd_card_new(&pcard->card->dev,
+                            index[dev], id[dev], THIS_MODULE,
+                            sizeof(struct snd_card_azt2320), &card);
        if (error < 0)
                return error;
        acard = card->private_data;
@@ -194,7 +195,6 @@ static int snd_card_azt2320_probe(int dev,
                snd_card_free(card);
                return error;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
 
        if ((error = snd_card_azt2320_enable_wss(port[dev]))) {
                snd_card_free(card);
index ab6b2dc043f1e399d3205ba802448433f61f357e..4778852a1201388645d15c54f4f67cbd2abd3142 100644 (file)
@@ -293,15 +293,14 @@ static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev)
        }
        outb(val, port);
 
-       err = snd_card_create(index[ndev], id[ndev], THIS_MODULE,
-                               sizeof(struct snd_cmi8328), &card);
+       err = snd_card_new(pdev, index[ndev], id[ndev], THIS_MODULE,
+                          sizeof(struct snd_cmi8328), &card);
        if (err < 0)
                return err;
        cmi = card->private_data;
        cmi->card = card;
        cmi->port = port;
        cmi->wss_cfg = val;
-       snd_card_set_dev(card, pdev);
 
        err = snd_wss_create(card, port + 4, -1, irq[ndev], dma1[ndev],
                        dma2[ndev], WSS_HW_DETECT, 0, &cmi->wss);
index 270b9659ef7f703790a65531fc0205ddfead3c3a..dfedfd85f205460095ad09b1f0086c8f25925ea9 100644 (file)
@@ -514,14 +514,15 @@ static int snd_cmi8330_resume(struct snd_card *card)
 
 #define PFX    "cmi8330: "
 
-static int snd_cmi8330_card_new(int dev, struct snd_card **cardp)
+static int snd_cmi8330_card_new(struct device *pdev, int dev,
+                               struct snd_card **cardp)
 {
        struct snd_card *card;
        struct snd_cmi8330 *acard;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_cmi8330), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_cmi8330), &card);
        if (err < 0) {
                snd_printk(KERN_ERR PFX "could not get a new card\n");
                return err;
@@ -635,10 +636,9 @@ static int snd_cmi8330_isa_probe(struct device *pdev,
        struct snd_card *card;
        int err;
 
-       err = snd_cmi8330_card_new(dev, &card);
+       err = snd_cmi8330_card_new(pdev, dev, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, pdev);
        if ((err = snd_cmi8330_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -698,7 +698,7 @@ static int snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
                               
-       res = snd_cmi8330_card_new(dev, &card);
+       res = snd_cmi8330_card_new(&pcard->card->dev, dev, &card);
        if (res < 0)
                return res;
        if ((res = snd_cmi8330_pnp(dev, card->private_data, pcard, pid)) < 0) {
@@ -706,7 +706,6 @@ static int snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
                snd_card_free(card);
                return res;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
        if ((res = snd_cmi8330_probe(card, dev)) < 0) {
                snd_card_free(card);
                return res;
index ba9a74eff3e0dda98644dbe13df9cdb505e3043f..7dba07a4343aecfbebbb2c97c43e47b87936e768 100644 (file)
@@ -95,7 +95,7 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n)
        struct snd_pcm *pcm;
        int error;
 
-       error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
+       error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
        if (error < 0)
                return error;
 
@@ -135,8 +135,6 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n)
                        dev_warn(dev, "MPU401 not detected\n");
        }
 
-       snd_card_set_dev(card, dev);
-
        error = snd_card_register(card);
        if (error < 0)
                goto out;
index 69614acb20520678ea0c58c5dbfb5a4a74563772..750f51c904fcb446b0726109516f04c1bd348bac 100644 (file)
@@ -364,13 +364,14 @@ static void snd_card_cs4236_free(struct snd_card *card)
        release_and_free_resource(acard->res_sb_port);
 }
 
-static int snd_cs423x_card_new(int dev, struct snd_card **cardp)
+static int snd_cs423x_card_new(struct device *pdev, int dev,
+                              struct snd_card **cardp)
 {
        struct snd_card *card;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_card_cs4236), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_card_cs4236), &card);
        if (err < 0)
                return err;
        card->private_free = snd_card_cs4236_free;
@@ -487,10 +488,9 @@ static int snd_cs423x_isa_probe(struct device *pdev,
        struct snd_card *card;
        int err;
 
-       err = snd_cs423x_card_new(dev, &card);
+       err = snd_cs423x_card_new(pdev, dev, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, pdev);
        if ((err = snd_cs423x_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -577,7 +577,7 @@ static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
                if (!strcmp(cdev->id[0].id, cid))
                        break;
        }
-       err = snd_cs423x_card_new(dev, &card);
+       err = snd_cs423x_card_new(&pdev->dev, dev, &card);
        if (err < 0)
                return err;
        err = snd_card_cs423x_pnp(dev, card->private_data, pdev, cdev);
@@ -586,7 +586,6 @@ static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
                snd_card_free(card);
                return err;
        }
-       snd_card_set_dev(card, &pdev->dev);
        if ((err = snd_cs423x_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -638,7 +637,7 @@ static int snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
 
-       res = snd_cs423x_card_new(dev, &card);
+       res = snd_cs423x_card_new(&pcard->card->dev, dev, &card);
        if (res < 0)
                return res;
        if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) {
@@ -647,7 +646,6 @@ static int snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
                snd_card_free(card);
                return res;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
        if ((res = snd_cs423x_probe(card, dev)) < 0) {
                snd_card_free(card);
                return res;
index cdcfb57f1f0a94226d2f131d1005117c33766627..76001fe0579da1942620ae97f1c0e8bed4aa67fa 100644 (file)
@@ -187,8 +187,8 @@ static int snd_es1688_isa_probe(struct device *dev, unsigned int n)
        struct snd_card *card;
        int error;
 
-       error = snd_card_create(index[n], id[n], THIS_MODULE,
-                               sizeof(struct snd_es1688), &card);
+       error = snd_card_new(dev, index[n], id[n], THIS_MODULE,
+                            sizeof(struct snd_es1688), &card);
        if (error < 0)
                return error;
 
@@ -196,8 +196,6 @@ static int snd_es1688_isa_probe(struct device *dev, unsigned int n)
        if (error < 0)
                goto out;
 
-       snd_card_set_dev(card, dev);
-
        error = snd_es1688_probe(card, n);
        if (error < 0)
                goto out;
@@ -274,8 +272,9 @@ static int snd_es968_pnp_detect(struct pnp_card_link *pcard,
        if (dev == SNDRV_CARDS)
                return -ENODEV;
 
-       error = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                               sizeof(struct snd_es1688), &card);
+       error = snd_card_new(&pcard->card->dev,
+                            index[dev], id[dev], THIS_MODULE,
+                            sizeof(struct snd_es1688), &card);
        if (error < 0)
                return error;
        chip = card->private_data;
@@ -285,7 +284,6 @@ static int snd_es968_pnp_detect(struct pnp_card_link *pcard,
                snd_card_free(card);
                return error;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
        error = snd_es1688_probe(card, dev);
        if (error < 0)
                return error;
index 12978b864c3ab52b8cc1388d24d15ead0fd4f690..1c16830af3d8cf73bfd3ff4042d070f556e53d25 100644 (file)
@@ -2105,10 +2105,11 @@ static int snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip,
 #define is_isapnp_selected(dev)                0
 #endif
 
-static int snd_es18xx_card_new(int dev, struct snd_card **cardp)
+static int snd_es18xx_card_new(struct device *pdev, int dev,
+                              struct snd_card **cardp)
 {
-       return snd_card_create(index[dev], id[dev], THIS_MODULE,
-                              sizeof(struct snd_es18xx), cardp);
+       return snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                           sizeof(struct snd_es18xx), cardp);
 }
 
 static int snd_audiodrive_probe(struct snd_card *card, int dev)
@@ -2179,10 +2180,9 @@ static int snd_es18xx_isa_probe1(int dev, struct device *devptr)
        struct snd_card *card;
        int err;
 
-       err = snd_es18xx_card_new(dev, &card);
+       err = snd_es18xx_card_new(devptr, dev, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, devptr);
        if ((err = snd_audiodrive_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -2284,14 +2284,13 @@ static int snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
 
-       err = snd_es18xx_card_new(dev, &card);
+       err = snd_es18xx_card_new(&pdev->dev, dev, &card);
        if (err < 0)
                return err;
        if ((err = snd_audiodrive_pnp(dev, card->private_data, pdev)) < 0) {
                snd_card_free(card);
                return err;
        }
-       snd_card_set_dev(card, &pdev->dev);
        if ((err = snd_audiodrive_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -2342,7 +2341,7 @@ static int snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
 
-       res = snd_es18xx_card_new(dev, &card);
+       res = snd_es18xx_card_new(&pcard->card->dev, dev, &card);
        if (res < 0)
                return res;
 
@@ -2350,7 +2349,6 @@ static int snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
                snd_card_free(card);
                return res;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
        if ((res = snd_audiodrive_probe(card, dev)) < 0) {
                snd_card_free(card);
                return res;
index 81244e7cea5be0d32d00cf14fe2a461432cd1082..1eb2b1ec0fd93c8a288a521f8e35f184ee7ebd69 100644 (file)
@@ -506,13 +506,11 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n)
        u8 type;
        int err;
 
-       err = snd_card_create(index[n], id[n], THIS_MODULE, sizeof *galaxy,
-                             &card);
+       err = snd_card_new(dev, index[n], id[n], THIS_MODULE,
+                          sizeof(*galaxy), &card);
        if (err < 0)
                return err;
 
-       snd_card_set_dev(card, dev);
-
        card->private_free = snd_galaxy_free;
        galaxy = card->private_data;
 
index 1adc1b924f39f4e3d3dc7a4d4414568a3cb10b7c..7ce29ffa1af9b476ef264cc874591a0d8829415d 100644 (file)
@@ -149,7 +149,7 @@ static int snd_gusclassic_probe(struct device *dev, unsigned int n)
        struct snd_gus_card *gus;
        int error;
 
-       error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
+       error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
        if (error < 0)
                return error;
 
@@ -199,8 +199,6 @@ static int snd_gusclassic_probe(struct device *dev, unsigned int n)
                sprintf(card->longname + strlen(card->longname),
                        "&%d", gus->gf1.dma2);
 
-       snd_card_set_dev(card, dev);
-
        error = snd_card_register(card);
        if (error < 0)
                goto out;
index 38e1e3260c2453be6c07d0dfecdb48d5869bba78..28a16936a397b71207b88504cd6ee1fc0e8ad82a 100644 (file)
@@ -242,8 +242,8 @@ static int snd_gusextreme_probe(struct device *dev, unsigned int n)
        struct snd_opl3 *opl3;
        int error;
 
-       error = snd_card_create(index[n], id[n], THIS_MODULE,
-                               sizeof(struct snd_es1688), &card);
+       error = snd_card_new(dev, index[n], id[n], THIS_MODULE,
+                            sizeof(struct snd_es1688), &card);
        if (error < 0)
                return error;
 
@@ -328,8 +328,6 @@ static int snd_gusextreme_probe(struct device *dev, unsigned int n)
                "irq %i&%i, dma %i&%i", es1688->port,
                gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8);
 
-       snd_card_set_dev(card, dev);
-
        error = snd_card_register(card);
        if (error < 0)
                goto out;
index 652d5d834620daa453caf9390b618e1fcc46afa6..39df36ca3acbe7438d2dc3bd6e0644683c1f0f53 100644 (file)
@@ -214,8 +214,8 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev)
        struct snd_wss *wss;
        struct snd_gusmax *maxcard;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_gusmax), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_gusmax), &card);
        if (err < 0)
                return err;
        card->private_free = snd_gusmax_free;
@@ -337,8 +337,6 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev)
        if (xdma2 >= 0)
                sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
 
-       snd_card_set_dev(card, pdev);
-
        err = snd_card_register(card);
        if (err < 0)
                goto _err;
index afef0d738078f27935d844f5d002db1b7bbe2609..5abbbe477d16c529f839b34f5cf21abe885a1fe9 100644 (file)
@@ -625,14 +625,15 @@ static void snd_interwave_free(struct snd_card *card)
                free_irq(iwcard->irq, (void *)iwcard);
 }
 
-static int snd_interwave_card_new(int dev, struct snd_card **cardp)
+static int snd_interwave_card_new(struct device *pdev, int dev,
+                                 struct snd_card **cardp)
 {
        struct snd_card *card;
        struct snd_interwave *iwcard;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_interwave), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_interwave), &card);
        if (err < 0)
                return err;
        iwcard = card->private_data;
@@ -779,11 +780,10 @@ static int snd_interwave_isa_probe1(int dev, struct device *devptr)
        struct snd_card *card;
        int err;
 
-       err = snd_interwave_card_new(dev, &card);
+       err = snd_interwave_card_new(devptr, dev, &card);
        if (err < 0)
                return err;
 
-       snd_card_set_dev(card, devptr);
        if ((err = snd_interwave_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -876,7 +876,7 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
                                
-       res = snd_interwave_card_new(dev, &card);
+       res = snd_interwave_card_new(&pcard->card->dev, dev, &card);
        if (res < 0)
                return res;
 
@@ -884,7 +884,6 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
                snd_card_free(card);
                return res;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
        if ((res = snd_interwave_probe(card, dev)) < 0) {
                snd_card_free(card);
                return res;
index 0a90bd6ae2325d296f12f8d01a730e6d98fb0606..5016bf957f51d69778b2ff57b5ad4d7abe5acb97 100644 (file)
@@ -905,12 +905,11 @@ static int snd_msnd_isa_probe(struct device *pdev, unsigned int idx)
                return -ENODEV;
        }
 
-       err = snd_card_create(index[idx], id[idx], THIS_MODULE,
-                             sizeof(struct snd_msnd), &card);
+       err = snd_card_new(pdev, index[idx], id[idx], THIS_MODULE,
+                          sizeof(struct snd_msnd), &card);
        if (err < 0)
                return err;
 
-       snd_card_set_dev(card, pdev);
        chip = card->private_data;
        chip->card = card;
 
@@ -1122,14 +1121,14 @@ static int snd_msnd_pnp_detect(struct pnp_card_link *pcard,
         * Create a new ALSA sound card entry, in anticipation
         * of detecting our hardware ...
         */
-       ret = snd_card_create(index[idx], id[idx], THIS_MODULE,
-                             sizeof(struct snd_msnd), &card);
+       ret = snd_card_new(&pcard->card->dev,
+                          index[idx], id[idx], THIS_MODULE,
+                          sizeof(struct snd_msnd), &card);
        if (ret < 0)
                return ret;
 
        chip = card->private_data;
        chip->card = card;
-       snd_card_set_dev(card, &pcard->card->dev);
 
        /*
         * Read the correct parameters off the ISA PnP bus ...
index cc01c419b7e91931a1b61d0170d101256d9446fe..a219bc37816b30228d5fefd6b984deab70307585 100644 (file)
@@ -627,14 +627,15 @@ static void snd_opl3sa2_free(struct snd_card *card)
        release_and_free_resource(chip->res_port);
 }
 
-static int snd_opl3sa2_card_new(int dev, struct snd_card **cardp)
+static int snd_opl3sa2_card_new(struct device *pdev, int dev,
+                               struct snd_card **cardp)
 {
        struct snd_card *card;
        struct snd_opl3sa2 *chip;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_opl3sa2), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_opl3sa2), &card);
        if (err < 0)
                return err;
        strcpy(card->driver, "OPL3SA2");
@@ -737,14 +738,13 @@ static int snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
 
-       err = snd_opl3sa2_card_new(dev, &card);
+       err = snd_opl3sa2_card_new(&pdev->dev, dev, &card);
        if (err < 0)
                return err;
        if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) {
                snd_card_free(card);
                return err;
        }
-       snd_card_set_dev(card, &pdev->dev);
        if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -802,14 +802,13 @@ static int snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
 
-       err = snd_opl3sa2_card_new(dev, &card);
+       err = snd_opl3sa2_card_new(&pdev->dev, dev, &card);
        if (err < 0)
                return err;
        if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) {
                snd_card_free(card);
                return err;
        }
-       snd_card_set_dev(card, &pdev->dev);
        if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -883,10 +882,9 @@ static int snd_opl3sa2_isa_probe(struct device *pdev,
        struct snd_card *card;
        int err;
 
-       err = snd_opl3sa2_card_new(dev, &card);
+       err = snd_opl3sa2_card_new(pdev, dev, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, pdev);
        if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
index 619753d96ca5e1cfbc51d4fd146cba5e9b520cfe..c2ca681ac51ba7516cf93834df76cf613a6eff2f 100644 (file)
@@ -1411,8 +1411,8 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n)
        struct snd_miro *miro;
        struct snd_card *card;
 
-       error = snd_card_create(index, id, THIS_MODULE,
-                               sizeof(struct snd_miro), &card);
+       error = snd_card_new(devptr, index, id, THIS_MODULE,
+                            sizeof(struct snd_miro), &card);
        if (error < 0)
                return error;
 
@@ -1479,8 +1479,6 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n)
                }
        }
 
-       snd_card_set_dev(card, devptr);
-
        error = snd_miro_probe(card);
        if (error < 0) {
                snd_card_free(card);
@@ -1584,8 +1582,8 @@ static int snd_miro_pnp_probe(struct pnp_card_link *pcard,
                return -EBUSY;
        if (!isapnp)
                return -ENODEV;
-       err = snd_card_create(index, id, THIS_MODULE,
-                               sizeof(struct snd_miro), &card);
+       err = snd_card_new(&pcard->card->dev, index, id, THIS_MODULE,
+                          sizeof(struct snd_miro), &card);
        if (err < 0)
                return err;
 
@@ -1612,7 +1610,6 @@ static int snd_miro_pnp_probe(struct pnp_card_link *pcard,
                return err;
        }
 
-       snd_card_set_dev(card, &pcard->card->dev);
        err = snd_miro_probe(card);
        if (err < 0) {
                snd_card_free(card);
index 6effe99bbb9cd80797a149abebec80ce9bc6162e..c9b5828486037b187c5ec64252c19fefb681f54d 100644 (file)
@@ -934,13 +934,13 @@ static int snd_opti9xx_probe(struct snd_card *card)
        return snd_card_register(card);
 }
 
-static int snd_opti9xx_card_new(struct snd_card **cardp)
+static int snd_opti9xx_card_new(struct device *pdev, struct snd_card **cardp)
 {
        struct snd_card *card;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE,
-                             sizeof(struct snd_opti9xx), &card);
+       err = snd_card_new(pdev, index, id, THIS_MODULE,
+                          sizeof(struct snd_opti9xx), &card);
        if (err < 0)
                return err;
        card->private_free = snd_card_opti9xx_free;
@@ -1010,7 +1010,7 @@ static int snd_opti9xx_isa_probe(struct device *devptr,
        }
 #endif
 
-       error = snd_opti9xx_card_new(&card);
+       error = snd_opti9xx_card_new(devptr, &card);
        if (error < 0)
                return error;
 
@@ -1018,7 +1018,6 @@ static int snd_opti9xx_isa_probe(struct device *devptr,
                snd_card_free(card);
                return error;
        }
-       snd_card_set_dev(card, devptr);
        if ((error = snd_opti9xx_probe(card)) < 0) {
                snd_card_free(card);
                return error;
@@ -1100,7 +1099,7 @@ static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
                return -EBUSY;
        if (! isapnp)
                return -ENODEV;
-       error = snd_opti9xx_card_new(&card);
+       error = snd_opti9xx_card_new(&pcard->card->dev, &card);
        if (error < 0)
                return error;
        chip = card->private_data;
@@ -1131,7 +1130,6 @@ static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
                snd_card_free(card);
                return error;
        }
-       snd_card_set_dev(card, &pcard->card->dev);
        if ((error = snd_opti9xx_probe(card)) < 0) {
                snd_card_free(card);
                return error;
index 356a6308392f29a19fabd4e670cafdac35cc3486..90d2eba549e90d51fde8c71834dfb6f2cd52e895 100644 (file)
@@ -229,8 +229,8 @@ static int snd_jazz16_probe(struct device *devptr, unsigned int dev)
        static int possible_dmas16[] = {5, 7, -1};
        int err, xirq, xdma8, xdma16, xmpu_port, xmpu_irq;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_card_jazz16), &card);
+       err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_card_jazz16), &card);
        if (err < 0)
                return err;
 
@@ -327,8 +327,6 @@ static int snd_jazz16_probe(struct device *devptr, unsigned int dev)
                                        mpu_port[dev]);
        }
 
-       snd_card_set_dev(card, devptr);
-
        err = snd_card_register(card);
        if (err < 0)
                goto err_free;
index a4130993955f39d0781983c7f12060ba518c0770..3f694543a7ea7774f3719647adc0cc3a399c0809 100644 (file)
@@ -323,13 +323,14 @@ static void snd_sb16_free(struct snd_card *card)
 #define is_isapnp_selected(dev)                0
 #endif
 
-static int snd_sb16_card_new(int dev, struct snd_card **cardp)
+static int snd_sb16_card_new(struct device *devptr, int dev,
+                            struct snd_card **cardp)
 {
        struct snd_card *card;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_card_sb16), &card);
+       err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_card_sb16), &card);
        if (err < 0)
                return err;
        card->private_free = snd_sb16_free;
@@ -493,7 +494,7 @@ static int snd_sb16_isa_probe1(int dev, struct device *pdev)
        struct snd_card *card;
        int err;
 
-       err = snd_sb16_card_new(dev, &card);
+       err = snd_sb16_card_new(pdev, dev, &card);
        if (err < 0)
                return err;
 
@@ -507,7 +508,6 @@ static int snd_sb16_isa_probe1(int dev, struct device *pdev)
        awe_port[dev] = port[dev] + 0x400;
 #endif
 
-       snd_card_set_dev(card, pdev);
        if ((err = snd_sb16_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -613,10 +613,9 @@ static int snd_sb16_pnp_detect(struct pnp_card_link *pcard,
        for ( ; dev < SNDRV_CARDS; dev++) {
                if (!enable[dev] || !isapnp[dev])
                        continue;
-               res = snd_sb16_card_new(dev, &card);
+               res = snd_sb16_card_new(&pcard->card->dev, dev, &card);
                if (res < 0)
                        return res;
-               snd_card_set_dev(card, &pcard->card->dev);
                if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 ||
                    (res = snd_sb16_probe(card, dev)) < 0) {
                        snd_card_free(card);
index a806ae90a9449246cd9b8a43ae6924f7439def21..6c32b3aa34af169b3c409768ce5d82e4cb86539b 100644 (file)
@@ -102,8 +102,8 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
        struct snd_opl3 *opl3;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_sb8), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_sb8), &card);
        if (err < 0)
                return err;
        acard = card->private_data;
@@ -192,8 +192,6 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
                chip->port,
                irq[dev], dma8[dev]);
 
-       snd_card_set_dev(card, pdev);
-
        if ((err = snd_card_register(card)) < 0)
                goto _err;
 
index 09d481b3ba7fae52346ccdb273403e32c76e4862..15a152eaa2e89ee2cd8c7d10fc3c670b1c6ff3c8 100644 (file)
@@ -559,8 +559,8 @@ static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
        char __iomem *vmss_port;
 
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, sizeof(vport),
-                               &card);
+       err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE,
+                          sizeof(vport), &card);
        if (err < 0)
                return err;
 
@@ -668,8 +668,6 @@ static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
        sprintf(card->longname, "Gallant SC-6000 at 0x%lx, irq %d, dma %d",
                mss_port[dev], xirq, xdma);
 
-       snd_card_set_dev(card, devptr);
-
        err = snd_card_register(card);
        if (err < 0)
                goto err_unmap2;
index 57b338973ede0c99ff9b2b291761bc2d1dfa62c3..44405df7d4becffcf82db3b5e9a1152f65eed304 100644 (file)
@@ -1169,8 +1169,8 @@ static int snd_sscape_probe(struct device *pdev, unsigned int dev)
        struct soundscape *sscape;
        int ret;
 
-       ret = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct soundscape), &card);
+       ret = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct soundscape), &card);
        if (ret < 0)
                return ret;
 
@@ -1178,7 +1178,6 @@ static int snd_sscape_probe(struct device *pdev, unsigned int dev)
        sscape->type = SSCAPE;
 
        dma[dev] &= 0x03;
-       snd_card_set_dev(card, pdev);
 
        ret = create_sscape(dev, card);
        if (ret < 0)
@@ -1259,8 +1258,9 @@ static int sscape_pnp_detect(struct pnp_card_link *pcard,
         * Create a new ALSA sound card entry, in anticipation
         * of detecting our hardware ...
         */
-       ret = snd_card_create(index[idx], id[idx], THIS_MODULE,
-                             sizeof(struct soundscape), &card);
+       ret = snd_card_new(&pcard->card->dev,
+                          index[idx], id[idx], THIS_MODULE,
+                          sizeof(struct soundscape), &card);
        if (ret < 0)
                return ret;
 
@@ -1288,7 +1288,6 @@ static int sscape_pnp_detect(struct pnp_card_link *pcard,
                wss_port[idx] = pnp_port_start(dev, 1);
                dma2[idx] = pnp_dma(dev, 1);
        }
-       snd_card_set_dev(card, &pcard->card->dev);
 
        ret = create_sscape(idx, card);
        if (ret < 0)
index 82dd76939fa040b639f32cb33d072fecafd22239..bfbf38cf984175966e2cdfca4a83647f56c99192 100644 (file)
@@ -334,14 +334,15 @@ snd_wavefront_free(struct snd_card *card)
        }
 }
 
-static int snd_wavefront_card_new(int dev, struct snd_card **cardp)
+static int snd_wavefront_card_new(struct device *pdev, int dev,
+                                 struct snd_card **cardp)
 {
        struct snd_card *card;
        snd_wavefront_card_t *acard;
        int err;
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(snd_wavefront_card_t), &card);
+       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(snd_wavefront_card_t), &card);
        if (err < 0)
                return err;
 
@@ -564,10 +565,9 @@ static int snd_wavefront_isa_probe(struct device *pdev,
        struct snd_card *card;
        int err;
 
-       err = snd_wavefront_card_new(dev, &card);
+       err = snd_wavefront_card_new(pdev, dev, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, pdev);
        if ((err = snd_wavefront_probe(card, dev)) < 0) {
                snd_card_free(card);
                return err;
@@ -612,7 +612,7 @@ static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
 
-       res = snd_wavefront_card_new(dev, &card);
+       res = snd_wavefront_card_new(&pcard->card->dev, dev, &card);
        if (res < 0)
                return res;
 
@@ -623,7 +623,6 @@ static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
                        return -ENODEV;
                }
        }
-       snd_card_set_dev(card, &pcard->card->dev);
 
        if ((res = snd_wavefront_probe(card, dev)) < 0)
                return res;
index 224f54be15a61002ef17630acff78a191a501039..a7cc49e960685d97f223accb9916f478a1e22e43 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <sound/core.h>
@@ -98,6 +99,7 @@ struct snd_au1000 {
 
        struct snd_pcm *pcm;
        struct audio_stream *stream[2]; /* playback & capture */
+       int dmaid[2];           /* tx(0)/rx(1) DMA ids */
 };
 
 /*--------------------------- Local Functions --------------------------------*/
@@ -465,15 +467,17 @@ snd_au1000_pcm_new(struct snd_au1000 *au1000)
        spin_lock_init(&au1000->stream[CAPTURE]->dma_lock);
 
        flags = claim_dma_lock();
-       if ((au1000->stream[PLAYBACK]->dma = request_au1000_dma(DMA_ID_AC97C_TX,
+       au1000->stream[PLAYBACK]->dma = request_au1000_dma(au1000->dmaid[0],
                        "AC97 TX", au1000_dma_interrupt, 0,
-                       au1000->stream[PLAYBACK])) < 0) {
+                       au1000->stream[PLAYBACK]);
+       if (au1000->stream[PLAYBACK]->dma < 0) {
                release_dma_lock(flags);
                return -EBUSY;
        }
-       if ((au1000->stream[CAPTURE]->dma = request_au1000_dma(DMA_ID_AC97C_RX,
+       au1000->stream[CAPTURE]->dma = request_au1000_dma(au1000->dmaid[1],
                        "AC97 RX", au1000_dma_interrupt, 0,
-                       au1000->stream[CAPTURE])) < 0){
+                       au1000->stream[CAPTURE]);
+       if (au1000->stream[CAPTURE]->dma < 0){
                release_dma_lock(flags);
                return -EBUSY;
        }
@@ -552,69 +556,12 @@ get the interrupt driven case to work efficiently */
        spin_unlock(&au1000->ac97_lock);
 }
 
-static int
-snd_au1000_ac97_new(struct snd_au1000 *au1000)
-{
-       int err;
-       struct snd_ac97_bus *pbus;
-       struct snd_ac97_template ac97;
-       static struct snd_ac97_bus_ops ops = {
-               .write = snd_au1000_ac97_write,
-               .read = snd_au1000_ac97_read,
-       };
-
-       if ((au1000->ac97_res_port = request_mem_region(CPHYSADDR(AC97C_CONFIG),
-                       0x100000, "Au1x00 AC97")) == NULL) {
-               snd_printk(KERN_ERR "ALSA AC97: can't grap AC97 port\n");
-               return -EBUSY;
-       }
-       au1000->ac97_ioport = (struct au1000_ac97_reg *)
-               KSEG1ADDR(au1000->ac97_res_port->start);
-
-       spin_lock_init(&au1000->ac97_lock);
-
-       /* configure pins for AC'97
-       TODO: move to board_setup.c */
-       au_writel(au_readl(SYS_PINFUNC) & ~0x02, SYS_PINFUNC);
-
-       /* Initialise Au1000's AC'97 Control Block */
-       au1000->ac97_ioport->cntrl = AC97C_RS | AC97C_CE;
-       udelay(10);
-       au1000->ac97_ioport->cntrl = AC97C_CE;
-       udelay(10);
-
-       /* Initialise External CODEC -- cold reset */
-       au1000->ac97_ioport->config = AC97C_RESET;
-       udelay(10);
-       au1000->ac97_ioport->config = 0x0;
-       mdelay(5);
-
-       /* Initialise AC97 middle-layer */
-       if ((err = snd_ac97_bus(au1000->card, 0, &ops, au1000, &pbus)) < 0)
-               return err;
-
-       memset(&ac97, 0, sizeof(ac97));
-       ac97.private_data = au1000;
-       if ((err = snd_ac97_mixer(pbus, &ac97, &au1000->ac97)) < 0)
-               return err;
-
-       return 0;
-}
-
 /*------------------------------ Setup / Destroy ----------------------------*/
 
-void
-snd_au1000_free(struct snd_card *card)
+static void snd_au1000_free(struct snd_card *card)
 {
        struct snd_au1000 *au1000 = card->private_data;
 
-       if (au1000->ac97_res_port) {
-               /* put internal AC97 block into reset */
-               au1000->ac97_ioport->cntrl = AC97C_RS;
-               au1000->ac97_ioport = NULL;
-               release_and_free_resource(au1000->ac97_res_port);
-       }
-
        if (au1000->stream[PLAYBACK]) {
                if (au1000->stream[PLAYBACK]->dma >= 0)
                        free_au1000_dma(au1000->stream[PLAYBACK]->dma);
@@ -626,71 +573,167 @@ snd_au1000_free(struct snd_card *card)
                        free_au1000_dma(au1000->stream[CAPTURE]->dma);
                kfree(au1000->stream[CAPTURE]);
        }
-}
 
+       if (au1000->ac97_res_port) {
+               /* put internal AC97 block into reset */
+               if (au1000->ac97_ioport) {
+                       au1000->ac97_ioport->cntrl = AC97C_RS;
+                       iounmap(au1000->ac97_ioport);
+                       au1000->ac97_ioport = NULL;
+               }
+               release_and_free_resource(au1000->ac97_res_port);
+               au1000->ac97_res_port = NULL;
+       }
+}
 
-static struct snd_card *au1000_card;
+static struct snd_ac97_bus_ops ops = {
+       .write  = snd_au1000_ac97_write,
+       .read   = snd_au1000_ac97_read,
+};
 
-static int __init
-au1000_init(void)
+static int au1000_ac97_probe(struct platform_device *pdev)
 {
        int err;
+       void __iomem *io;
+       struct resource *r;
        struct snd_card *card;
        struct snd_au1000 *au1000;
+       struct snd_ac97_bus *pbus;
+       struct snd_ac97_template ac97;
 
-       err = snd_card_create(-1, "AC97", THIS_MODULE,
-                             sizeof(struct snd_au1000), &card);
+       err = snd_card_new(&pdev->dev, -1, "AC97", THIS_MODULE,
+                          sizeof(struct snd_au1000), &card);
        if (err < 0)
                return err;
 
-       card->private_free = snd_au1000_free;
        au1000 = card->private_data;
        au1000->card = card;
+       spin_lock_init(&au1000->ac97_lock);
 
-       au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL);
-       au1000->stream[CAPTURE ] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL);
-       /* so that snd_au1000_free will work as intended */
-       au1000->ac97_res_port = NULL;
-       if (au1000->stream[PLAYBACK])
-               au1000->stream[PLAYBACK]->dma = -1;
-       if (au1000->stream[CAPTURE ])
-               au1000->stream[CAPTURE ]->dma = -1;
-
-       if (au1000->stream[PLAYBACK] == NULL ||
-           au1000->stream[CAPTURE ] == NULL) {
-               snd_card_free(card);
-               return -ENOMEM;
-       }
+       /* from here on let ALSA call the special freeing function */
+       card->private_free = snd_au1000_free;
 
-       if ((err = snd_au1000_ac97_new(au1000)) < 0 ) {
-               snd_card_free(card);
-               return err;
+       /* TX DMA ID */
+       r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+       if (!r) {
+               err = -ENODEV;
+               snd_printk(KERN_INFO "no TX DMA platform resource!\n");
+               goto out;
        }
-
-       if ((err = snd_au1000_pcm_new(au1000)) < 0) {
-               snd_card_free(card);
-               return err;
+       au1000->dmaid[0] = r->start;
+
+       /* RX DMA ID */
+       r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
+       if (!r) {
+               err = -ENODEV;
+               snd_printk(KERN_INFO "no RX DMA platform resource!\n");
+               goto out;
+       }
+       au1000->dmaid[1] = r->start;
+
+       au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream),
+                                          GFP_KERNEL);
+       if (!au1000->stream[PLAYBACK])
+               goto out;
+       au1000->stream[PLAYBACK]->dma = -1;
+
+       au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream),
+                                         GFP_KERNEL);
+       if (!au1000->stream[CAPTURE])
+               goto out;
+       au1000->stream[CAPTURE]->dma = -1;
+
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!r)
+               goto out;
+
+       err = -EBUSY;
+       au1000->ac97_res_port = request_mem_region(r->start,
+                                       r->end - r->start + 1, pdev->name);
+       if (!au1000->ac97_res_port) {
+               snd_printk(KERN_ERR "ALSA AC97: can't grab AC97 port\n");
+               goto out;
        }
 
+       io = ioremap(r->start, r->end - r->start + 1);
+       if (!io)
+               goto out;
+
+       au1000->ac97_ioport = (struct au1000_ac97_reg *)io;
+
+       /* configure pins for AC'97
+       TODO: move to board_setup.c */
+       au_writel(au_readl(SYS_PINFUNC) & ~0x02, SYS_PINFUNC);
+
+       /* Initialise Au1000's AC'97 Control Block */
+       au1000->ac97_ioport->cntrl = AC97C_RS | AC97C_CE;
+       udelay(10);
+       au1000->ac97_ioport->cntrl = AC97C_CE;
+       udelay(10);
+
+       /* Initialise External CODEC -- cold reset */
+       au1000->ac97_ioport->config = AC97C_RESET;
+       udelay(10);
+       au1000->ac97_ioport->config = 0x0;
+       mdelay(5);
+
+       /* Initialise AC97 middle-layer */
+       err = snd_ac97_bus(au1000->card, 0, &ops, au1000, &pbus);
+       if (err < 0)
+               goto out;
+
+       memset(&ac97, 0, sizeof(ac97));
+       ac97.private_data = au1000;
+       err = snd_ac97_mixer(pbus, &ac97, &au1000->ac97);
+       if (err < 0)
+               goto out;
+
+       err = snd_au1000_pcm_new(au1000);
+       if (err < 0)
+               goto out;
+
        strcpy(card->driver, "Au1000-AC97");
        strcpy(card->shortname, "AMD Au1000-AC97");
        sprintf(card->longname, "AMD Au1000--AC97 ALSA Driver");
 
-       if ((err = snd_card_register(card)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
+       err = snd_card_register(card);
+       if (err < 0)
+               goto out;
 
        printk(KERN_INFO "ALSA AC97: Driver Initialized\n");
-       au1000_card = card;
+
+       platform_set_drvdata(pdev, card);
+
        return 0;
+
+ out:
+       snd_card_free(card);
+       return err;
+}
+
+static int au1000_ac97_remove(struct platform_device *pdev)
+{
+       return snd_card_free(platform_get_drvdata(pdev));
 }
 
-static void __exit au1000_exit(void)
+struct platform_driver au1000_ac97c_driver = {
+       .driver = {
+               .name   = "au1000-ac97c",
+               .owner  = THIS_MODULE,
+       },
+       .probe          = au1000_ac97_probe,
+       .remove         = au1000_ac97_remove,
+};
+
+static int __init au1000_ac97_load(void)
 {
-       snd_card_free(au1000_card);
+       return platform_driver_register(&au1000_ac97c_driver);
 }
 
-module_init(au1000_init);
-module_exit(au1000_exit);
+static void __exit au1000_ac97_unload(void)
+{
+       platform_driver_unregister(&au1000_ac97c_driver);
+}
 
+module_init(au1000_ac97_load);
+module_exit(au1000_ac97_unload);
index 2b7f6e8bdd24343bd41ce854bb93383815386d6b..23441b9e6148b6ded73a89c01eb3ac93e65a4895 100644 (file)
@@ -880,7 +880,7 @@ static int hal2_probe(struct platform_device *pdev)
        struct snd_hal2 *chip;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pdev->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -889,7 +889,6 @@ static int hal2_probe(struct platform_device *pdev)
                snd_card_free(card);
                return err;
        }
-       snd_card_set_dev(card, &pdev->dev);
 
        err = hal2_pcm_create(chip);
        if (err < 0) {
index cfe99ae149fed9f55d70dc10f23e12e59fa4ee34..04bb06c03ec80bf2673644f616cbfb39579f6ba3 100644 (file)
@@ -920,7 +920,7 @@ static int snd_sgio2audio_probe(struct platform_device *pdev)
        struct snd_sgio2audio *chip;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pdev->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -929,7 +929,6 @@ static int snd_sgio2audio_probe(struct platform_device *pdev)
                snd_card_free(card);
                return err;
        }
-       snd_card_set_dev(card, &pdev->dev);
 
        err = snd_sgio2audio_new_pcm(chip);
        if (err < 0) {
index fa12c55f560e05992872018b25bd7b75e6267952..d19f757dbd79676ab48d1667c8ed38d7a98434b1 100644 (file)
@@ -15,3 +15,6 @@ int pas_init_mixer(void);
 /*     From pas_midi.c */
 void pas_midi_init(void);
 void pas_midi_interrupt(void);
+
+/*     From pas2_mixer.c*/
+void mix_write(unsigned char data, int ioaddr);
index 7004e24d209f167c196e231ffc1f883033eb8d54..b07954a7953679b077b12b190343492a3271510f 100644 (file)
@@ -74,8 +74,6 @@ static char    *pas_model_names[] = {
  * to support other than the default base address
  */
 
-extern void     mix_write(unsigned char data, int ioaddr);
-
 unsigned char pas_read(int ioaddr)
 {
        return inb(ioaddr + pas_translate_code);
index 67f56a2cee6aec83bd4710f645a82cdca9e39847..4b20be79c1ddbb58b2712a03db08227afd5a12ef 100644 (file)
@@ -959,8 +959,6 @@ snd_harmony_create(struct snd_card *card,
                 goto free_and_ret;
         }
 
-       snd_card_set_dev(card, &padev->dev);
-
        *rchip = h;
 
        return 0;
@@ -977,7 +975,7 @@ snd_harmony_probe(struct parisc_device *padev)
        struct snd_card *card;
        struct snd_harmony *h;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&padev->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index 8756c8e329224f1e2fb81862d6e60be4954a85cd..0b0c0cf13f748e0e231a6d068351c6827a57d128 100644 (file)
@@ -276,7 +276,7 @@ config SND_CS46XX_NEW_DSP
 
 config SND_CS5530
        tristate "CS5530 Audio"
-       depends on ISA_DMA_API
+       depends on ISA_DMA_API && (X86_32 || COMPILE_TEST)
        select SND_SB16_DSP
        help
          Say Y here to include support for audio on Cyrix/NatSemi CS5530 chips.
@@ -286,6 +286,7 @@ config SND_CS5530
 
 config SND_CS5535AUDIO
        tristate "CS5535/CS5536 Audio"
+       depends on X86_32 || MIPS || COMPILE_TEST
        select SND_PCM
        select SND_AC97_CODEC
        help
@@ -578,8 +579,6 @@ config SND_FM801_TEA575X_BOOL
          FM801 chip with a TEA5757 tuner (MediaForte SF256-PCS, SF256-PCP and
          SF64-PCR) into the snd-fm801 driver.
 
-source "sound/pci/hda/Kconfig"
-
 config SND_HDSP
        tristate "RME Hammerfall DSP Audio"
        select FW_LOADER
@@ -796,7 +795,7 @@ config SND_RME9652
 
 config SND_SIS7019
        tristate "SiS 7019 Audio Accelerator"
-       depends on X86 && !X86_64
+       depends on X86_32
        select SND_AC97_CODEC
        select ZONE_DMA
        help
@@ -889,3 +888,5 @@ config SND_YMFPCI
          will be called snd-ymfpci.
 
 endif  # SND_PCI
+
+source "sound/pci/hda/Kconfig"
index bf578ba2677e72566187619e1e0515afe93fdfd6..14ad54b7928cf326732f3967a2fc24faadeef60e 100644 (file)
@@ -214,6 +214,12 @@ static void update_power_regs(struct snd_ac97 *ac97);
 #define ac97_is_power_save_mode(ac97) 0
 #endif
 
+#define ac97_err(ac97, fmt, args...)   \
+       dev_err((ac97)->bus->card->dev, fmt, ##args)
+#define ac97_warn(ac97, fmt, args...)  \
+       dev_warn((ac97)->bus->card->dev, fmt, ##args)
+#define ac97_dbg(ac97, fmt, args...)   \
+       dev_dbg((ac97)->bus->card->dev, fmt, ##args)
 
 /*
  *  I/O routines
@@ -1673,7 +1679,7 @@ static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97)
        int err, idx;
 
        /*
-       printk(KERN_DEBUG "AC97_GPIO_CFG = %x\n",
+       ac97_dbg(ac97, "AC97_GPIO_CFG = %x\n",
               snd_ac97_read(ac97,AC97_GPIO_CFG));
        */
        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)
                     ac97->bus->card->number, ac97->num,
                     snd_ac97_get_short_name(ac97));
        if ((err = device_register(&ac97->dev)) < 0) {
-               snd_printk(KERN_ERR "Can't register ac97 bus\n");
+               ac97_err(ac97, "Can't register ac97 bus\n");
                ac97->dev.bus = NULL;
                return err;
        }
@@ -2089,7 +2095,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
                                                      msecs_to_jiffies(500), 1);
                }
                if (err < 0) {
-                       snd_printk(KERN_WARNING "AC'97 %d does not respond - RESET\n", ac97->num);
+                       ac97_warn(ac97, "AC'97 %d does not respond - RESET\n",
+                                ac97->num);
                        /* proceed anyway - it's often non-critical */
                }
        }
@@ -2098,7 +2105,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
        ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2);
        if (! (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) &&
            (ac97->id == 0x00000000 || ac97->id == 0xffffffff)) {
-               snd_printk(KERN_ERR "AC'97 %d access is not valid [0x%x], removing mixer.\n", ac97->num, ac97->id);
+               ac97_err(ac97,
+                        "AC'97 %d access is not valid [0x%x], removing mixer.\n",
+                        ac97->num, ac97->id);
                snd_ac97_free(ac97);
                return -EIO;
        }
@@ -2131,7 +2140,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
 
        if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) {
                if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM)))
-                       snd_printk(KERN_ERR "AC'97 %d access error (not audio or modem codec)\n", ac97->num);
+                       ac97_err(ac97,
+                                "AC'97 %d access error (not audio or modem codec)\n",
+                                ac97->num);
                snd_ac97_free(ac97);
                return -EACCES;
        }
@@ -2156,7 +2167,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
                                goto __ready_ok;
                        schedule_timeout_uninterruptible(1);
                } while (time_after_eq(end_time, jiffies));
-               snd_printk(KERN_WARNING "AC'97 %d analog subsections not ready\n", ac97->num);
+               ac97_warn(ac97,
+                         "AC'97 %d analog subsections not ready\n", ac97->num);
        }
 
        /* FIXME: add powerdown control */
@@ -2188,7 +2200,10 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
                                goto __ready_ok;
                        schedule_timeout_uninterruptible(1);
                } while (time_after_eq(end_time, jiffies));
-               snd_printk(KERN_WARNING "MC'97 %d converters and GPIO not ready (0x%x)\n", ac97->num, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
+               ac97_warn(ac97,
+                         "MC'97 %d converters and GPIO not ready (0x%x)\n",
+                         ac97->num,
+                         snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
        }
        
       __ready_ok:
@@ -2723,7 +2738,7 @@ static int tune_ad_sharing(struct snd_ac97 *ac97)
 {
        unsigned short scfg;
        if ((ac97->id & 0xffffff00) != 0x41445300) {
-               snd_printk(KERN_ERR "ac97_quirk AD_SHARING is only for AD codecs\n");
+               ac97_err(ac97, "ac97_quirk AD_SHARING is only for AD codecs\n");
                return -EINVAL;
        }
        /* Turn on OMS bit to route microphone to back panel */
@@ -2739,7 +2754,8 @@ AC97_SINGLE("Jack Detect", AC97_ALC650_CLOCK, 5, 1, 0);
 static int tune_alc_jack(struct snd_ac97 *ac97)
 {
        if ((ac97->id & 0xffffff00) != 0x414c4700) {
-               snd_printk(KERN_ERR "ac97_quirk ALC_JACK is only for Realtek codecs\n");
+               ac97_err(ac97,
+                        "ac97_quirk ALC_JACK is only for Realtek codecs\n");
                return -EINVAL;
        }
        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
        if (override && strcmp(override, "-1") && strcmp(override, "default")) {
                result = apply_quirk_str(ac97, override);
                if (result < 0)
-                       snd_printk(KERN_ERR "applying quirk type %s failed (%d)\n", override, result);
+                       ac97_err(ac97, "applying quirk type %s failed (%d)\n",
+                                override, result);
                return result;
        }
 
@@ -2913,10 +2930,14 @@ int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, cons
                    quirk->subdevice == (quirk->mask & ac97->subsystem_device)) {
                        if (quirk->codec_id && quirk->codec_id != ac97->id)
                                continue;
-                       snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device);
+                       ac97_dbg(ac97, "ac97 quirk for %s (%04x:%04x)\n",
+                                quirk->name, ac97->subsystem_vendor,
+                                ac97->subsystem_device);
                        result = apply_quirk(ac97, quirk->type);
                        if (result < 0)
-                               snd_printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result);
+                               ac97_err(ac97,
+                                        "applying quirk type %d for %s failed (%d)\n",
+                                        quirk->type, quirk->name, result);
                        return result;
                }
        }
index 66a3bc95fb844c3f1b311b227622aacbb680a50c..99176221541782c3cd7c8a9f257ed1d708904c98 100644 (file)
@@ -3477,7 +3477,8 @@ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
 
                sctl = snd_ac97_find_mixer_ctl(ac97, *s);
                if (!sctl) {
-                       snd_printdd("Cannot find slave %s, skipped\n", *s);
+                       dev_dbg(ac97->bus->card->dev,
+                               "Cannot find slave %s, skipped\n", *s);
                        continue;
                }
                err = snd_ctl_add_slave(kctl, sctl);
index eab0fc9ff2e0c7aacb08ffdf69a3be7fdb4b5c2c..d15297a68801c8925d3cd3d7c8be70ef99ef4a1e 100644 (file)
@@ -604,7 +604,9 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
                }
                if (!ok_flag) {
                        spin_unlock_irq(&pcm->bus->bus_lock);
-                       snd_printk(KERN_ERR "cannot find configuration for AC97 slot %i\n", i);
+                       dev_err(bus->card->dev,
+                               "cannot find configuration for AC97 slot %i\n",
+                               i);
                        err = -EAGAIN;
                        goto error;
                }
@@ -618,15 +620,20 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
                        if (pcm->r[r].rslots[cidx] & (1 << i)) {
                                reg = get_slot_reg(pcm, cidx, i, r);
                                if (reg == 0xff) {
-                                       snd_printk(KERN_ERR "invalid AC97 slot %i?\n", i);
+                                       dev_err(bus->card->dev,
+                                               "invalid AC97 slot %i?\n", i);
                                        continue;
                                }
                                if (reg_ok[cidx] & (1 << (reg - AC97_PCM_FRONT_DAC_RATE)))
                                        continue;
-                               //printk(KERN_DEBUG "setting ac97 reg 0x%x to rate %d\n", reg, rate);
+                               dev_dbg(bus->card->dev,
+                                       "setting ac97 reg 0x%x to rate %d\n",
+                                       reg, rate);
                                err = snd_ac97_set_rate(pcm->r[r].codec[cidx], reg, rate);
                                if (err < 0)
-                                       snd_printk(KERN_ERR "error in snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d, err=%d\n", cidx, reg, rate, err);
+                                       dev_err(bus->card->dev,
+                                               "error in snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d, err=%d\n",
+                                               cidx, reg, rate, err);
                                else
                                        reg_ok[cidx] |= (1 << (reg - AC97_PCM_FRONT_DAC_RATE));
                        }
index b680d03e24192e0079e733ec0079d7e6b3ef4904..488f966adde31db86444fd1b03272b3d80b19a8b 100644 (file)
@@ -77,9 +77,6 @@ MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
 #define DEVNAME "ad1889"
 #define PFX    DEVNAME ": "
 
-/* let's use the global sound debug interfaces */
-#define ad1889_debug(fmt, arg...) snd_printd(KERN_DEBUG fmt, ## arg)
-
 /* keep track of some hw registers */
 struct ad1889_register_state {
        u16 reg;        /* reg setup */
@@ -264,11 +261,11 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip)
                        && --retry)
                mdelay(1);
        if (!retry) {
-               snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n",
-                      __func__);
+               dev_err(chip->card->dev, "[%s] Link is not ready.\n",
+                       __func__);
                return -EIO;
        }
-       ad1889_debug("[%s] ready after %d ms\n", __func__, 400 - retry);
+       dev_dbg(chip->card->dev, "[%s] ready after %d ms\n", __func__, 400 - retry);
 
        return 0;
 }
@@ -405,9 +402,9 @@ snd_ad1889_playback_prepare(struct snd_pcm_substream *ss)
        
        spin_unlock_irq(&chip->lock);
        
-       ad1889_debug("prepare playback: addr = 0x%x, count = %u, "
-                       "size = %u, reg = 0x%x, rate = %u\n", chip->wave.addr,
-                       count, size, reg, rt->rate);
+       dev_dbg(chip->card->dev,
+               "prepare playback: addr = 0x%x, count = %u, size = %u, reg = 0x%x, rate = %u\n",
+               chip->wave.addr, count, size, reg, rt->rate);
        return 0;
 }
 
@@ -452,9 +449,9 @@ snd_ad1889_capture_prepare(struct snd_pcm_substream *ss)
        
        spin_unlock_irq(&chip->lock);
        
-       ad1889_debug("prepare capture: addr = 0x%x, count = %u, "
-                       "size = %u, reg = 0x%x, rate = %u\n", chip->ramc.addr,
-                       count, size, reg, rt->rate);
+       dev_dbg(chip->card->dev,
+               "prepare capture: addr = 0x%x, count = %u, size = %u, reg = 0x%x, rate = %u\n",
+               chip->ramc.addr, count, size, reg, rt->rate);
        return 0;
 }
 
@@ -614,7 +611,8 @@ snd_ad1889_interrupt(int irq, void *dev_id)
                return IRQ_NONE;
 
        if (st & (AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI))
-               ad1889_debug("Unexpected master or target abort interrupt!\n");
+               dev_dbg(chip->card->dev,
+                       "Unexpected master or target abort interrupt!\n");
 
        if ((st & AD_DMA_DISR_WAVI) && chip->psubs)
                snd_pcm_period_elapsed(chip->psubs);
@@ -656,7 +654,7 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm)
                                                BUFFER_BYTES_MAX);
 
        if (err < 0) {
-               snd_printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
+               dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
                return err;
        }
        
@@ -912,7 +910,7 @@ snd_ad1889_create(struct snd_card *card,
        /* check PCI availability (32bit DMA) */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
-               printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n");
+               dev_err(card->dev, "error setting 32-bit DMA mask.\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -935,7 +933,7 @@ snd_ad1889_create(struct snd_card *card,
        chip->bar = pci_resource_start(pci, 0);
        chip->iobase = pci_ioremap_bar(pci, 0);
        if (chip->iobase == NULL) {
-               printk(KERN_ERR PFX "unable to reserve region.\n");
+               dev_err(card->dev, "unable to reserve region.\n");
                err = -EBUSY;
                goto free_and_ret;
        }
@@ -946,7 +944,7 @@ snd_ad1889_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_ad1889_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR PFX "cannot obtain IRQ %d\n", pci->irq);
+               dev_err(card->dev, "cannot obtain IRQ %d\n", pci->irq);
                snd_ad1889_free(chip);
                return -EBUSY;
        }
@@ -965,8 +963,6 @@ snd_ad1889_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
 
        return 0;
@@ -996,7 +992,8 @@ snd_ad1889_probe(struct pci_dev *pci,
        }
 
        /* (2) */
-       err = snd_card_create(index[devno], id[devno], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE,
+                          0, &card);
        /* XXX REVISIT: we can probably allocate chip in this call */
        if (err < 0)
                return err;
index c6835a3d64fb016df4cc865df0469a37a7181411..feb29c24cab132581be6922fe530ef50f137447d 100644 (file)
@@ -64,18 +64,6 @@ static bool enable;
 module_param(enable, bool, 0444);
 
 
-/*
- *  Debug part definitions
- */
-
-/* #define ALI_DEBUG */
-
-#ifdef ALI_DEBUG
-#define snd_ali_printk(format, args...) printk(KERN_DEBUG format, ##args);
-#else
-#define snd_ali_printk(format, args...)
-#endif
-
 /*
  *  Constants definition
  */
@@ -321,7 +309,7 @@ static int snd_ali_codec_ready(struct snd_ali *codec,
        }
 
        snd_ali_5451_poke(codec, port, res & ~0x8000);
-       snd_printdd("ali_codec_ready: codec is not ready.\n ");
+       dev_dbg(codec->card->dev, "ali_codec_ready: codec is not ready.\n ");
        return -EIO;
 }
 
@@ -342,7 +330,7 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
                schedule_timeout_uninterruptible(1);
        }
 
-       snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n");
+       dev_err(codec->card->dev, "ali_stimer_read: stimer is not ready.\n");
        return -EIO;
 }
 
@@ -354,7 +342,8 @@ static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
        unsigned int port;
 
        if (reg >= 0x80) {
-               snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg);
+               dev_err(codec->card->dev,
+                       "ali_codec_poke: reg(%xh) invalid.\n", reg);
                return;
        }
 
@@ -385,7 +374,8 @@ static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
        unsigned int port;
 
        if (reg >= 0x80) {
-               snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg);
+               dev_err(codec->card->dev,
+                       "ali_codec_peek: reg(%xh) invalid.\n", reg);
                return ~0;
        }
 
@@ -417,7 +407,7 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
 {
        struct snd_ali *codec = ac97->private_data;
 
-       snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val);
+       dev_dbg(codec->card->dev, "codec_write: reg=%xh data=%xh.\n", reg, val);
        if (reg == AC97_GPIO_STATUS) {
                outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE,
                     ALI_REG(codec, ALI_AC97_GPIO));
@@ -433,7 +423,7 @@ static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97,
 {
        struct snd_ali *codec = ac97->private_data;
 
-       snd_ali_printk("codec_read reg=%xh.\n", reg);
+       dev_dbg(codec->card->dev, "codec_read reg=%xh.\n", reg);
        return snd_ali_codec_peek(codec, ac97->num, reg);
 }
 
@@ -474,7 +464,7 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
        }
 
        /* non-fatal if you have a non PM capable codec */
-       /* snd_printk(KERN_WARNING "ali5451: reset time out\n"); */
+       /* dev_warn(codec->card->dev, "ali5451: reset time out\n"); */
        return 0;
 }
 
@@ -528,7 +518,7 @@ static void snd_ali_disable_voice_irq(struct snd_ali *codec,
        unsigned int mask;
        struct snd_ali_channel_control *pchregs = &(codec->chregs);
 
-       snd_ali_printk("disable_voice_irq channel=%d\n",channel);
+       dev_dbg(codec->card->dev, "disable_voice_irq channel=%d\n", channel);
 
        mask = 1 << (channel & 0x1f);
        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)
        unsigned int idx =  channel & 0x1f;
 
        if (codec->synth.chcnt >= ALI_CHANNELS){
-               snd_printk(KERN_ERR
+               dev_err(codec->card->dev,
                           "ali_alloc_pcm_channel: no free channels.\n");
                return -1;
        }
@@ -549,7 +539,7 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
        if (!(codec->synth.chmap & (1 << idx))) {
                codec->synth.chmap |= 1 << idx;
                codec->synth.chcnt++;
-               snd_ali_printk("alloc_pcm_channel no. %d.\n",idx);
+               dev_dbg(codec->card->dev, "alloc_pcm_channel no. %d.\n", idx);
                return idx;
        }
        return -1;
@@ -560,7 +550,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
        int idx;
        int result = -1;
 
-       snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm");
+       dev_dbg(codec->card->dev,
+               "find_free_channel: for %s\n", rec ? "rec" : "pcm");
 
        /* recording */
        if (rec) {
@@ -575,8 +566,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
                if (result >= 0)
                        return result;
                else {
-                       snd_printk(KERN_ERR "ali_find_free_channel: "
-                                  "record channel is busy now.\n");
+                       dev_err(codec->card->dev,
+                               "ali_find_free_channel: record channel is busy now.\n");
                        return -1;
                }
        }
@@ -590,8 +581,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
                if (result >= 0)
                        return result;
                else
-                       snd_printk(KERN_ERR "ali_find_free_channel: "
-                                  "S/PDIF out channel is in busy now.\n");
+                       dev_err(codec->card->dev,
+                               "ali_find_free_channel: S/PDIF out channel is in busy now.\n");
        }
 
        for (idx = 0; idx < ALI_CHANNELS; idx++) {
@@ -599,7 +590,7 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
                if (result >= 0)
                        return result;
        }
-       snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n");
+       dev_err(codec->card->dev, "ali_find_free_channel: no free channels.\n");
        return -1;
 }
 
@@ -607,14 +598,15 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
 {
        unsigned int idx = channel & 0x0000001f;
 
-       snd_ali_printk("free_channel_pcm channel=%d\n",channel);
+       dev_dbg(codec->card->dev, "free_channel_pcm channel=%d\n", channel);
 
        if (channel < 0 || channel >= ALI_CHANNELS)
                return;
 
        if (!(codec->synth.chmap & (1 << idx))) {
-               snd_printk(KERN_ERR "ali_free_channel_pcm: "
-                          "channel %d is not in use.\n", channel);
+               dev_err(codec->card->dev,
+                       "ali_free_channel_pcm: channel %d is not in use.\n",
+                       channel);
                return;
        } else {
                codec->synth.chmap &= ~(1 << idx);
@@ -626,7 +618,7 @@ static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
 {
        unsigned int mask = 1 << (channel & 0x1f);
 
-       snd_ali_printk("stop_voice: channel=%d\n",channel);
+       dev_dbg(codec->card->dev, "stop_voice: channel=%d\n", channel);
        outl(mask, ALI_REG(codec, codec->chregs.regs.stop));
 }
 
@@ -667,7 +659,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
        }
 
        if (count > 50000) {
-               snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n");
+               dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
                return;
        }
 
@@ -682,7 +674,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
        }
 
        if (count > 50000) {
-               snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n");
+               dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
                return;
        }
 
@@ -857,9 +849,6 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
        struct snd_ali_voice *pvoice;
        struct snd_ali_channel_control *pchregs;
        unsigned int old, mask;
-#ifdef ALI_DEBUG
-       unsigned int temp, cspf;
-#endif
 
        pchregs = &(codec->chregs);
 
@@ -877,14 +866,11 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
 
        if (pvoice->pcm && pvoice->substream) {
                /* pcm interrupt */
-#ifdef ALI_DEBUG
-               outb((u8)(pvoice->number), ALI_REG(codec, ALI_GC_CIR));
-               temp = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
-               cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
-#endif
                if (pvoice->running) {
-                       snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",
-                                      (u16)temp, cspf);
+                       dev_dbg(codec->card->dev,
+                               "update_ptr: cso=%4.4x cspf=%d.\n",
+                               inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)),
+                               (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask);
                        spin_unlock(&codec->reg_lock);
                        snd_pcm_period_elapsed(pvoice->substream);
                        spin_lock(&codec->reg_lock);
@@ -940,14 +926,14 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
        struct snd_ali_voice *pvoice;
        int idx;
 
-       snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec);
+       dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec);
 
        spin_lock_irq(&codec->voice_alloc);
        if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
                idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
                        snd_ali_find_free_channel(codec,rec);
                if (idx < 0) {
-                       snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
+                       dev_err(codec->card->dev, "ali_alloc_voice: err.\n");
                        spin_unlock_irq(&codec->voice_alloc);
                        return NULL;
                }
@@ -970,7 +956,7 @@ static void snd_ali_free_voice(struct snd_ali * codec,
        void (*private_free)(void *);
        void *private_data;
 
-       snd_ali_printk("free_voice: channel=%d\n",pvoice->number);
+       dev_dbg(codec->card->dev, "free_voice: channel=%d\n", pvoice->number);
        if (!pvoice->use)
                return;
        snd_ali_clear_voices(codec, pvoice->number, pvoice->number);
@@ -1153,7 +1139,7 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
        outl(val, ALI_REG(codec, ALI_AINTEN));
        if (do_start)
                outl(what, ALI_REG(codec, ALI_START));
-       snd_ali_printk("trigger: what=%xh whati=%xh\n", what, whati);
+       dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati);
        spin_unlock(&codec->reg_lock);
 
        return 0;
@@ -1239,7 +1225,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
        unsigned int VOL;
        unsigned int EC;
        
-       snd_ali_printk("playback_prepare ...\n");
+       dev_dbg(codec->card->dev, "playback_prepare ...\n");
 
        spin_lock_irq(&codec->reg_lock);        
        
@@ -1266,7 +1252,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
        /* set target ESO for channel */
        pvoice->eso = runtime->buffer_size; 
 
-       snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",
+       dev_dbg(codec->card->dev, "playback_prepare: eso=%xh count=%xh\n",
                       pvoice->eso, pvoice->count);
 
        /* set ESO to capture first MIDLP interrupt */
@@ -1278,8 +1264,9 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
        PAN = 0;
        VOL = 0;
        EC = 0;
-       snd_ali_printk("playback_prepare:\n");
-       snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
+       dev_dbg(codec->card->dev, "playback_prepare:\n");
+       dev_dbg(codec->card->dev,
+               "ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
                       pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
        snd_ali_write_voice_regs(codec,
                                 pvoice->number,
@@ -1332,7 +1319,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
 
        spin_lock_irq(&codec->reg_lock);
 
-       snd_ali_printk("ali_prepare...\n");
+       dev_dbg(codec->card->dev, "ali_prepare...\n");
 
        snd_ali_enable_special_channel(codec,pvoice->number);
 
@@ -1351,15 +1338,16 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
 
                rate = snd_ali_get_spdif_in_rate(codec);
                if (rate == 0) {
-                       snd_printk(KERN_WARNING "ali_capture_preapre: "
-                                  "spdif rate detect err!\n");
+                       dev_warn(codec->card->dev,
+                                "ali_capture_preapre: spdif rate detect err!\n");
                        rate = 48000;
                }
                spin_lock_irq(&codec->reg_lock);
                bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL));
                if (bValue & 0x10) {
                        outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL));
-                       printk(KERN_WARNING "clear SPDIF parity error flag.\n");
+                       dev_warn(codec->card->dev,
+                                "clear SPDIF parity error flag.\n");
                }
 
                if (rate != 48000)
@@ -1418,7 +1406,7 @@ snd_ali_playback_pointer(struct snd_pcm_substream *substream)
        outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
        cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
        spin_unlock(&codec->reg_lock);
-       snd_ali_printk("playback pointer returned cso=%xh.\n", cso);
+       dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso);
 
        return cso;
 }
@@ -1685,7 +1673,8 @@ static int snd_ali_pcm(struct snd_ali *codec, int device,
        err = snd_pcm_new(codec->card, desc->name, device,
                          desc->playback_num, desc->capture_num, &pcm);
        if (err < 0) {
-               snd_printk(KERN_ERR "snd_ali_pcm: err called snd_pcm_new.\n");
+               dev_err(codec->card->dev,
+                       "snd_ali_pcm: err called snd_pcm_new.\n");
                return err;
        }
        pcm->private_data = codec;
@@ -1861,7 +1850,7 @@ static int snd_ali_mixer(struct snd_ali *codec)
                ac97.num = i;
                err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
                if (err < 0) {
-                       snd_printk(KERN_ERR
+                       dev_err(codec->card->dev,
                                   "ali mixer %d creating error.\n", i);
                        if (i == 0)
                                return err;
@@ -1947,8 +1936,7 @@ static int ali_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "ali5451: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2013,10 +2001,10 @@ static int snd_ali_chip_init(struct snd_ali *codec)
        unsigned char temp;
        struct pci_dev *pci_dev;
 
-       snd_ali_printk("chip initializing ... \n");
+       dev_dbg(codec->card->dev, "chip initializing ...\n");
 
        if (snd_ali_reset_5451(codec)) {
-               snd_printk(KERN_ERR "ali_chip_init: reset 5451 error.\n");
+               dev_err(codec->card->dev, "ali_chip_init: reset 5451 error.\n");
                return -1;
        }
 
@@ -2062,7 +2050,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
                     ALI_REG(codec, ALI_SCTRL));
        }
 
-       snd_ali_printk("chip initialize succeed.\n");
+       dev_dbg(codec->card->dev, "chip initialize succeed.\n");
        return 0;
 
 }
@@ -2088,7 +2076,7 @@ static int snd_ali_resources(struct snd_ali *codec)
 {
        int err;
 
-       snd_ali_printk("resources allocation ...\n");
+       dev_dbg(codec->card->dev, "resources allocation ...\n");
        err = pci_request_regions(codec->pci, "ALI 5451");
        if (err < 0)
                return err;
@@ -2096,11 +2084,11 @@ static int snd_ali_resources(struct snd_ali *codec)
 
        if (request_irq(codec->pci->irq, snd_ali_card_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, codec)) {
-               snd_printk(KERN_ERR "Unable to request irq.\n");
+               dev_err(codec->card->dev, "Unable to request irq.\n");
                return -EBUSY;
        }
        codec->irq = codec->pci->irq;
-       snd_ali_printk("resources allocated.\n");
+       dev_dbg(codec->card->dev, "resources allocated.\n");
        return 0;
 }
 static int snd_ali_dev_free(struct snd_device *device)
@@ -2125,7 +2113,7 @@ static int snd_ali_create(struct snd_card *card,
 
        *r_ali = NULL;
 
-       snd_ali_printk("creating ...\n");
+       dev_dbg(card->dev, "creating ...\n");
 
        /* enable PCI device */
        err = pci_enable_device(pci);
@@ -2134,8 +2122,8 @@ static int snd_ali_create(struct snd_card *card,
        /* check, if we can restrict PCI DMA transfers to 31 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support "
-                          "31bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 31bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -2199,48 +2187,46 @@ static int snd_ali_create(struct snd_card *card,
        /* M1533: southbridge */
        codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
        if (!codec->pci_m1533) {
-               snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
+               dev_err(card->dev, "cannot find ALi 1533 chip.\n");
                snd_ali_free(codec);
                return -ENODEV;
        }
        /* M7101: power management */
        codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
        if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
-               snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
+               dev_err(card->dev, "cannot find ALi 7101 chip.\n");
                snd_ali_free(codec);
                return -ENODEV;
        }
 
-       snd_ali_printk("snd_device_new is called.\n");
+       dev_dbg(card->dev, "snd_device_new is called.\n");
        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
        if (err < 0) {
                snd_ali_free(codec);
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        /* initialise synth voices*/
        for (i = 0; i < ALI_CHANNELS; i++)
                codec->synth.voices[i].number = i;
 
        err = snd_ali_chip_init(codec);
        if (err < 0) {
-               snd_printk(KERN_ERR "ali create: chip init error.\n");
+               dev_err(card->dev, "ali create: chip init error.\n");
                return err;
        }
 
 #ifdef CONFIG_PM_SLEEP
        codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
        if (!codec->image)
-               snd_printk(KERN_WARNING "can't allocate apm buffer\n");
+               dev_warn(card->dev, "can't allocate apm buffer\n");
 #endif
 
        snd_ali_enable_address_interrupt(codec);
        codec->hw_initialized = 1;
 
        *r_ali = codec;
-       snd_ali_printk("created.\n");
+       dev_dbg(card->dev, "created.\n");
        return 0;
 }
 
@@ -2251,9 +2237,9 @@ static int snd_ali_probe(struct pci_dev *pci,
        struct snd_ali *codec;
        int err;
 
-       snd_ali_printk("probe ...\n");
+       dev_dbg(&pci->dev, "probe ...\n");
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -2262,12 +2248,12 @@ static int snd_ali_probe(struct pci_dev *pci,
                goto error;
        card->private_data = codec;
 
-       snd_ali_printk("mixer building ...\n");
+       dev_dbg(&pci->dev, "mixer building ...\n");
        err = snd_ali_mixer(codec);
        if (err < 0)
                goto error;
        
-       snd_ali_printk("pcm building ...\n");
+       dev_dbg(&pci->dev, "pcm building ...\n");
        err = snd_ali_build_pcms(codec);
        if (err < 0)
                goto error;
@@ -2280,7 +2266,7 @@ static int snd_ali_probe(struct pci_dev *pci,
        sprintf(card->longname, "%s at 0x%lx, irq %i",
                card->shortname, codec->port, codec->irq);
 
-       snd_ali_printk("register card.\n");
+       dev_dbg(&pci->dev, "register card.\n");
        err = snd_card_register(card);
        if (err < 0)
                goto error;
index 591efb6eef05687a93ce4cd3b77a8a9134b6aa33..cc9a15a1304ba191f902b91bdebbc835401200d7 100644 (file)
 #define PLAYBACK_BLOCK_COUNTER 0x9A
 #define RECORD_BLOCK_COUNTER   0x9B
 
-#define DEBUG_CALLS    0
 #define DEBUG_PLAY_REC 0
 
-#if DEBUG_CALLS
-#define snd_als300_dbgcalls(format, args...) printk(KERN_DEBUG format, ##args)
-#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
-#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
-#else
-#define snd_als300_dbgcalls(format, args...)
-#define snd_als300_dbgcallenter()
-#define snd_als300_dbgcallleave()
-#endif
-
 #if DEBUG_PLAY_REC
 #define snd_als300_dbgplay(format, args...) printk(KERN_ERR format, ##args)
 #else
@@ -177,7 +166,6 @@ static inline void snd_als300_gcr_write(unsigned long port,
 static void snd_als300_set_irq_flag(struct snd_als300 *chip, int cmd)
 {
        u32 tmp = snd_als300_gcr_read(chip->port, MISC_CONTROL);
-       snd_als300_dbgcallenter();
 
        /* boolean XOR check, since old vs. new hardware have
           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)
        else
                tmp &= ~IRQ_SET_BIT;
        snd_als300_gcr_write(chip->port, MISC_CONTROL, tmp);
-       snd_als300_dbgcallleave();
 }
 
 static int snd_als300_free(struct snd_als300 *chip)
 {
-       snd_als300_dbgcallenter();
        snd_als300_set_irq_flag(chip, IRQ_DISABLE);
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -280,9 +265,7 @@ static irqreturn_t snd_als300plus_interrupt(int irq, void *dev_id)
 
 static void snd_als300_remove(struct pci_dev *pci)
 {
-       snd_als300_dbgcallenter();
        snd_card_free(pci_get_drvdata(pci));
-       snd_als300_dbgcallleave();
 }
 
 static unsigned short snd_als300_ac97_read(struct snd_ac97 *ac97,
@@ -330,14 +313,12 @@ static int snd_als300_ac97(struct snd_als300 *chip)
                .read = snd_als300_ac97_read,
        };
 
-       snd_als300_dbgcallenter();
        if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &bus)) < 0)
                return err;
 
        memset(&ac97, 0, sizeof(ac97));
        ac97.private_data = chip;
 
-       snd_als300_dbgcallleave();
        return snd_ac97_mixer(bus, &ac97, &chip->ac97);
 }
 
@@ -395,13 +376,11 @@ static int snd_als300_playback_open(struct snd_pcm_substream *substream)
 
        if (!data)
                return -ENOMEM;
-       snd_als300_dbgcallenter();
        chip->playback_substream = substream;
        runtime->hw = snd_als300_playback_hw;
        runtime->private_data = data;
        data->control_register = PLAYBACK_CONTROL;
        data->block_counter_register = PLAYBACK_BLOCK_COUNTER;
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -411,11 +390,9 @@ static int snd_als300_playback_close(struct snd_pcm_substream *substream)
        struct snd_als300_substream_data *data;
 
        data = substream->runtime->private_data;
-       snd_als300_dbgcallenter();
        kfree(data);
        chip->playback_substream = NULL;
        snd_pcm_lib_free_pages(substream);
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -428,13 +405,11 @@ static int snd_als300_capture_open(struct snd_pcm_substream *substream)
 
        if (!data)
                return -ENOMEM;
-       snd_als300_dbgcallenter();
        chip->capture_substream = substream;
        runtime->hw = snd_als300_capture_hw;
        runtime->private_data = data;
        data->control_register = RECORD_CONTROL;
        data->block_counter_register = RECORD_BLOCK_COUNTER;
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -444,11 +419,9 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream)
        struct snd_als300_substream_data *data;
 
        data = substream->runtime->private_data;
-       snd_als300_dbgcallenter();
        kfree(data);
        chip->capture_substream = NULL;
        snd_pcm_lib_free_pages(substream);
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -472,7 +445,6 @@ static int snd_als300_playback_prepare(struct snd_pcm_substream *substream)
        unsigned short period_bytes = snd_pcm_lib_period_bytes(substream);
        unsigned short buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
        
-       snd_als300_dbgcallenter();
        spin_lock_irq(&chip->reg_lock);
        tmp = snd_als300_gcr_read(chip->port, PLAYBACK_CONTROL);
        tmp &= ~TRANSFER_START;
@@ -491,7 +463,6 @@ static int snd_als300_playback_prepare(struct snd_pcm_substream *substream)
        snd_als300_gcr_write(chip->port, PLAYBACK_END,
                                        runtime->dma_addr + buffer_bytes - 1);
        spin_unlock_irq(&chip->reg_lock);
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -503,7 +474,6 @@ static int snd_als300_capture_prepare(struct snd_pcm_substream *substream)
        unsigned short period_bytes = snd_pcm_lib_period_bytes(substream);
        unsigned short buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
 
-       snd_als300_dbgcallenter();
        spin_lock_irq(&chip->reg_lock);
        tmp = snd_als300_gcr_read(chip->port, RECORD_CONTROL);
        tmp &= ~TRANSFER_START;
@@ -522,7 +492,6 @@ static int snd_als300_capture_prepare(struct snd_pcm_substream *substream)
        snd_als300_gcr_write(chip->port, RECORD_END,
                                        runtime->dma_addr + buffer_bytes - 1);
        spin_unlock_irq(&chip->reg_lock);
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -537,7 +506,6 @@ static int snd_als300_trigger(struct snd_pcm_substream *substream, int cmd)
        data = substream->runtime->private_data;
        reg = data->control_register;
 
-       snd_als300_dbgcallenter();
        spin_lock(&chip->reg_lock);
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -568,7 +536,6 @@ static int snd_als300_trigger(struct snd_pcm_substream *substream, int cmd)
                ret = -EINVAL;
        }
        spin_unlock(&chip->reg_lock);
-       snd_als300_dbgcallleave();
        return ret;
 }
 
@@ -582,7 +549,6 @@ static snd_pcm_uframes_t snd_als300_pointer(struct snd_pcm_substream *substream)
        data = substream->runtime->private_data;
        period_bytes = snd_pcm_lib_period_bytes(substream);
        
-       snd_als300_dbgcallenter();
        spin_lock(&chip->reg_lock);
        current_ptr = (u16) snd_als300_gcr_read(chip->port,
                                        data->block_counter_register) + 4;
@@ -595,7 +561,6 @@ static snd_pcm_uframes_t snd_als300_pointer(struct snd_pcm_substream *substream)
        if (data->period_flipflop == 0)
                current_ptr += period_bytes;
        snd_als300_dbgplay("Pointer (bytes): %d\n", current_ptr);
-       snd_als300_dbgcallleave();
        return bytes_to_frames(substream->runtime, current_ptr);
 }
 
@@ -626,7 +591,6 @@ static int snd_als300_new_pcm(struct snd_als300 *chip)
        struct snd_pcm *pcm;
        int err;
 
-       snd_als300_dbgcallenter();
        err = snd_pcm_new(chip->card, "ALS300", 0, 1, 1, &pcm);
        if (err < 0)
                return err;
@@ -643,7 +607,6 @@ static int snd_als300_new_pcm(struct snd_als300 *chip)
        /* pre-allocation of buffers */
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
        snd_dma_pci_data(chip->pci), 64*1024, 64*1024);
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -652,7 +615,6 @@ static void snd_als300_init(struct snd_als300 *chip)
        unsigned long flags;
        u32 tmp;
        
-       snd_als300_dbgcallenter();
        spin_lock_irqsave(&chip->reg_lock, flags);
        chip->revision = (snd_als300_gcr_read(chip->port, MISC_CONTROL) >> 16)
                                                                & 0x0000000F;
@@ -679,7 +641,6 @@ static void snd_als300_init(struct snd_als300 *chip)
        snd_als300_gcr_write(chip->port, PLAYBACK_CONTROL,
                        tmp & ~TRANSFER_START);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
-       snd_als300_dbgcallleave();
 }
 
 static int snd_als300_create(struct snd_card *card,
@@ -695,13 +656,12 @@ static int snd_als300_create(struct snd_card *card,
        };
        *rchip = NULL;
 
-       snd_als300_dbgcallenter();
        if ((err = pci_enable_device(pci)) < 0)
                return err;
 
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
                pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
-               printk(KERN_ERR "error setting 28bit DMA mask\n");
+               dev_err(card->dev, "error setting 28bit DMA mask\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -733,7 +693,7 @@ static int snd_als300_create(struct snd_card *card,
 
        if (request_irq(pci->irq, irq_handler, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_als300_free(chip);
                return -EBUSY;
        }
@@ -744,13 +704,13 @@ static int snd_als300_create(struct snd_card *card,
 
        err = snd_als300_ac97(chip);
        if (err < 0) {
-               snd_printk(KERN_WARNING "Could not create ac97\n");
+               dev_err(card->dev, "Could not create ac97\n");
                snd_als300_free(chip);
                return err;
        }
 
        if ((err = snd_als300_new_pcm(chip)) < 0) {
-               snd_printk(KERN_WARNING "Could not create PCM\n");
+               dev_err(card->dev, "Could not create PCM\n");
                snd_als300_free(chip);
                return err;
        }
@@ -761,10 +721,7 @@ static int snd_als300_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
-       snd_als300_dbgcallleave();
        return 0;
 }
 
@@ -794,8 +751,7 @@ static int snd_als300_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "als300: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -829,7 +785,8 @@ static int snd_als300_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
 
        if (err < 0)
                return err;
index ffc821b0139e9a3566ca56856667f443ba954d35..b751c381d25e841d541b61bfff22fe6995a24b4e 100644 (file)
@@ -578,7 +578,7 @@ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id)
                snd_als4k_iobase_readb(chip->alt_port,
                                        ALS4K_IOB_16_ACK_FOR_CR1E);
 
-       /* printk(KERN_INFO "als4000: irq 0x%04x 0x%04x\n",
+       /* dev_dbg(chip->card->dev, "als4000: irq 0x%04x 0x%04x\n",
                                         pci_irqstatus, sb_irqstatus); */
 
        /* 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)
        }
 
        if (!r) {
-               printk(KERN_WARNING "als4000: cannot reserve joystick ports\n");
+               dev_warn(&acard->pci->dev, "cannot reserve joystick ports\n");
                return -EBUSY;
        }
 
        acard->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "als4000: cannot allocate memory for gameport\n");
+               dev_err(&acard->pci->dev, "cannot allocate memory for gameport\n");
                release_and_free_resource(r);
                return -ENOMEM;
        }
@@ -873,7 +873,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
        /* check, if we can restrict PCI DMA transfers to 24 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
+               dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -888,9 +888,9 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
        pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO);
        pci_set_master(pci);
        
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 
-                             sizeof(*acard) /* private_data: acard */,
-                             &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(*acard) /* private_data: acard */,
+                          &card);
        if (err < 0) {
                pci_release_regions(pci);
                pci_disable_device(pci);
@@ -920,7 +920,6 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
 
        chip->pci = pci;
        chip->alt_port = iobase;
-       snd_card_set_dev(card, &pci->dev);
 
        snd_als4000_configure(chip);
 
@@ -934,7 +933,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
                                        MPU401_INFO_INTEGRATED |
                                        MPU401_INFO_IRQ_HOOK,
                                        -1, &chip->rmidi)) < 0) {
-               printk(KERN_ERR "als4000: no MPU-401 device at 0x%lx?\n",
+               dev_err(&pci->dev, "no MPU-401 device at 0x%lx?\n",
                                iobase + ALS4K_IOB_30_MIDI_DATA);
                goto out_err;
        }
@@ -955,7 +954,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
                                iobase + ALS4K_IOB_10_ADLIB_ADDR0,
                                iobase + ALS4K_IOB_12_ADLIB_ADDR2,
                            OPL3_HW_AUTO, 1, &opl3) < 0) {
-               printk(KERN_ERR "als4000: no OPL device at 0x%lx-0x%lx?\n",
+               dev_err(&pci->dev, "no OPL device at 0x%lx-0x%lx?\n",
                           iobase + ALS4K_IOB_10_ADLIB_ADDR0,
                           iobase + ALS4K_IOB_12_ADLIB_ADDR2);
        } else {
@@ -1015,8 +1014,7 @@ static int snd_als4000_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "als4000: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index 5f2acd35dcb9f4ccf26d6263e8fcba1f6a984683..901c9490398a15a254718b7ec3465b786fc41c5f 100644 (file)
@@ -1253,11 +1253,12 @@ static int snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, int device)
                        num_outstreams, num_instreams, &pcm);
        if (err < 0)
                return err;
+
        /* pointer to ops struct is stored, dont change ops afterwards! */
-               snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
-                               &snd_card_asihpi_playback_mmap_ops);
-               snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
-                               &snd_card_asihpi_capture_mmap_ops);
+       snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                       &snd_card_asihpi_playback_mmap_ops);
+       snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
+                       &snd_card_asihpi_capture_mmap_ops);
 
        pcm->private_data = asihpi;
        pcm->info_flags = 0;
@@ -2827,17 +2828,13 @@ static int snd_asihpi_probe(struct pci_dev *pci_dev,
        hpi = pci_get_drvdata(pci_dev);
        adapter_index = hpi->adapter->index;
        /* first try to give the card the same index as its hardware index */
-       err = snd_card_create(adapter_index,
-                             id[adapter_index], THIS_MODULE,
-                             sizeof(struct snd_card_asihpi),
-                             &card);
+       err = snd_card_new(&pci_dev->dev, adapter_index, id[adapter_index],
+                          THIS_MODULE, sizeof(struct snd_card_asihpi), &card);
        if (err < 0) {
                /* if that fails, try the default index==next available */
-               err =
-                   snd_card_create(index[dev], id[dev],
-                                   THIS_MODULE,
-                                   sizeof(struct snd_card_asihpi),
-                                   &card);
+               err = snd_card_new(&pci_dev->dev, index[dev], id[dev],
+                                  THIS_MODULE, sizeof(struct snd_card_asihpi),
+                                  &card);
                if (err < 0)
                        return err;
                snd_printk(KERN_WARNING
@@ -2845,8 +2842,6 @@ static int snd_asihpi_probe(struct pci_dev *pci_dev,
                        adapter_index, card->number);
        }
 
-       snd_card_set_dev(card, &pci_dev->dev);
-
        asihpi = card->private_data;
        asihpi->card = card;
        asihpi->pci = pci_dev;
index f6dec3ea371fa8c8e4e580af71d980e4c6595545..ae07b4926dc2266c562a934a9abb73f3d483bdd5 100644 (file)
@@ -432,7 +432,7 @@ static int snd_atiixp_acquire_codec(struct atiixp *chip)
 
        while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) {
                if (! timeout--) {
-                       snd_printk(KERN_WARNING "atiixp: codec acquire timeout\n");
+                       dev_warn(chip->card->dev, "codec acquire timeout\n");
                        return -EBUSY;
                }
                udelay(1);
@@ -463,7 +463,7 @@ static unsigned short snd_atiixp_codec_read(struct atiixp *chip, unsigned short
        } while (--timeout);
        /* time out may happen during reset */
        if (reg < 0x7c)
-               snd_printk(KERN_WARNING "atiixp: codec read timeout (reg %x)\n", reg);
+               dev_warn(chip->card->dev, "codec read timeout (reg %x)\n", reg);
        return 0xffff;
 }
 
@@ -523,7 +523,7 @@ static int snd_atiixp_aclink_reset(struct atiixp *chip)
                mdelay(1);
                atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
                if (!--timeout) {
-                       snd_printk(KERN_ERR "atiixp: codec reset timeout\n");
+                       dev_err(chip->card->dev, "codec reset timeout\n");
                        break;
                }
        }
@@ -567,9 +567,8 @@ static int ac97_probing_bugs(struct pci_dev *pci)
 
        q = snd_pci_quirk_lookup(pci, atiixp_quirks);
        if (q) {
-               snd_printdd(KERN_INFO
-                           "Atiixp quirk for %s.  Forcing codec %d\n",
-                           snd_pci_quirk_name(q), q->value);
+               dev_dbg(&pci->dev, "atiixp quirk for %s.  Forcing codec %d\n",
+                       snd_pci_quirk_name(q), q->value);
                return q->value;
        }
        /* this hardware doesn't need workarounds.  Probe for codec */
@@ -600,7 +599,7 @@ static int snd_atiixp_codec_detect(struct atiixp *chip)
        atiixp_write(chip, IER, 0); /* disable irqs */
 
        if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) {
-               snd_printk(KERN_ERR "atiixp: no codec detected!\n");
+               dev_err(chip->card->dev, "no codec detected!\n");
                return -ENXIO;
        }
        return 0;
@@ -676,7 +675,7 @@ static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substr
                        continue;
                return bytes_to_frames(runtime, curptr);
        }
-       snd_printd("atiixp: invalid DMA pointer read 0x%x (buf=%x)\n",
+       dev_dbg(chip->card->dev, "invalid DMA pointer read 0x%x (buf=%x)\n",
                   readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
        return 0;
 }
@@ -688,7 +687,7 @@ static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
 {
        if (! dma->substream || ! dma->running)
                return;
-       snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type);
+       dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
        snd_pcm_stream_lock(dma->substream);
        snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
        snd_pcm_stream_unlock(dma->substream);
@@ -1453,14 +1452,15 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock,
                        ac97.scaps |= AC97_SCAP_NO_SPDIF;
                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
                        chip->ac97[i] = NULL; /* to be sure */
-                       snd_printdd("atiixp: codec %d not available for audio\n", i);
+                       dev_dbg(chip->card->dev,
+                               "codec %d not available for audio\n", i);
                        continue;
                }
                codec_count++;
        }
 
        if (! codec_count) {
-               snd_printk(KERN_ERR "atiixp: no codec available\n");
+               dev_err(chip->card->dev, "no codec available\n");
                return -ENODEV;
        }
 
@@ -1511,8 +1511,7 @@ static int snd_atiixp_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "atiixp: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -1637,14 +1636,14 @@ static int snd_atiixp_create(struct snd_card *card,
        chip->addr = pci_resource_start(pci, 0);
        chip->remap_addr = pci_ioremap_bar(pci, 0);
        if (chip->remap_addr == NULL) {
-               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               dev_err(card->dev, "AC'97 space ioremap problem\n");
                snd_atiixp_free(chip);
                return -EIO;
        }
 
        if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_atiixp_free(chip);
                return -EBUSY;
        }
@@ -1657,8 +1656,6 @@ static int snd_atiixp_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_chip = chip;
        return 0;
 }
@@ -1671,7 +1668,7 @@ static int snd_atiixp_probe(struct pci_dev *pci,
        struct atiixp *chip;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index 289563ecb6dd704e0a3f89d81ca19afef63cf98a..b9dc96c5d21ea37c11e502ce884769cbc746dc81 100644 (file)
@@ -400,7 +400,7 @@ static int snd_atiixp_acquire_codec(struct atiixp_modem *chip)
 
        while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) {
                if (! timeout--) {
-                       snd_printk(KERN_WARNING "atiixp-modem: codec acquire timeout\n");
+                       dev_warn(chip->card->dev, "codec acquire timeout\n");
                        return -EBUSY;
                }
                udelay(1);
@@ -433,7 +433,7 @@ static unsigned short snd_atiixp_codec_read(struct atiixp_modem *chip,
        } while (--timeout);
        /* time out may happen during reset */
        if (reg < 0x7c)
-               snd_printk(KERN_WARNING "atiixp-modem: codec read timeout (reg %x)\n", reg);
+               dev_warn(chip->card->dev, "codec read timeout (reg %x)\n", reg);
        return 0xffff;
 }
 
@@ -499,7 +499,7 @@ static int snd_atiixp_aclink_reset(struct atiixp_modem *chip)
                msleep(1);
                atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
                if (!--timeout) {
-                       snd_printk(KERN_ERR "atiixp-modem: codec reset timeout\n");
+                       dev_err(chip->card->dev, "codec reset timeout\n");
                        break;
                }
        }
@@ -553,7 +553,7 @@ static int snd_atiixp_codec_detect(struct atiixp_modem *chip)
        atiixp_write(chip, IER, 0); /* disable irqs */
 
        if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) {
-               snd_printk(KERN_ERR "atiixp-modem: no codec detected!\n");
+               dev_err(chip->card->dev, "no codec detected!\n");
                return -ENXIO;
        }
        return 0;
@@ -624,7 +624,7 @@ static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substr
                        continue;
                return bytes_to_frames(runtime, curptr);
        }
-       snd_printd("atiixp-modem: invalid DMA pointer read 0x%x (buf=%x)\n",
+       dev_dbg(chip->card->dev, "invalid DMA pointer read 0x%x (buf=%x)\n",
                   readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
        return 0;
 }
@@ -637,7 +637,7 @@ static void snd_atiixp_xrun_dma(struct atiixp_modem *chip,
 {
        if (! dma->substream || ! dma->running)
                return;
-       snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type);
+       dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
        snd_pcm_stream_lock(dma->substream);
        snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
        snd_pcm_stream_unlock(dma->substream);
@@ -1098,14 +1098,15 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock)
                ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
                        chip->ac97[i] = NULL; /* to be sure */
-                       snd_printdd("atiixp-modem: codec %d not available for modem\n", i);
+                       dev_dbg(chip->card->dev,
+                               "codec %d not available for modem\n", i);
                        continue;
                }
                codec_count++;
        }
 
        if (! codec_count) {
-               snd_printk(KERN_ERR "atiixp-modem: no codec available\n");
+               dev_err(chip->card->dev, "no codec available\n");
                return -ENODEV;
        }
 
@@ -1150,8 +1151,7 @@ static int snd_atiixp_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "atiixp-modem: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -1262,14 +1262,14 @@ static int snd_atiixp_create(struct snd_card *card,
        chip->addr = pci_resource_start(pci, 0);
        chip->remap_addr = pci_ioremap_bar(pci, 0);
        if (chip->remap_addr == NULL) {
-               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               dev_err(card->dev, "AC'97 space ioremap problem\n");
                snd_atiixp_free(chip);
                return -EIO;
        }
 
        if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_atiixp_free(chip);
                return -EBUSY;
        }
@@ -1282,8 +1282,6 @@ static int snd_atiixp_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_chip = chip;
        return 0;
 }
@@ -1296,7 +1294,7 @@ static int snd_atiixp_probe(struct pci_dev *pci,
        struct atiixp_modem *chip;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index 7059dd69e5e611598530edf8ba6b6beba7a16050..afb1b44b741e0d31c51ad0afa92150cb9bf0ec54 100644 (file)
@@ -211,8 +211,6 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
                goto alloc_out;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
 
        return 0;
@@ -250,7 +248,8 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                return -ENOENT;
        }
        // (2)
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
index 2925220d3fcf84afdd27c0636b5b1939cd087f3f..120d0d320a6094bb788b3c5bc6cc14ef2c9df8b7 100644 (file)
@@ -262,7 +262,7 @@ static int snd_aw2_create(struct snd_card *card,
        /* check PCI availability (32bit DMA) */
        if ((pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) ||
            (pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0)) {
-               printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n");
+               dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -290,7 +290,7 @@ static int snd_aw2_create(struct snd_card *card,
                                pci_resource_len(pci, 0));
 
        if (chip->iobase_virt == NULL) {
-               printk(KERN_ERR "aw2: unable to remap memory region");
+               dev_err(card->dev, "unable to remap memory region");
                pci_release_regions(pci);
                pci_disable_device(pci);
                kfree(chip);
@@ -302,7 +302,7 @@ static int snd_aw2_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_aw2_saa7146_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR "aw2: Cannot grab irq %d\n", pci->irq);
+               dev_err(card->dev, "Cannot grab irq %d\n", pci->irq);
 
                iounmap(chip->iobase_virt);
                pci_release_regions(chip->pci);
@@ -322,12 +322,10 @@ static int snd_aw2_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
        *rchip = chip;
 
-       printk(KERN_INFO
-              "Audiowerk 2 sound card (saa7146 chipset) detected and "
-              "managed\n");
+       dev_info(card->dev,
+                "Audiowerk 2 sound card (saa7146 chipset) detected and managed\n");
        return 0;
 }
 
@@ -349,7 +347,8 @@ static int snd_aw2_probe(struct pci_dev *pci,
        }
 
        /* (2) Create card instance */
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -399,7 +398,7 @@ static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       snd_printdd(KERN_DEBUG "aw2: Playback_open\n");
+       dev_dbg(substream->pcm->card->dev, "Playback_open\n");
        runtime->hw = snd_aw2_playback_hw;
        return 0;
 }
@@ -415,7 +414,7 @@ static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       snd_printdd(KERN_DEBUG "aw2: Capture_open\n");
+       dev_dbg(substream->pcm->card->dev, "Capture_open\n");
        runtime->hw = snd_aw2_capture_hw;
        return 0;
 }
@@ -603,7 +602,7 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
        err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0,
                          &pcm_playback_ana);
        if (err < 0) {
-               printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
+               dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
                return err;
        }
 
@@ -633,14 +632,15 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
                                                    (chip->pci),
                                                    64 * 1024, 64 * 1024);
        if (err)
-               printk(KERN_ERR "aw2: snd_pcm_lib_preallocate_pages_for_all "
-                      "error (0x%X)\n", err);
+               dev_err(chip->card->dev,
+                       "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
+                       err);
 
        err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
                          &pcm_playback_num);
 
        if (err < 0) {
-               printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
+               dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
                return err;
        }
        /* Creation ok */
@@ -669,17 +669,15 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
                                                    (chip->pci),
                                                    64 * 1024, 64 * 1024);
        if (err)
-               printk(KERN_ERR
-                      "aw2: snd_pcm_lib_preallocate_pages_for_all error "
-                      "(0x%X)\n", err);
-
-
+               dev_err(chip->card->dev,
+                       "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
+                       err);
 
        err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
                          &pcm_capture);
 
        if (err < 0) {
-               printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
+               dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
                return err;
        }
 
@@ -709,15 +707,15 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
                                                    (chip->pci),
                                                    64 * 1024, 64 * 1024);
        if (err)
-               printk(KERN_ERR
-                      "aw2: snd_pcm_lib_preallocate_pages_for_all error "
-                      "(0x%X)\n", err);
+               dev_err(chip->card->dev,
+                       "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
+                       err);
 
 
        /* Create control */
        err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
        if (err < 0) {
-               printk(KERN_ERR "aw2: snd_ctl_add error (0x%X)\n", err);
+               dev_err(chip->card->dev, "snd_ctl_add error (0x%X)\n", err);
                return err;
        }
 
index 4439636971eb4c4c215ba49cff8c0b6015b873b2..6d24e95367772c352f6ed903ca410e876d1812e5 100644 (file)
@@ -204,8 +204,7 @@ void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
                /* Define upper limit for DMA access */
                WRITEREG(dma_addr + buffer_size, ProtA1_out);
        } else {
-               printk(KERN_ERR
-                      "aw2: snd_aw2_saa7146_pcm_init_playback: "
+               pr_err("aw2: snd_aw2_saa7146_pcm_init_playback: "
                       "Substream number is not 0 or 1 -> not managed\n");
        }
 }
@@ -251,8 +250,7 @@ void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
                /* Define upper limit for DMA access  */
                WRITEREG(dma_addr + buffer_size, ProtA1_in);
        } else {
-               printk(KERN_ERR
-                      "aw2: snd_aw2_saa7146_pcm_init_capture: "
+               pr_err("aw2: snd_aw2_saa7146_pcm_init_capture: "
                       "Substream number is not 0 -> not managed\n");
        }
 }
index 1aef7128f7caa97e0daacaeb312ee60d1ec9225f..c9216c0a9c8b06cfa284401d5f280ad80be13d31 100644 (file)
@@ -238,61 +238,6 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
     2>/dev/null
 */
 
-#define DEBUG_MISC     0
-#define DEBUG_CALLS    0
-#define DEBUG_MIXER    0
-#define DEBUG_CODEC    0
-#define DEBUG_TIMER    0
-#define DEBUG_GAME     0
-#define DEBUG_PM       0
-#define MIXER_TESTING  0
-
-#if DEBUG_MISC
-#define snd_azf3328_dbgmisc(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define snd_azf3328_dbgmisc(format, args...)
-#endif
-
-#if DEBUG_CALLS
-#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args)
-#define snd_azf3328_dbgcallenter() printk(KERN_DEBUG "--> %s\n", __func__)
-#define snd_azf3328_dbgcallleave() printk(KERN_DEBUG "<-- %s\n", __func__)
-#else
-#define snd_azf3328_dbgcalls(format, args...)
-#define snd_azf3328_dbgcallenter()
-#define snd_azf3328_dbgcallleave()
-#endif
-
-#if DEBUG_MIXER
-#define snd_azf3328_dbgmixer(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define snd_azf3328_dbgmixer(format, args...)
-#endif
-
-#if DEBUG_CODEC
-#define snd_azf3328_dbgcodec(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define snd_azf3328_dbgcodec(format, args...)
-#endif
-
-#if DEBUG_MISC
-#define snd_azf3328_dbgtimer(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define snd_azf3328_dbgtimer(format, args...)
-#endif
-
-#if DEBUG_GAME
-#define snd_azf3328_dbggame(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define snd_azf3328_dbggame(format, args...)
-#endif
-
-#if DEBUG_PM
-#define snd_azf3328_dbgpm(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define snd_azf3328_dbgpm(format, args...)
-#endif
-
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard.");
@@ -475,6 +420,12 @@ snd_azf3328_ctrl_inb(const struct snd_azf3328 *chip, unsigned reg)
        return inb(chip->ctrl_io + reg);
 }
 
+static inline u16
+snd_azf3328_ctrl_inw(const struct snd_azf3328 *chip, unsigned reg)
+{
+       return inw(chip->ctrl_io + reg);
+}
+
 static inline void
 snd_azf3328_ctrl_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value)
 {
@@ -578,11 +529,12 @@ snd_azf3328_mixer_reset(const struct snd_azf3328 *chip)
 #ifdef AZF_USE_AC97_LAYER
 
 static inline void
-snd_azf3328_mixer_ac97_map_unsupported(unsigned short reg, const char *mode)
+snd_azf3328_mixer_ac97_map_unsupported(const struct snd_azf3328 *chip,
+                                      unsigned short reg, const char *mode)
 {
        /* need to add some more or less clever emulation? */
-       printk(KERN_WARNING
-               "azt3328: missing %s emulation for AC97 register 0x%02x!\n",
+       dev_warn(chip->card->dev,
+               "missing %s emulation for AC97 register 0x%02x!\n",
                mode, reg);
 }
 
@@ -717,10 +669,8 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
        unsigned short reg_val = 0;
        bool unsupported = false;
 
-       snd_azf3328_dbgmixer(
-               "snd_azf3328_mixer_ac97_read reg_ac97 %u\n",
-                       reg_ac97
-       );
+       dev_dbg(chip->card->dev, "snd_azf3328_mixer_ac97_read reg_ac97 %u\n",
+               reg_ac97);
        if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
                unsupported = true;
        else {
@@ -765,7 +715,7 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
                }
        }
        if (unsupported)
-               snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "read");
+               snd_azf3328_mixer_ac97_map_unsupported(chip, reg_ac97, "read");
 
        return reg_val;
 }
@@ -778,10 +728,9 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
        unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97);
        bool unsupported = false;
 
-       snd_azf3328_dbgmixer(
+       dev_dbg(chip->card->dev,
                "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n",
-                       reg_ac97, val
-       );
+               reg_ac97, val);
        if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
                unsupported = true;
        else {
@@ -814,7 +763,7 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
                }
        }
        if (unsupported)
-               snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "write");
+               snd_azf3328_mixer_ac97_map_unsupported(chip, reg_ac97, "write");
 }
 
 static int
@@ -850,7 +799,7 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
                 * due to this card being a very quirky AC97 "lookalike".
                 */
        if (rc)
-               printk(KERN_ERR "azt3328: AC97 init failed, err %d!\n", rc);
+               dev_err(chip->card->dev, "AC97 init failed, err %d!\n", rc);
 
        /* If we return an error here, then snd_card_free() should
         * 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,
        unsigned char curr_vol_left = 0, curr_vol_right = 0;
        int left_change = 0, right_change = 0;
 
-       snd_azf3328_dbgcallenter();
-
        if (chan_sel & SET_CHAN_LEFT) {
                curr_vol_left  = inb(portbase + 1);
 
@@ -912,7 +859,6 @@ snd_azf3328_mixer_write_volume_gradually(const struct snd_azf3328 *chip,
                if (delay)
                        mdelay(delay);
        } while ((left_change) || (right_change));
-       snd_azf3328_dbgcallleave();
 }
 
 /*
@@ -990,14 +936,12 @@ snd_azf3328_info_mixer(struct snd_kcontrol *kcontrol,
 {
        struct azf3328_mixer_reg reg;
 
-       snd_azf3328_dbgcallenter();
        snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value);
        uinfo->type = reg.mask == 1 ?
                SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = reg.stereo + 1;
        uinfo->value.integer.min = 0;
        uinfo->value.integer.max = reg.mask;
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -1009,7 +953,6 @@ snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol,
        struct azf3328_mixer_reg reg;
        u16 oreg, val;
 
-       snd_azf3328_dbgcallenter();
        snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value);
 
        oreg = snd_azf3328_mixer_inw(chip, reg.reg);
@@ -1023,12 +966,11 @@ snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol,
                        val = reg.mask - val;
                ucontrol->value.integer.value[1] = val;
        }
-       snd_azf3328_dbgmixer("get: %02x is %04x -> vol %02lx|%02lx "
-                            "(shift %02d|%02d, mask %02x, inv. %d, stereo %d)\n",
+       dev_dbg(chip->card->dev,
+               "get: %02x is %04x -> vol %02lx|%02lx (shift %02d|%02d, mask %02x, inv. %d, stereo %d)\n",
                reg.reg, oreg,
                ucontrol->value.integer.value[0], ucontrol->value.integer.value[1],
                reg.lchan_shift, reg.rchan_shift, reg.mask, reg.invert, reg.stereo);
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -1040,7 +982,6 @@ snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol,
        struct azf3328_mixer_reg reg;
        u16 oreg, nreg, val;
 
-       snd_azf3328_dbgcallenter();
        snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value);
        oreg = snd_azf3328_mixer_inw(chip, reg.reg);
        val = ucontrol->value.integer.value[0] & reg.mask;
@@ -1064,12 +1005,11 @@ snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol,
        else
                snd_azf3328_mixer_outw(chip, reg.reg, nreg);
 
-       snd_azf3328_dbgmixer("put: %02x to %02lx|%02lx, "
-                            "oreg %04x; shift %02d|%02d -> nreg %04x; after: %04x\n",
+       dev_dbg(chip->card->dev,
+               "put: %02x to %02lx|%02lx, oreg %04x; shift %02d|%02d -> nreg %04x; after: %04x\n",
                reg.reg, ucontrol->value.integer.value[0], ucontrol->value.integer.value[1],
                oreg, reg.lchan_shift, reg.rchan_shift,
                nreg, snd_azf3328_mixer_inw(chip, reg.reg));
-       snd_azf3328_dbgcallleave();
        return (nreg != oreg);
 }
 
@@ -1135,7 +1075,8 @@ snd_azf3328_get_mixer_enum(struct snd_kcontrol *kcontrol,
        } else
                ucontrol->value.enumerated.item[0] = (val >> reg.lchan_shift) & (reg.enum_c - 1);
 
-       snd_azf3328_dbgmixer("get_enum: %02x is %04x -> %d|%d (shift %02d, enum_c %d)\n",
+       dev_dbg(chip->card->dev,
+               "get_enum: %02x is %04x -> %d|%d (shift %02d, enum_c %d)\n",
                reg.reg, val, ucontrol->value.enumerated.item[0], ucontrol->value.enumerated.item[1],
                reg.lchan_shift, reg.enum_c);
         return 0;
@@ -1167,7 +1108,8 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol,
        snd_azf3328_mixer_outw(chip, reg.reg, val);
        nreg = val;
 
-       snd_azf3328_dbgmixer("put_enum: %02x to %04x, oreg %04x\n", reg.reg, val, oreg);
+       dev_dbg(chip->card->dev,
+               "put_enum: %02x to %04x, oreg %04x\n", reg.reg, val, oreg);
        return (nreg != oreg);
 }
 
@@ -1253,7 +1195,6 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
        unsigned int idx;
        int err;
 
-       snd_azf3328_dbgcallenter();
        if (snd_BUG_ON(!chip || !chip->card))
                return -EINVAL;
 
@@ -1279,7 +1220,6 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
        snd_component_add(card, "AZF3328 mixer");
        strcpy(card->mixername, "AZF3328 mixer");
 
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 #endif /* AZF_USE_AC97_LAYER */
@@ -1288,19 +1228,13 @@ static int
 snd_azf3328_hw_params(struct snd_pcm_substream *substream,
                                 struct snd_pcm_hw_params *hw_params)
 {
-       int res;
-       snd_azf3328_dbgcallenter();
-       res = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
-       snd_azf3328_dbgcallleave();
-       return res;
+       return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
 }
 
 static int
 snd_azf3328_hw_free(struct snd_pcm_substream *substream)
 {
-       snd_azf3328_dbgcallenter();
        snd_pcm_lib_free_pages(substream);
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -1315,7 +1249,6 @@ snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec,
        u16 val = 0xff00;
        u8 freq = 0;
 
-       snd_azf3328_dbgcallenter();
        switch (bitrate) {
        case AZF_FREQ_4000:  freq = SOUNDFORMAT_FREQ_SUSPECTED_4000; break;
        case AZF_FREQ_4800:  freq = SOUNDFORMAT_FREQ_SUSPECTED_4800; break;
@@ -1379,7 +1312,6 @@ snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec,
                );
 
        spin_unlock_irqrestore(codec->lock, flags);
-       snd_azf3328_dbgcallleave();
 }
 
 static inline void
@@ -1404,15 +1336,16 @@ snd_azf3328_ctrl_reg_6AH_update(struct snd_azf3328 *chip,
                chip->shadow_reg_ctrl_6AH |= bitmask;
        else
                chip->shadow_reg_ctrl_6AH &= ~bitmask;
-       snd_azf3328_dbgcodec("6AH_update mask 0x%04x do_mask %d: val 0x%04x\n",
-                       bitmask, do_mask, chip->shadow_reg_ctrl_6AH);
+       dev_dbg(chip->card->dev,
+               "6AH_update mask 0x%04x do_mask %d: val 0x%04x\n",
+               bitmask, do_mask, chip->shadow_reg_ctrl_6AH);
        snd_azf3328_ctrl_outw(chip, IDX_IO_6AH, chip->shadow_reg_ctrl_6AH);
 }
 
 static inline void
 snd_azf3328_ctrl_enable_codecs(struct snd_azf3328 *chip, bool enable)
 {
-       snd_azf3328_dbgcodec("codec_enable %d\n", enable);
+       dev_dbg(chip->card->dev, "codec_enable %d\n", enable);
        /* no idea what exactly is being done here, but I strongly assume it's
         * PM related */
        snd_azf3328_ctrl_reg_6AH_update(
@@ -1429,7 +1362,7 @@ snd_azf3328_ctrl_codec_activity(struct snd_azf3328 *chip,
        struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type];
        bool need_change = (codec->running != enable);
 
-       snd_azf3328_dbgcodec(
+       dev_dbg(chip->card->dev,
                "codec_activity: %s codec, enable %d, need_change %d\n",
                                codec->name, enable, need_change
        );
@@ -1470,13 +1403,13 @@ snd_azf3328_ctrl_codec_activity(struct snd_azf3328 *chip,
 }
 
 static void
-snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec,
-                               unsigned long addr,
-                               unsigned int period_bytes,
-                               unsigned int buffer_bytes
+snd_azf3328_codec_setdmaa(struct snd_azf3328 *chip,
+                         struct snd_azf3328_codec_data *codec,
+                         unsigned long addr,
+                         unsigned int period_bytes,
+                         unsigned int buffer_bytes
 )
 {
-       snd_azf3328_dbgcallenter();
        WARN_ONCE(period_bytes & 1, "odd period length!?\n");
        WARN_ONCE(buffer_bytes != 2 * period_bytes,
                 "missed our input expectations! %u vs. %u\n",
@@ -1499,7 +1432,7 @@ snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec,
                setup_io.dma_start_1 = addr;
                setup_io.dma_start_2 = addr+area_length;
 
-               snd_azf3328_dbgcodec(
+               dev_dbg(chip->card->dev,
                        "setdma: buffers %08x[%u] / %08x[%u], %u, %u\n",
                                setup_io.dma_start_1, area_length,
                                setup_io.dma_start_2, area_length,
@@ -1522,7 +1455,6 @@ snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec,
                );
                spin_unlock_irqrestore(codec->lock, flags);
        }
-       snd_azf3328_dbgcallleave();
 }
 
 static int
@@ -1535,8 +1467,6 @@ snd_azf3328_pcm_prepare(struct snd_pcm_substream *substream)
        unsigned int count = snd_pcm_lib_period_bytes(substream);
 #endif
 
-       snd_azf3328_dbgcallenter();
-
        codec->dma_base = runtime->dma_addr;
 
 #if 0
@@ -1544,10 +1474,9 @@ snd_azf3328_pcm_prepare(struct snd_pcm_substream *substream)
                runtime->rate,
                snd_pcm_format_width(runtime->format),
                runtime->channels);
-       snd_azf3328_codec_setdmaa(codec,
+       snd_azf3328_codec_setdmaa(chip, codec,
                                        runtime->dma_addr, count, size);
 #endif
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -1562,11 +1491,9 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        bool previously_muted = false;
        bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type);
 
-       snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd);
-
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
-               snd_azf3328_dbgcodec("START %s\n", codec->name);
+               dev_dbg(chip->card->dev, "START PCM %s\n", codec->name);
 
                if (is_main_mixer_playback_codec) {
                        /* mute WaveOut (avoid clicking during setup) */
@@ -1593,7 +1520,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                snd_azf3328_codec_outw(codec, IDX_IO_CODEC_IRQTYPE, 0xffff);
                spin_unlock(codec->lock);
 
-               snd_azf3328_codec_setdmaa(codec, runtime->dma_addr,
+               snd_azf3328_codec_setdmaa(chip, codec, runtime->dma_addr,
                        snd_pcm_lib_period_bytes(substream),
                        snd_pcm_lib_buffer_bytes(substream)
                );
@@ -1633,10 +1560,10 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                                );
                }
 
-               snd_azf3328_dbgcodec("STARTED %s\n", codec->name);
+               dev_dbg(chip->card->dev, "PCM STARTED %s\n", codec->name);
                break;
        case SNDRV_PCM_TRIGGER_RESUME:
-               snd_azf3328_dbgcodec("RESUME %s\n", codec->name);
+               dev_dbg(chip->card->dev, "PCM RESUME %s\n", codec->name);
                /* resume codec if we were active */
                spin_lock(codec->lock);
                if (codec->running)
@@ -1648,7 +1575,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                spin_unlock(codec->lock);
                break;
        case SNDRV_PCM_TRIGGER_STOP:
-               snd_azf3328_dbgcodec("STOP %s\n", codec->name);
+               dev_dbg(chip->card->dev, "PCM STOP %s\n", codec->name);
 
                if (is_main_mixer_playback_codec) {
                        /* mute WaveOut (avoid clicking during setup) */
@@ -1684,10 +1611,10 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                                );
                }
 
-               snd_azf3328_dbgcodec("STOPPED %s\n", codec->name);
+               dev_dbg(chip->card->dev, "PCM STOPPED %s\n", codec->name);
                break;
        case SNDRV_PCM_TRIGGER_SUSPEND:
-               snd_azf3328_dbgcodec("SUSPEND %s\n", codec->name);
+               dev_dbg(chip->card->dev, "PCM SUSPEND %s\n", codec->name);
                /* make sure codec is stopped */
                snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS,
                        snd_azf3328_codec_inw(
@@ -1696,17 +1623,16 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                );
                break;
         case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-               snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n");
+               WARN(1, "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n");
                 break;
         case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-               snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n");
+               WARN(1, "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n");
                 break;
         default:
-               snd_printk(KERN_ERR "FIXME: unknown trigger mode!\n");
+               WARN(1, "FIXME: unknown trigger mode!\n");
                 return -EINVAL;
        }
 
-       snd_azf3328_dbgcallleave();
        return result;
 }
 
@@ -1728,8 +1654,8 @@ snd_azf3328_pcm_pointer(struct snd_pcm_substream *substream
        result -= codec->dma_base;
 #endif
        frmres = bytes_to_frames( substream->runtime, result);
-       snd_azf3328_dbgcodec("%08li %s @ 0x%8lx, frames %8ld\n",
-                               jiffies, codec->name, result, frmres);
+       dev_dbg(substream->pcm->card->dev, "%08li %s @ 0x%8lx, frames %8ld\n",
+               jiffies, codec->name, result, frmres);
        return frmres;
 }
 
@@ -1792,7 +1718,7 @@ snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip)
         * skeleton handler only
         * (we do not want axis reading in interrupt handler - too much load!)
         */
-       snd_azf3328_dbggame("gameport irq\n");
+       dev_dbg(chip->card->dev, "gameport irq\n");
 
         /* this should ACK the gameport IRQ properly, hopefully. */
        snd_azf3328_game_inw(chip, IDX_GAME_AXIS_VALUE);
@@ -1804,7 +1730,7 @@ snd_azf3328_gameport_open(struct gameport *gameport, int mode)
        struct snd_azf3328 *chip = gameport_get_port_data(gameport);
        int res;
 
-       snd_azf3328_dbggame("gameport_open, mode %d\n", mode);
+       dev_dbg(chip->card->dev, "gameport_open, mode %d\n", mode);
        switch (mode) {
        case GAMEPORT_MODE_COOKED:
        case GAMEPORT_MODE_RAW:
@@ -1827,7 +1753,7 @@ snd_azf3328_gameport_close(struct gameport *gameport)
 {
        struct snd_azf3328 *chip = gameport_get_port_data(gameport);
 
-       snd_azf3328_dbggame("gameport_close\n");
+       dev_dbg(chip->card->dev, "gameport_close\n");
        snd_azf3328_gameport_set_counter_frequency(chip,
                                GAME_HWCFG_ADC_COUNTER_FREQ_1_200);
        snd_azf3328_gameport_axis_circuit_enable(chip, 0);
@@ -1892,9 +1818,8 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport,
                        axes[i] = -1;
        }
 
-       snd_azf3328_dbggame("cooked_read: axes %d %d %d %d buttons %d\n",
-               axes[0], axes[1], axes[2], axes[3], *buttons
-       );
+       dev_dbg(chip->card->dev, "cooked_read: axes %d %d %d %d buttons %d\n",
+               axes[0], axes[1], axes[2], axes[3], *buttons);
 
        return 0;
 }
@@ -1906,7 +1831,7 @@ snd_azf3328_gameport(struct snd_azf3328 *chip, int dev)
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "azt3328: cannot alloc memory for gameport\n");
+               dev_err(chip->card->dev, "cannot alloc memory for gameport\n");
                return -ENOMEM;
        }
 
@@ -1950,23 +1875,23 @@ snd_azf3328_gameport_free(struct snd_azf3328 *chip) { }
 static inline void
 snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip)
 {
-       printk(KERN_WARNING "huh, game port IRQ occurred!?\n");
+       dev_warn(chip->card->dev, "huh, game port IRQ occurred!?\n");
 }
 #endif /* SUPPORT_GAMEPORT */
 
 /******************************************************************/
 
 static inline void
-snd_azf3328_irq_log_unknown_type(u8 which)
+snd_azf3328_irq_log_unknown_type(struct snd_azf3328 *chip, u8 which)
 {
-       snd_azf3328_dbgcodec(
-       "azt3328: unknown IRQ type (%x) occurred, please report!\n",
-               which
-       );
+       dev_dbg(chip->card->dev,
+               "unknown IRQ type (%x) occurred, please report!\n",
+               which);
 }
 
 static inline void
-snd_azf3328_pcm_interrupt(const struct snd_azf3328_codec_data *first_codec,
+snd_azf3328_pcm_interrupt(struct snd_azf3328 *chip,
+                         const struct snd_azf3328_codec_data *first_codec,
                          u8 status
 )
 {
@@ -1990,17 +1915,15 @@ snd_azf3328_pcm_interrupt(const struct snd_azf3328_codec_data *first_codec,
 
                if (codec->substream) {
                        snd_pcm_period_elapsed(codec->substream);
-                       snd_azf3328_dbgcodec("%s period done (#%x), @ %x\n",
+                       dev_dbg(chip->card->dev, "%s period done (#%x), @ %x\n",
                                codec->name,
                                which,
                                snd_azf3328_codec_inl(
-                                       codec, IDX_IO_CODEC_DMA_CURRPOS
-                               )
-                       );
+                                       codec, IDX_IO_CODEC_DMA_CURRPOS));
                } else
-                       printk(KERN_WARNING "azt3328: irq handler problem!\n");
+                       dev_warn(chip->card->dev, "irq handler problem!\n");
                if (which & IRQ_SOMETHING)
-                       snd_azf3328_irq_log_unknown_type(which);
+                       snd_azf3328_irq_log_unknown_type(chip, which);
        }
 }
 
@@ -2009,9 +1932,7 @@ snd_azf3328_interrupt(int irq, void *dev_id)
 {
        struct snd_azf3328 *chip = dev_id;
        u8 status;
-#if DEBUG_CODEC
        static unsigned long irq_count;
-#endif
 
        status = snd_azf3328_ctrl_inb(chip, IDX_IO_IRQSTATUS);
 
@@ -2022,14 +1943,13 @@ snd_azf3328_interrupt(int irq, void *dev_id)
        ))
                return IRQ_NONE; /* must be interrupt for another device */
 
-       snd_azf3328_dbgcodec(
+       dev_dbg(chip->card->dev,
                "irq_count %ld! IDX_IO_IRQSTATUS %04x\n",
                        irq_count++ /* debug-only */,
-                       status
-       );
+                       status);
 
        if (status & IRQ_TIMER) {
-               /* snd_azf3328_dbgcodec("timer %ld\n",
+               /* dev_dbg(chip->card->dev, "timer %ld\n",
                        snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE)
                                & TIMER_VALUE_MASK
                ); */
@@ -2039,11 +1959,11 @@ snd_azf3328_interrupt(int irq, void *dev_id)
                 spin_lock(&chip->reg_lock);
                snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07);
                spin_unlock(&chip->reg_lock);
-               snd_azf3328_dbgcodec("azt3328: timer IRQ\n");
+               dev_dbg(chip->card->dev, "timer IRQ\n");
        }
 
        if (status & (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT))
-               snd_azf3328_pcm_interrupt(chip->codecs, status);
+               snd_azf3328_pcm_interrupt(chip, chip->codecs, status);
 
        if (status & IRQ_GAMEPORT)
                snd_azf3328_gameport_interrupt(chip);
@@ -2055,7 +1975,7 @@ snd_azf3328_interrupt(int irq, void *dev_id)
 
                /* hmm, do we have to ack the IRQ here somehow?
                 * If so, then I don't know how yet... */
-               snd_azf3328_dbgcodec("azt3328: MPU401 IRQ\n");
+               dev_dbg(chip->card->dev, "MPU401 IRQ\n");
        }
        return IRQ_HANDLED;
 }
@@ -2133,7 +2053,6 @@ snd_azf3328_pcm_open(struct snd_pcm_substream *substream,
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type];
 
-       snd_azf3328_dbgcallenter();
        codec->substream = substream;
 
        /* same parameters for all our codecs - at least we think so... */
@@ -2142,7 +2061,6 @@ snd_azf3328_pcm_open(struct snd_pcm_substream *substream,
        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
                                   &snd_azf3328_hw_constraints_rates);
        runtime->private_data = codec;
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -2171,9 +2089,7 @@ snd_azf3328_pcm_close(struct snd_pcm_substream *substream
        struct snd_azf3328_codec_data *codec =
                substream->runtime->private_data;
 
-       snd_azf3328_dbgcallenter();
        codec->substream = NULL;
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -2220,8 +2136,6 @@ enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */
        struct snd_pcm *pcm;
        int err;
 
-       snd_azf3328_dbgcallenter();
-
        err = snd_pcm_new(chip->card, "AZF3328 DSP", AZF_PCMDEV_STD,
                                                                1, 1, &pcm);
        if (err < 0)
@@ -2258,7 +2172,6 @@ enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */
                                                snd_dma_pci_data(chip->pci),
                                                        64*1024, 64*1024);
 
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -2281,7 +2194,6 @@ snd_azf3328_timer_start(struct snd_timer *timer)
        unsigned long flags;
        unsigned int delay;
 
-       snd_azf3328_dbgcallenter();
        chip = snd_timer_chip(timer);
        delay = ((timer->sticks * seqtimer_scaling) - 1) & TIMER_VALUE_MASK;
        if (delay < 49) {
@@ -2289,15 +2201,14 @@ snd_azf3328_timer_start(struct snd_timer *timer)
                 * this timing tweak
                 * (we need to do it to avoid a lockup, though) */
 
-               snd_azf3328_dbgtimer("delay was too low (%d)!\n", delay);
+               dev_dbg(chip->card->dev, "delay was too low (%d)!\n", delay);
                delay = 49; /* minimum time is 49 ticks */
        }
-       snd_azf3328_dbgtimer("setting timer countdown value %d\n", delay);
+       dev_dbg(chip->card->dev, "setting timer countdown value %d\n", delay);
        delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE;
        spin_lock_irqsave(&chip->reg_lock, flags);
        snd_azf3328_ctrl_outl(chip, IDX_IO_TIMER_VALUE, delay);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -2307,7 +2218,6 @@ snd_azf3328_timer_stop(struct snd_timer *timer)
        struct snd_azf3328 *chip;
        unsigned long flags;
 
-       snd_azf3328_dbgcallenter();
        chip = snd_timer_chip(timer);
        spin_lock_irqsave(&chip->reg_lock, flags);
        /* disable timer countdown and interrupt */
@@ -2319,7 +2229,6 @@ snd_azf3328_timer_stop(struct snd_timer *timer)
           the hardware/ALSA interrupt activity. */
        snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x04);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -2328,10 +2237,8 @@ static int
 snd_azf3328_timer_precise_resolution(struct snd_timer *timer,
                                               unsigned long *num, unsigned long *den)
 {
-       snd_azf3328_dbgcallenter();
        *num = 1;
        *den = 1024000 / seqtimer_scaling;
-       snd_azf3328_dbgcallleave();
        return 0;
 }
 
@@ -2351,7 +2258,6 @@ snd_azf3328_timer(struct snd_azf3328 *chip, int device)
        struct snd_timer_id tid;
        int err;
 
-       snd_azf3328_dbgcallenter();
        tid.dev_class = SNDRV_TIMER_CLASS_CARD;
        tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE;
        tid.card = chip->card->number;
@@ -2376,7 +2282,6 @@ snd_azf3328_timer(struct snd_azf3328 *chip, int device)
        err = 0;
 
 out:
-       snd_azf3328_dbgcallleave();
        return err;
 }
 
@@ -2438,34 +2343,34 @@ snd_azf3328_test_bit(unsigned unsigned reg, int bit)
 static inline void
 snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
 {
-#if DEBUG_MISC
        u16 tmp;
 
-       snd_azf3328_dbgmisc(
+       dev_dbg(chip->card->dev,
                "ctrl_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, "
                "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n",
                chip->ctrl_io, chip->game_io, chip->mpu_io,
-               chip->opl3_io, chip->mixer_io, chip->irq
-       );
+               chip->opl3_io, chip->mixer_io, chip->irq);
 
-       snd_azf3328_dbgmisc("game %02x %02x %02x %02x %02x %02x\n",
+       dev_dbg(chip->card->dev,
+               "game %02x %02x %02x %02x %02x %02x\n",
                snd_azf3328_game_inb(chip, 0),
                snd_azf3328_game_inb(chip, 1),
                snd_azf3328_game_inb(chip, 2),
                snd_azf3328_game_inb(chip, 3),
                snd_azf3328_game_inb(chip, 4),
-               snd_azf3328_game_inb(chip, 5)
-       );
+               snd_azf3328_game_inb(chip, 5));
 
        for (tmp = 0; tmp < 0x07; tmp += 1)
-               snd_azf3328_dbgmisc("mpu_io 0x%04x\n", inb(chip->mpu_io + tmp));
+               dev_dbg(chip->card->dev,
+                       "mpu_io 0x%04x\n", inb(chip->mpu_io + tmp));
 
        for (tmp = 0; tmp <= 0x07; tmp += 1)
-               snd_azf3328_dbgmisc("0x%02x: game200 0x%04x, game208 0x%04x\n",
+               dev_dbg(chip->card->dev,
+                       "0x%02x: game200 0x%04x, game208 0x%04x\n",
                        tmp, inb(0x200 + tmp), inb(0x208 + tmp));
 
        for (tmp = 0; tmp <= 0x01; tmp += 1)
-               snd_azf3328_dbgmisc(
+               dev_dbg(chip->card->dev,
                        "0x%02x: mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, "
                        "mpu330 0x%04x opl388 0x%04x opl38c 0x%04x\n",
                                tmp,
@@ -2474,19 +2379,17 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
                                inb(0x320 + tmp),
                                inb(0x330 + tmp),
                                inb(0x388 + tmp),
-                               inb(0x38c + tmp)
-               );
+                               inb(0x38c + tmp));
 
        for (tmp = 0; tmp < AZF_IO_SIZE_CTRL; tmp += 2)
-               snd_azf3328_dbgmisc("ctrl 0x%02x: 0x%04x\n",
-                       tmp, snd_azf3328_ctrl_inw(chip, tmp)
-               );
+               dev_dbg(chip->card->dev,
+                       "ctrl 0x%02x: 0x%04x\n",
+                       tmp, snd_azf3328_ctrl_inw(chip, tmp));
 
        for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2)
-               snd_azf3328_dbgmisc("mixer 0x%02x: 0x%04x\n",
-                       tmp, snd_azf3328_mixer_inw(chip, tmp)
-               );
-#endif /* DEBUG_MISC */
+               dev_dbg(chip->card->dev,
+                       "mixer 0x%02x: 0x%04x\n",
+                       tmp, snd_azf3328_mixer_inw(chip, tmp));
 }
 
 static int
@@ -2523,8 +2426,8 @@ snd_azf3328_create(struct snd_card *card,
        /* check if we can restrict PCI DMA transfers to 24 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support "
-                                       "24bit PCI busmaster DMA\n"
+               dev_err(card->dev,
+                       "architecture does not support 24bit PCI busmaster DMA\n"
                );
                err = -ENXIO;
                goto out_err;
@@ -2560,7 +2463,7 @@ snd_azf3328_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_azf3328_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                err = -EBUSY;
                goto out_err;
        }
@@ -2599,8 +2502,6 @@ snd_azf3328_create(struct snd_card *card,
                spin_unlock_irq(codec->lock);
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
 
        err = 0;
@@ -2624,7 +2525,6 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
        struct snd_opl3 *opl3;
        int err;
 
-       snd_azf3328_dbgcallenter();
        if (dev >= SNDRV_CARDS) {
                err = -ENODEV;
                goto out;
@@ -2635,7 +2535,8 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                goto out;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                goto out;
 
@@ -2657,7 +2558,7 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                -1, &chip->rmidi
        );
        if (err < 0) {
-               snd_printk(KERN_ERR "azf3328: no MPU-401 device at 0x%lx?\n",
+               dev_err(card->dev, "no MPU-401 device at 0x%lx?\n",
                                chip->mpu_io
                );
                goto out_err;
@@ -2673,7 +2574,7 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 
        if (snd_opl3_create(card, chip->opl3_io, chip->opl3_io+2,
                            OPL3_HW_AUTO, 1, &opl3) < 0) {
-               snd_printk(KERN_ERR "azf3328: no OPL3 device at 0x%lx-0x%lx?\n",
+               dev_err(card->dev, "no OPL3 device at 0x%lx-0x%lx?\n",
                           chip->opl3_io, chip->opl3_io+2
                );
        } else {
@@ -2695,12 +2596,15 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                goto out_err;
 
 #ifdef MODULE
-       printk(KERN_INFO
-"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n"
-"azt3328: Hardware was completely undocumented, unfortunately.\n"
-"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n"
-"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n",
-       1024000 / seqtimer_scaling, seqtimer_scaling);
+       dev_info(card->dev,
+                "Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n");
+       dev_info(card->dev,
+                "Hardware was completely undocumented, unfortunately.\n");
+       dev_info(card->dev,
+                "Feel free to contact andi AT lisas.de for bug reports etc.!\n");
+       dev_info(card->dev,
+                "User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n",
+                1024000 / seqtimer_scaling, seqtimer_scaling);
 #endif
 
        snd_azf3328_gameport(chip, dev);
@@ -2712,31 +2616,29 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
        goto out;
 
 out_err:
-       snd_printk(KERN_ERR "azf3328: something failed, exiting\n");
+       dev_err(card->dev, "something failed, exiting\n");
        snd_card_free(card);
 
 out:
-       snd_azf3328_dbgcallleave();
        return err;
 }
 
 static void
 snd_azf3328_remove(struct pci_dev *pci)
 {
-       snd_azf3328_dbgcallenter();
        snd_card_free(pci_get_drvdata(pci));
-       snd_azf3328_dbgcallleave();
 }
 
 #ifdef CONFIG_PM_SLEEP
 static inline void
-snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs)
+snd_azf3328_suspend_regs(const struct snd_azf3328 *chip,
+                        unsigned long io_addr, unsigned count, u32 *saved_regs)
 {
        unsigned reg;
 
        for (reg = 0; reg < count; ++reg) {
                *saved_regs = inl(io_addr);
-               snd_azf3328_dbgpm("suspend: io 0x%04lx: 0x%08x\n",
+               dev_dbg(chip->card->dev, "suspend: io 0x%04lx: 0x%08x\n",
                        io_addr, *saved_regs);
                ++saved_regs;
                io_addr += sizeof(*saved_regs);
@@ -2744,7 +2646,8 @@ snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs)
 }
 
 static inline void
-snd_azf3328_resume_regs(const u32 *saved_regs,
+snd_azf3328_resume_regs(const struct snd_azf3328 *chip,
+                       const u32 *saved_regs,
                        unsigned long io_addr,
                        unsigned count
 )
@@ -2753,7 +2656,8 @@ snd_azf3328_resume_regs(const u32 *saved_regs,
 
        for (reg = 0; reg < count; ++reg) {
                outl(*saved_regs, io_addr);
-               snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n",
+               dev_dbg(chip->card->dev,
+                       "resume: io 0x%04lx: 0x%08x --> 0x%08x\n",
                        io_addr, *saved_regs, inl(io_addr));
                ++saved_regs;
                io_addr += sizeof(*saved_regs);
@@ -2766,7 +2670,7 @@ snd_azf3328_suspend_ac97(struct snd_azf3328 *chip)
 #ifdef AZF_USE_AC97_LAYER
        snd_ac97_suspend(chip->ac97);
 #else
-       snd_azf3328_suspend_regs(chip->mixer_io,
+       snd_azf3328_suspend_regs(chip, chip->mixer_io,
                ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer);
 
        /* make sure to disable master volume etc. to prevent looping sound */
@@ -2781,7 +2685,7 @@ snd_azf3328_resume_ac97(const struct snd_azf3328 *chip)
 #ifdef AZF_USE_AC97_LAYER
        snd_ac97_resume(chip->ac97);
 #else
-       snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io,
+       snd_azf3328_resume_regs(chip, chip->saved_regs_mixer, chip->mixer_io,
                                        ARRAY_SIZE(chip->saved_regs_mixer));
 
        /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02)
@@ -2808,18 +2712,18 @@ snd_azf3328_suspend(struct device *dev)
 
        snd_azf3328_suspend_ac97(chip);
 
-       snd_azf3328_suspend_regs(chip->ctrl_io,
+       snd_azf3328_suspend_regs(chip, chip->ctrl_io,
                ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl);
 
        /* manually store the one currently relevant write-only reg, too */
        saved_regs_ctrl_u16 = (u16 *)chip->saved_regs_ctrl;
        saved_regs_ctrl_u16[IDX_IO_6AH / 2] = chip->shadow_reg_ctrl_6AH;
 
-       snd_azf3328_suspend_regs(chip->game_io,
+       snd_azf3328_suspend_regs(chip, chip->game_io,
                ARRAY_SIZE(chip->saved_regs_game), chip->saved_regs_game);
-       snd_azf3328_suspend_regs(chip->mpu_io,
+       snd_azf3328_suspend_regs(chip, chip->mpu_io,
                ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu);
-       snd_azf3328_suspend_regs(chip->opl3_io,
+       snd_azf3328_suspend_regs(chip, chip->opl3_io,
                ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3);
 
        pci_disable_device(pci);
@@ -2838,23 +2742,22 @@ snd_azf3328_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "azt3328: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
        pci_set_master(pci);
 
-       snd_azf3328_resume_regs(chip->saved_regs_game, chip->game_io,
+       snd_azf3328_resume_regs(chip, chip->saved_regs_game, chip->game_io,
                                        ARRAY_SIZE(chip->saved_regs_game));
-       snd_azf3328_resume_regs(chip->saved_regs_mpu, chip->mpu_io,
+       snd_azf3328_resume_regs(chip, chip->saved_regs_mpu, chip->mpu_io,
                                        ARRAY_SIZE(chip->saved_regs_mpu));
-       snd_azf3328_resume_regs(chip->saved_regs_opl3, chip->opl3_io,
+       snd_azf3328_resume_regs(chip, chip->saved_regs_opl3, chip->opl3_io,
                                        ARRAY_SIZE(chip->saved_regs_opl3));
 
        snd_azf3328_resume_ac97(chip);
 
-       snd_azf3328_resume_regs(chip->saved_regs_ctrl, chip->ctrl_io,
+       snd_azf3328_resume_regs(chip, chip->saved_regs_ctrl, chip->ctrl_io,
                                        ARRAY_SIZE(chip->saved_regs_ctrl));
 
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
index 18802039497afd3dfcafdd53dd1d0d62e503c4cc..8546711d12f9275c9dba94bbfc1a59476e1c041a 100644 (file)
@@ -293,17 +293,23 @@ static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status)
                PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY;
        pci_write_config_word(chip->pci, PCI_STATUS, pci_status);
        if (pci_status != PCI_STATUS_DETECTED_PARITY)
-               snd_printk(KERN_ERR "Aieee - PCI error! status %#08x, PCI status %#04x\n",
+               dev_err(chip->card->dev,
+                       "Aieee - PCI error! status %#08x, PCI status %#04x\n",
                           status & ERROR_INTERRUPTS, pci_status);
        else {
-               snd_printk(KERN_ERR "Aieee - PCI parity error detected!\n");
+               dev_err(chip->card->dev,
+                       "Aieee - PCI parity error detected!\n");
                /* error 'handling' similar to aic7xxx_pci.c: */
                chip->pci_parity_errors++;
                if (chip->pci_parity_errors > 20) {
-                       snd_printk(KERN_ERR "Too many PCI parity errors observed.\n");
-                       snd_printk(KERN_ERR "Some device on this bus is generating bad parity.\n");
-                       snd_printk(KERN_ERR "This is an error *observed by*, not *generated by*, this card.\n");
-                       snd_printk(KERN_ERR "PCI parity error checking has been disabled.\n");
+                       dev_err(chip->card->dev,
+                               "Too many PCI parity errors observed.\n");
+                       dev_err(chip->card->dev,
+                               "Some device on this bus is generating bad parity.\n");
+                       dev_err(chip->card->dev,
+                               "This is an error *observed by*, not *generated by*, this card.\n");
+                       dev_err(chip->card->dev,
+                               "PCI parity error checking has been disabled.\n");
                        chip->interrupt_mask &= ~(INT_PPERR | INT_RIPERR);
                        snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask);
                }
@@ -323,9 +329,11 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id)
 
        if (irq_status & ERROR_INTERRUPTS) {
                if (irq_status & (INT_FBUS | INT_FTRGT))
-                       snd_printk(KERN_WARNING "FIFO overrun, status %#08x\n", status);
+                       dev_warn(chip->card->dev,
+                                "FIFO overrun, status %#08x\n", status);
                if (irq_status & INT_OCERR)
-                       snd_printk(KERN_ERR "internal RISC error, status %#08x\n", status);
+                       dev_err(chip->card->dev,
+                               "internal RISC error, status %#08x\n", status);
                if (irq_status & (INT_PPERR | INT_RIPERR | INT_PABORT))
                        snd_bt87x_pci_error(chip, irq_status);
        }
@@ -747,7 +755,7 @@ static int snd_bt87x_create(struct snd_card *card,
        }
        chip->mmio = pci_ioremap_bar(pci, 0);
        if (!chip->mmio) {
-               snd_printk(KERN_ERR "cannot remap io memory\n");
+               dev_err(card->dev, "cannot remap io memory\n");
                err = -ENOMEM;
                goto fail;
        }
@@ -762,7 +770,7 @@ static int snd_bt87x_create(struct snd_card *card,
        err = request_irq(pci->irq, snd_bt87x_interrupt, IRQF_SHARED,
                          KBUILD_MODNAME, chip);
        if (err < 0) {
-               snd_printk(KERN_ERR "cannot grab irq %d\n", pci->irq);
+               dev_err(card->dev, "cannot grab irq %d\n", pci->irq);
                goto fail;
        }
        chip->irq = pci->irq;
@@ -773,7 +781,6 @@ static int snd_bt87x_create(struct snd_card *card,
        if (err < 0)
                goto fail;
 
-       snd_card_set_dev(card, &pci->dev);
        *rchip = chip;
        return 0;
 
@@ -851,14 +858,15 @@ static int snd_bt87x_detect_card(struct pci_dev *pci)
        for (i = 0; i < ARRAY_SIZE(blacklist); ++i)
                if (blacklist[i].subvendor == pci->subsystem_vendor &&
                    blacklist[i].subdevice == pci->subsystem_device) {
-                       snd_printdd(KERN_INFO "card %#04x-%#04x:%#04x has no audio\n",
+                       dev_dbg(&pci->dev,
+                               "card %#04x-%#04x:%#04x has no audio\n",
                                    pci->device, pci->subsystem_vendor, pci->subsystem_device);
                        return -EBUSY;
                }
 
-       snd_printk(KERN_INFO "unknown card %#04x-%#04x:%#04x\n",
+       dev_info(&pci->dev, "unknown card %#04x-%#04x:%#04x\n",
                   pci->device, pci->subsystem_vendor, pci->subsystem_device);
-       snd_printk(KERN_DEBUG "please mail id, board name, and, "
+       dev_info(&pci->dev, "please mail id, board name, and, "
                   "if it works, the correct digital_rate option to "
                   "<alsa-devel@alsa-project.org>\n");
        return SND_BT87X_BOARD_UNKNOWN;
@@ -888,7 +896,8 @@ static int snd_bt87x_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -925,7 +934,7 @@ static int snd_bt87x_probe(struct pci_dev *pci,
                if (err < 0)
                        goto _error;
        }
-       snd_printk(KERN_INFO "bt87x%d: Using board %d, %sanalog, %sdigital "
+       dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital "
                   "(rate %d Hz)\n", dev, boardid,
                   chip->board.no_analog ? "no " : "",
                   chip->board.no_digital ? "no " : "", chip->board.dig_rate);
index f4db5587e86ee9b3f509d1541b9ae85c0a64cbab..f94cc6e97d4ab8cec22ddff2134f96139ba89d92 100644 (file)
@@ -417,13 +417,13 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
        int status;
        int retry;
        if ((reg > 0x7f) || (value > 0x1ff)) {
-               snd_printk(KERN_ERR "i2c_write: invalid values.\n");
+               dev_err(emu->card->dev, "i2c_write: invalid values.\n");
                return -EINVAL;
        }
 
        tmp = reg << 25 | value << 16;
        /*
-       snd_printk(KERN_DEBUG "I2C-write:reg=0x%x, value=0x%x\n", reg, value);
+       dev_dbg(emu->card->dev, "I2C-write:reg=0x%x, value=0x%x\n", reg, value);
        */
        /* Not sure what this I2C channel controls. */
        /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */
@@ -442,7 +442,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
                /* Wait till the transaction ends */
                while (1) {
                        status = snd_ca0106_ptr_read(emu, I2C_A, 0);
-                       /*snd_printk(KERN_DEBUG "I2C:status=0x%x\n", status);*/
+                       /*dev_dbg(emu->card->dev, "I2C:status=0x%x\n", status);*/
                        timeout++;
                        if ((status & I2C_A_ADC_START) == 0)
                                break;
@@ -456,7 +456,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
        }
 
        if (retry == 10) {
-               snd_printk(KERN_ERR "Writing to ADC failed!\n");
+               dev_err(emu->card->dev, "Writing to ADC failed!\n");
                return -EINVAL;
        }
     
@@ -516,7 +516,8 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
        }
 }
 
-static int snd_ca0106_channel_dac(struct snd_ca0106_details *details,
+static int snd_ca0106_channel_dac(struct snd_ca0106 *chip,
+                                 struct snd_ca0106_details *details,
                                  int channel_id)
 {
        switch (channel_id) {
@@ -529,7 +530,7 @@ static int snd_ca0106_channel_dac(struct snd_ca0106_details *details,
        case PCM_UNKNOWN_CHANNEL:
                return (details->spi_dac & 0x000f) >> (4 * 0);
        default:
-               snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n",
+               dev_dbg(chip->card->dev, "ca0106: unknown channel_id %d\n",
                           channel_id);
        }
        return 0;
@@ -539,7 +540,7 @@ static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
                                    int power)
 {
        if (chip->details->spi_dac) {
-               const int dac = snd_ca0106_channel_dac(chip->details,
+               const int dac = snd_ca0106_channel_dac(chip, chip->details,
                                                       channel_id);
                const int reg = spi_dacd_reg[dac];
                const int bit = spi_dacd_bit[dac];
@@ -583,7 +584,7 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
 
        channel->use = 1;
        /*
-       printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
+       dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
               channel_id, chip, channel);
        */
         //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
@@ -660,7 +661,8 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre
 
        epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
        if (epcm == NULL) {
-               snd_printk(KERN_ERR "open_capture_channel: failed epcm alloc\n");
+               dev_err(chip->card->dev,
+                       "open_capture_channel: failed epcm alloc\n");
                return -ENOMEM;
         }
        epcm->emu = chip;
@@ -677,7 +679,7 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre
 
        channel->use = 1;
        /*
-        printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
+       dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
               channel_id, chip, channel);
        */
         //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
@@ -771,7 +773,7 @@ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream)
        int i;
        
 #if 0 /* debug */
-       snd_printk(KERN_DEBUG
+       dev_dbg(emu->card->dev,
                   "prepare:channel_number=%d, rate=%d, format=0x%x, "
                   "channels=%d, buffer_size=%ld, period_size=%ld, "
                   "periods=%u, frames_to_bytes=%d\n",
@@ -779,9 +781,11 @@ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream)
                   runtime->channels, runtime->buffer_size,
                   runtime->period_size, runtime->periods,
                   frames_to_bytes(runtime, 1));
-       snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
+       dev_dbg(emu->card->dev,
+               "dma_addr=%x, dma_area=%p, table_base=%p\n",
                   runtime->dma_addr, runtime->dma_area, table_base);
-       snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
+       dev_dbg(emu->card->dev,
+               "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
                   emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
 #endif /* debug */
        /* Rate can be set per channel. */
@@ -876,7 +880,7 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
        u32 reg71;
        
 #if 0 /* debug */
-       snd_printk(KERN_DEBUG
+       dev_dbg(emu->card->dev,
                   "prepare:channel_number=%d, rate=%d, format=0x%x, "
                   "channels=%d, buffer_size=%ld, period_size=%ld, "
                   "periods=%u, frames_to_bytes=%d\n",
@@ -884,9 +888,11 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
                   runtime->channels, runtime->buffer_size,
                   runtime->period_size, runtime->periods,
                   frames_to_bytes(runtime, 1));
-        snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
+       dev_dbg(emu->card->dev,
+               "dma_addr=%x, dma_area=%p, table_base=%p\n",
                   runtime->dma_addr, runtime->dma_area, table_base);
-       snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
+       dev_dbg(emu->card->dev,
+               "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
                   emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
 #endif /* debug */
        /* reg71 controls ADC rate. */
@@ -934,7 +940,7 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
 
 
        /*
-       printk(KERN_DEBUG
+       dev_dbg(emu->card->dev,
               "prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, "
               "buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",
               channel, runtime->rate, runtime->format, runtime->channels,
@@ -982,13 +988,13 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
                runtime = s->runtime;
                epcm = runtime->private_data;
                channel = epcm->channel_id;
-               /* snd_printk(KERN_DEBUG "channel=%d\n", channel); */
+               /* dev_dbg(emu->card->dev, "channel=%d\n", channel); */
                epcm->running = running;
                basic |= (0x1 << channel);
                extended |= (0x10 << channel);
                 snd_pcm_trigger_done(s, substream);
         }
-       /* snd_printk(KERN_DEBUG "basic=0x%x, extended=0x%x\n",basic, extended); */
+       /* dev_dbg(emu->card->dev, "basic=0x%x, extended=0x%x\n",basic, extended); */
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -1070,7 +1076,7 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream)
                        return ptr;
                prev_ptr = ptr;
        } while (--timeout);
-       snd_printk(KERN_WARNING "ca0106: unstable DMA pointer!\n");
+       dev_warn(emu->card->dev, "ca0106: unstable DMA pointer!\n");
        return 0;
 }
 
@@ -1093,7 +1099,7 @@ snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream)
         if (ptr >= runtime->buffer_size)
                ptr -= runtime->buffer_size;
        /*
-       printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
+       dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
               "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
               ptr1, ptr2, ptr, (int)runtime->buffer_size,
               (int)runtime->period_size, (int)runtime->frame_bits,
@@ -1284,9 +1290,9 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
 
         stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0);
        /*
-       snd_printk(KERN_DEBUG "interrupt status = 0x%08x, stat76=0x%08x\n",
+       dev_dbg(emu->card->dev, "interrupt status = 0x%08x, stat76=0x%08x\n",
                   status, stat76);
-       snd_printk(KERN_DEBUG "ptr=0x%08x\n",
+       dev_dbg(emu->card->dev, "ptr=0x%08x\n",
                   snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0));
        */
         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)
 /* FIXME: Select the correct substream for period elapsed */
                        if(pchannel->use) {
                                snd_pcm_period_elapsed(pchannel->epcm->substream);
-                               //printk(KERN_INFO "interrupt [%d] used\n", i);
+                               /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */
                         }
                }
-               //printk(KERN_INFO "channel=%p\n",pchannel);
-               //printk(KERN_INFO "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number);
+               /*
+               dev_dbg(emu->card->dev, "channel=%p\n", pchannel);
+               dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number);
+               */
                mask <<= 1;
        }
         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)
 /* FIXME: Select the correct substream for period elapsed */
                        if(pchannel->use) {
                                snd_pcm_period_elapsed(pchannel->epcm->substream);
-                               //printk(KERN_INFO "interrupt [%d] used\n", i);
+                               /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */
                         }
                }
-               //printk(KERN_INFO "channel=%p\n",pchannel);
-               //printk(KERN_INFO "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number);
+               /*
+               dev_dbg(emu->card->dev, "channel=%p\n", pchannel);
+               dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number);
+               */
                mask <<= 1;
        }
 
@@ -1603,7 +1613,7 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
                int size, n;
 
                size = ARRAY_SIZE(i2c_adc_init);
-               /* snd_printk(KERN_DEBUG "I2C:array size=0x%x\n", size); */
+               /* dev_dbg(emu->card->dev, "I2C:array size=0x%x\n", size); */
                for (n = 0; n < size; n++)
                        snd_ca0106_i2c_write(chip, i2c_adc_init[n][0],
                                             i2c_adc_init[n][1]);
@@ -1668,7 +1678,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
                return err;
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
-               printk(KERN_ERR "error to set 32bit mask DMA\n");
+               dev_err(card->dev, "error to set 32bit mask DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -1689,14 +1699,14 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
        chip->res_port = request_region(chip->port, 0x20, "snd_ca0106");
        if (!chip->res_port) {
                snd_ca0106_free(chip);
-               printk(KERN_ERR "cannot allocate the port\n");
+               dev_err(card->dev, "cannot allocate the port\n");
                return -EBUSY;
        }
 
        if (request_irq(pci->irq, snd_ca0106_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
                snd_ca0106_free(chip);
-               printk(KERN_ERR "cannot grab irq\n");
+               dev_err(card->dev, "cannot grab irq\n");
                return -EBUSY;
        }
        chip->irq = pci->irq;
@@ -1712,7 +1722,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
        /* read serial */
        pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
        pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
-       printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n",
+       dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n",
               chip->model, pci->revision, chip->serial);
        strcpy(card->driver, "CA0106");
        strcpy(card->shortname, "CA0106");
@@ -1726,7 +1736,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
        }
        chip->details = c;
        if (subsystem[dev]) {
-               printk(KERN_INFO "snd-ca0106: Sound card name=%s, "
+               dev_info(card->dev, "Sound card name=%s, "
                       "subsystem=0x%x. Forced to subsystem=0x%x\n",
                       c->name, chip->serial, subsystem[dev]);
        }
@@ -1843,7 +1853,8 @@ static int snd_ca0106_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -1868,18 +1879,16 @@ static int snd_ca0106_probe(struct pci_dev *pci,
        if (err < 0)
                goto error;
 
-       snd_printdd("ca0106: probe for MIDI channel A ...");
+       dev_dbg(card->dev, "probe for MIDI channel A ...");
        err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A);
        if (err < 0)
                goto error;
-       snd_printdd(" done.\n");
+       dev_dbg(card->dev, " done.\n");
 
 #ifdef CONFIG_PROC_FS
        snd_ca0106_proc_init(chip);
 #endif
 
-       snd_card_set_dev(card, &pci->dev);
-
        err = snd_card_register(card);
        if (err < 0)
                goto error;
index 8bbdf265d11d240ab6798b8b6d67a65a693a8d2d..b91c7f6d19f9ee28005a91f3af210c3e60c6ea3d 100644 (file)
@@ -46,7 +46,7 @@ static void ca_midi_clear_rx(struct snd_ca_midi *midi)
                ca_midi_read_data(midi);
 #ifdef CONFIG_SND_DEBUG
        if (timeout <= 0)
-               snd_printk(KERN_ERR "ca_midi_clear_rx: timeout (status = 0x%x)\n",
+               pr_err("ca_midi_clear_rx: timeout (status = 0x%x)\n",
                           ca_midi_read_stat(midi));
 #endif
 }
@@ -113,7 +113,7 @@ static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack)
        }
        spin_unlock_irqrestore(&midi->input_lock, flags);
        if (!ok)
-               snd_printk(KERN_ERR "ca_midi_cmd: 0x%x failed at 0x%x (status = 0x%x, data = 0x%x)!!!\n",
+               pr_err("ca_midi_cmd: 0x%x failed at 0x%x (status = 0x%x, data = 0x%x)!!!\n",
                           cmd,
                           midi->get_dev_id_port(midi->dev_id),
                           ca_midi_read_stat(midi),
index 2755ec5bcc258d695d534f3ca99d895218c49215..12c318e175f4c0a461695eb101a4158b0eb1a12a 100644 (file)
@@ -796,7 +796,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
        if (runtime->channels > 1)
                rec->fmt |= 0x01;
        if (rec->is_dac && set_dac_channels(cm, rec, runtime->channels) < 0) {
-               snd_printd("cannot set dac channels\n");
+               dev_dbg(cm->card->dev, "cannot set dac channels\n");
                return -EINVAL;
        }
 
@@ -827,7 +827,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
        else
                cm->ctrl |= val;
        snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
-       //snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl);
+       /* dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl); */
 
        /* set sample rate */
        freq = 0;
@@ -850,7 +850,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
                val |= (freq << CM_ASFC_SHIFT) & CM_ASFC_MASK;
        }
        snd_cmipci_write(cm, CM_REG_FUNCTRL1, val);
-       //snd_printd("cmipci: functrl1 = %08x\n", val);
+       dev_dbg(cm->card->dev, "functrl1 = %08x\n", val);
 
        /* set format */
        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,
                val |= freq_ext << (rec->ch * 2);
        }
        snd_cmipci_write(cm, CM_REG_CHFORMAT, val);
-       //snd_printd("cmipci: chformat = %08x\n", val);
+       dev_dbg(cm->card->dev, "chformat = %08x\n", val);
 
        if (!rec->is_dac && cm->chip_version) {
                if (runtime->rate > 44100)
@@ -904,7 +904,7 @@ static int snd_cmipci_pcm_trigger(struct cmipci *cm, struct cmipci_pcm *rec,
                cm->ctrl |= chen;
                /* enable channel */
                snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
-               //snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl);
+               dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl);
                break;
        case SNDRV_PCM_TRIGGER_STOP:
                rec->running = 0;
@@ -952,7 +952,7 @@ static snd_pcm_uframes_t snd_cmipci_pcm_pointer(struct cmipci *cm, struct cmipci
                if (rem < rec->dma_size)
                        goto ok;
        } 
-       printk(KERN_ERR "cmipci: invalid PCM pointer: %#x\n", rem);
+       dev_err(cm->card->dev, "invalid PCM pointer: %#x\n", rem);
        return SNDRV_PCM_POS_XRUN;
 ok:
        ptr = (rec->dma_size - (rem + 1)) >> rec->shift;
@@ -2889,13 +2889,13 @@ static int snd_cmipci_create_gameport(struct cmipci *cm, int dev)
        }
 
        if (!r) {
-               printk(KERN_WARNING "cmipci: cannot reserve joystick ports\n");
+               dev_warn(cm->card->dev, "cannot reserve joystick ports\n");
                return -EBUSY;
        }
 
        cm->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n");
+               dev_err(cm->card->dev, "cannot allocate memory for gameport\n");
                release_and_free_resource(r);
                return -ENOMEM;
        }
@@ -2995,13 +2995,14 @@ static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port)
 
                if (snd_opl3_create(cm->card, iosynth, iosynth + 2,
                                    OPL3_HW_OPL3, 0, &opl3) < 0) {
-                       printk(KERN_ERR "cmipci: no OPL device at %#lx, "
-                              "skipping...\n", iosynth);
+                       dev_err(cm->card->dev,
+                               "no OPL device at %#lx, skipping...\n",
+                               iosynth);
                        goto disable_fm;
                }
        }
        if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
-               printk(KERN_ERR "cmipci: cannot create OPL3 hwdep\n");
+               dev_err(cm->card->dev, "cannot create OPL3 hwdep\n");
                return err;
        }
        return 0;
@@ -3060,7 +3061,7 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
 
        if (request_irq(pci->irq, snd_cmipci_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, cm)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_cmipci_free(cm);
                return -EBUSY;
        }
@@ -3192,8 +3193,9 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
                        /* enable UART */
                        snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN);
                        if (inb(iomidi + 1) == 0xff) {
-                               snd_printk(KERN_ERR "cannot enable MPU-401 port"
-                                          " at %#lx\n", iomidi);
+                               dev_err(cm->card->dev,
+                                       "cannot enable MPU-401 port at %#lx\n",
+                                       iomidi);
                                snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1,
                                                     CM_UART_EN);
                                iomidi = 0;
@@ -3237,7 +3239,8 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
                                                MPU401_INFO_INTEGRATED : 0) |
                                               MPU401_INFO_IRQ_HOOK,
                                               -1, &cm->rmidi)) < 0) {
-                       printk(KERN_ERR "cmipci: no UART401 device at 0x%lx\n", iomidi);
+                       dev_err(cm->card->dev,
+                               "no UART401 device at 0x%lx\n", iomidi);
                }
        }
 
@@ -3254,8 +3257,6 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
        if (snd_cmipci_create_gameport(cm, dev) < 0)
                snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rcmipci = cm;
        return 0;
 }
@@ -3280,7 +3281,8 @@ static int snd_cmipci_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        
@@ -3381,8 +3383,7 @@ static int snd_cmipci_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "cmipci: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index 1dc793e742d79845b3e92d6da1ac204f971a6ef8..43d1f912c6419db171b9fc12144ec5e2c33b367a 100644 (file)
@@ -564,7 +564,8 @@ static void snd_cs4281_ac97_write(struct snd_ac97 *ac97,
                        return;
                }
        }
-       snd_printk(KERN_ERR "AC'97 write problem, reg = 0x%x, val = 0x%x\n", reg, val);
+       dev_err(chip->card->dev,
+               "AC'97 write problem, reg = 0x%x, val = 0x%x\n", reg, val);
 }
 
 static 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,
                        goto __ok1;
        }
 
-       snd_printk(KERN_ERR "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
+       dev_err(chip->card->dev,
+               "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
        result = 0xffff;
        goto __end;
        
@@ -643,7 +645,8 @@ static unsigned short snd_cs4281_ac97_read(struct snd_ac97 *ac97,
                udelay(10);
        }
        
-       snd_printk(KERN_ERR "AC'97 read problem (ACSTS_VSTS), reg = 0x%x\n", reg);
+       dev_err(chip->card->dev,
+               "AC'97 read problem (ACSTS_VSTS), reg = 0x%x\n", reg);
        result = 0xffff;
        goto __end;
 
@@ -835,8 +838,9 @@ static snd_pcm_uframes_t snd_cs4281_pointer(struct snd_pcm_substream *substream)
        struct cs4281 *chip = snd_pcm_substream_chip(substream);
 
        /*
-       printk(KERN_DEBUG "DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n",
-              snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size,
+       dev_dbg(chip->card->dev,
+               "DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n",
+               snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size,
               jiffies);
        */
        return runtime->buffer_size -
@@ -1265,7 +1269,8 @@ static int snd_cs4281_create_gameport(struct cs4281 *chip)
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "cs4281: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                return -ENOMEM;
        }
 
@@ -1361,7 +1366,7 @@ static int snd_cs4281_create(struct snd_card *card,
        chip->irq = -1;
        pci_set_master(pci);
        if (dual_codec < 0 || dual_codec > 3) {
-               snd_printk(KERN_ERR "invalid dual_codec option %d\n", dual_codec);
+               dev_err(card->dev, "invalid dual_codec option %d\n", dual_codec);
                dual_codec = 0;
        }
        chip->dual_codec = dual_codec;
@@ -1383,7 +1388,7 @@ static int snd_cs4281_create(struct snd_card *card,
        
        if (request_irq(pci->irq, snd_cs4281_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_cs4281_free(chip);
                return -ENOMEM;
        }
@@ -1402,8 +1407,6 @@ static int snd_cs4281_create(struct snd_card *card,
 
        snd_cs4281_proc_init(chip);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        return 0;
 }
@@ -1425,7 +1428,8 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
                snd_cs4281_pokeBA0(chip, BA0_CFLR, BA0_CFLR_DEFAULT);
                tmp = snd_cs4281_peekBA0(chip, BA0_CFLR);
                if (tmp != BA0_CFLR_DEFAULT) {
-                       snd_printk(KERN_ERR "CFLR setup failed (0x%x)\n", tmp);
+                       dev_err(chip->card->dev,
+                               "CFLR setup failed (0x%x)\n", tmp);
                        return -EIO;
                }
        }
@@ -1436,11 +1440,13 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
        snd_cs4281_pokeBA0(chip, BA0_CWPR, 0x4281);
        
        if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC1)) != (BA0_SERC1_SO1EN | BA0_SERC1_AC97)) {
-               snd_printk(KERN_ERR "SERC1 AC'97 check failed (0x%x)\n", tmp);
+               dev_err(chip->card->dev,
+                       "SERC1 AC'97 check failed (0x%x)\n", tmp);
                return -EIO;
        }
        if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC2)) != (BA0_SERC2_SI1EN | BA0_SERC2_AC97)) {
-               snd_printk(KERN_ERR "SERC2 AC'97 check failed (0x%x)\n", tmp);
+               dev_err(chip->card->dev,
+                       "SERC2 AC'97 check failed (0x%x)\n", tmp);
                return -EIO;
        }
 
@@ -1502,7 +1508,7 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
                schedule_timeout_uninterruptible(1);
        } while (time_after_eq(end_time, jiffies));
 
-       snd_printk(KERN_ERR "DLLRDY not seen\n");
+       dev_err(chip->card->dev, "DLLRDY not seen\n");
        return -EIO;
 
       __ok0:
@@ -1528,7 +1534,9 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
                schedule_timeout_uninterruptible(1);
        } while (time_after_eq(end_time, jiffies));
 
-       snd_printk(KERN_ERR "never read codec ready from AC'97 (0x%x)\n", snd_cs4281_peekBA0(chip, BA0_ACSTS));
+       dev_err(chip->card->dev,
+               "never read codec ready from AC'97 (0x%x)\n",
+               snd_cs4281_peekBA0(chip, BA0_ACSTS));
        return -EIO;
 
       __ok1:
@@ -1539,7 +1547,8 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
                                goto __codec2_ok;
                        schedule_timeout_uninterruptible(1);
                } while (time_after_eq(end_time, jiffies));
-               snd_printk(KERN_INFO "secondary codec doesn't respond. disable it...\n");
+               dev_info(chip->card->dev,
+                        "secondary codec doesn't respond. disable it...\n");
                chip->dual_codec = 0;
        __codec2_ok: ;
        }
@@ -1569,7 +1578,7 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
 
        if (--retry_count > 0)
                goto __retry;
-       snd_printk(KERN_ERR "never read ISV3 and ISV4 from AC'97\n");
+       dev_err(chip->card->dev, "never read ISV3 and ISV4 from AC'97\n");
        return -EIO;
 
       __ok2:
@@ -1917,7 +1926,8 @@ static int snd_cs4281_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -2055,8 +2065,7 @@ static int cs4281_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "cs4281: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index b03498325d661d091ca18d84614fdebd1fb22032..af0eacbc8bd2097ab6c5112b116381194d7db730 100644 (file)
@@ -88,7 +88,8 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        if ((err = snd_cs46xx_create(card, pci,
index 062398ec5335f613b2b8e78e49d6374fc98bcdfc..32b44f25b5c8240a8b40e414a2e09ec7d43b2cc8 100644 (file)
@@ -116,7 +116,7 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
 
        tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL);
        if ((tmp & ACCTL_VFRM) == 0) {
-               snd_printk(KERN_WARNING  "cs46xx: ACCTL_VFRM not set 0x%x\n",tmp);
+               dev_warn(chip->card->dev, "ACCTL_VFRM not set 0x%x\n", tmp);
                snd_cs46xx_pokeBA0(chip, BA0_ACCTL, (tmp & (~ACCTL_ESYN)) | ACCTL_VFRM );
                msleep(50);
                tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL + offset);
@@ -168,7 +168,8 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
                        goto ok1;
        }
 
-       snd_printk(KERN_ERR "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
+       dev_err(chip->card->dev,
+               "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
        result = 0xffff;
        goto end;
        
@@ -187,7 +188,9 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
                udelay(10);
        }
        
-       snd_printk(KERN_ERR "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n", codec_index, reg);
+       dev_err(chip->card->dev,
+               "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n",
+               codec_index, reg);
        result = 0xffff;
        goto end;
 
@@ -197,7 +200,8 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
         *  ACSDA = Status Data Register = 474h
         */
 #if 0
-       printk(KERN_DEBUG "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
+       dev_dbg(chip->card->dev,
+               "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
                        snd_cs46xx_peekBA0(chip, BA0_ACSDA),
                        snd_cs46xx_peekBA0(chip, BA0_ACCAD));
 #endif
@@ -286,7 +290,9 @@ static void snd_cs46xx_codec_write(struct snd_cs46xx *chip,
                        goto end;
                }
        }
-       snd_printk(KERN_ERR "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n", codec_index, reg, val);
+       dev_err(chip->card->dev,
+               "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n",
+               codec_index, reg, val);
  end:
        chip->active_ctrl(chip, -1);
 }
@@ -608,8 +614,8 @@ static int cs46xx_wait_for_fifo(struct snd_cs46xx * chip,int retry_timeout)
        }
   
        if(status & SERBST_WBSY) {
-               snd_printk(KERN_ERR "cs46xx: failure waiting for "
-                          "FIFO command to complete\n");
+               dev_err(chip->card->dev,
+                       "failure waiting for FIFO command to complete\n");
                return -EINVAL;
        }
 
@@ -646,7 +652,9 @@ static void snd_cs46xx_clear_serial_FIFOs(struct snd_cs46xx *chip)
                 *  Make sure the previous FIFO write operation has completed.
                 */
                if (cs46xx_wait_for_fifo(chip,1)) {
-                       snd_printdd ("failed waiting for FIFO at addr (%02X)\n",idx);
+                       dev_dbg(chip->card->dev,
+                               "failed waiting for FIFO at addr (%02X)\n",
+                               idx);
 
                        if (powerdown)
                                snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp);
@@ -694,7 +702,7 @@ static void snd_cs46xx_proc_start(struct snd_cs46xx *chip)
        }
 
        if (snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR)
-               snd_printk(KERN_ERR "SPCR_RUNFR never reset\n");
+               dev_err(chip->card->dev, "SPCR_RUNFR never reset\n");
 }
 
 static 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
                cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, 
                                                                   cpcm, cpcm->hw_buf.addr,cpcm->pcm_channel_id);
                if (cpcm->pcm_channel == NULL) {
-                       snd_printk(KERN_ERR "cs46xx: failed to create virtual PCM channel\n");
+                       dev_err(chip->card->dev,
+                               "failed to create virtual PCM channel\n");
                        return -ENOMEM;
                }
                cpcm->pcm_channel->sample_rate = sample_rate;
@@ -1067,7 +1076,8 @@ static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46x
                if ( (cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, cpcm, 
                                                                         cpcm->hw_buf.addr,
                                                                         cpcm->pcm_channel_id)) == NULL) {
-                       snd_printk(KERN_ERR "cs46xx: failed to re-create virtual PCM channel\n");
+                       dev_err(chip->card->dev,
+                               "failed to re-create virtual PCM channel\n");
                        return -ENOMEM;
                }
 
@@ -1116,7 +1126,8 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
                 return -EINVAL;
         }
 
-       snd_printdd ("period_size (%d), periods (%d) buffer_size(%d)\n",
+       dev_dbg(chip->card->dev,
+               "period_size (%d), periods (%d) buffer_size(%d)\n",
                     period_size, params_periods(hw_params),
                     params_buffer_bytes(hw_params));
 #endif
@@ -1531,22 +1542,20 @@ static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,in
 
 static int snd_cs46xx_playback_open(struct snd_pcm_substream *substream)
 {
-       snd_printdd("open front channel\n");
+       dev_dbg(substream->pcm->card->dev, "open front channel\n");
        return _cs46xx_playback_open_channel(substream,DSP_PCM_MAIN_CHANNEL);
 }
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
 static int snd_cs46xx_playback_open_rear(struct snd_pcm_substream *substream)
 {
-       snd_printdd("open rear channel\n");
-
+       dev_dbg(substream->pcm->card->dev, "open rear channel\n");
        return _cs46xx_playback_open_channel(substream,DSP_PCM_REAR_CHANNEL);
 }
 
 static int snd_cs46xx_playback_open_clfe(struct snd_pcm_substream *substream)
 {
-       snd_printdd("open center - LFE channel\n");
-
+       dev_dbg(substream->pcm->card->dev, "open center - LFE channel\n");
        return _cs46xx_playback_open_channel(substream,DSP_PCM_CENTER_LFE_CHANNEL);
 }
 
@@ -1554,7 +1563,7 @@ static int snd_cs46xx_playback_open_iec958(struct snd_pcm_substream *substream)
 {
        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
 
-       snd_printdd("open raw iec958 channel\n");
+       dev_dbg(chip->card->dev, "open raw iec958 channel\n");
 
        mutex_lock(&chip->spos_mutex);
        cs46xx_iec958_pre_open (chip);
@@ -1570,7 +1579,7 @@ static int snd_cs46xx_playback_close_iec958(struct snd_pcm_substream *substream)
        int err;
        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
   
-       snd_printdd("close raw iec958 channel\n");
+       dev_dbg(chip->card->dev, "close raw iec958 channel\n");
 
        err = snd_cs46xx_playback_close(substream);
 
@@ -2421,10 +2430,10 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
 
        /* set the desired CODEC mode */
        if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) {
-               snd_printdd("cs46xx: CODEC1 mode %04x\n", 0x0);
+               dev_dbg(ac97->bus->card->dev, "CODEC1 mode %04x\n", 0x0);
                snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0);
        } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) {
-               snd_printdd("cs46xx: CODEC2 mode %04x\n", 0x3);
+               dev_dbg(ac97->bus->card->dev, "CODEC2 mode %04x\n", 0x3);
                snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3);
        } else {
                snd_BUG(); /* should never happen ... */
@@ -2456,7 +2465,8 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
                msleep(10);
        } while (time_after_eq(end_time, jiffies));
 
-       snd_printk(KERN_ERR "CS46xx secondary codec doesn't respond!\n");  
+       dev_err(ac97->bus->card->dev,
+               "CS46xx secondary codec doesn't respond!\n");
 }
 #endif
 
@@ -2476,7 +2486,8 @@ static int cs46xx_detect_codec(struct snd_cs46xx *chip, int codec)
                snd_cs46xx_codec_write(chip, AC97_RESET, 0, codec);
                udelay(10);
                if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) {
-                       snd_printdd("snd_cs46xx: seconadry codec not present\n");
+                       dev_dbg(chip->card->dev,
+                               "seconadry codec not present\n");
                        return -ENXIO;
                }
        }
@@ -2489,7 +2500,7 @@ static int cs46xx_detect_codec(struct snd_cs46xx *chip, int codec)
                }
                msleep(10);
        }
-       snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec);
+       dev_dbg(chip->card->dev, "codec %d detection timeout\n", codec);
        return -ENXIO;
 }
 
@@ -2509,7 +2520,7 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
 
        /* detect primary codec */
        chip->nr_ac97_codecs = 0;
-       snd_printdd("snd_cs46xx: detecting primary codec\n");
+       dev_dbg(chip->card->dev, "detecting primary codec\n");
        if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0)
                return err;
        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)
        chip->nr_ac97_codecs = 1;
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
-       snd_printdd("snd_cs46xx: detecting seconadry codec\n");
+       dev_dbg(chip->card->dev, "detecting seconadry codec\n");
        /* try detect a secondary codec */
        if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX))
                chip->nr_ac97_codecs = 2;
@@ -2554,7 +2565,7 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
        }
        /* do soundcard specific mixer setup */
        if (chip->mixer_init) {
-               snd_printdd ("calling chip->mixer_init(chip);\n");
+               dev_dbg(chip->card->dev, "calling chip->mixer_init(chip);\n");
                chip->mixer_init(chip);
        }
 #endif
@@ -2801,7 +2812,8 @@ int snd_cs46xx_gameport(struct snd_cs46xx *chip)
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "cs46xx: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                return -ENOMEM;
        }
 
@@ -3138,8 +3150,10 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
        }
 
 
-       snd_printk(KERN_ERR "create - never read codec ready from AC'97\n");
-       snd_printk(KERN_ERR "it is not probably bug, try to use CS4236 driver\n");
+       dev_err(chip->card->dev,
+               "create - never read codec ready from AC'97\n");
+       dev_err(chip->card->dev,
+               "it is not probably bug, try to use CS4236 driver\n");
        return -EIO;
  ok1:
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
@@ -3157,7 +3171,8 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
                 *  Make sure CODEC is READY.
                 */
                if (!(snd_cs46xx_peekBA0(chip, BA0_ACSTS2) & ACSTS_CRDY))
-                       snd_printdd("cs46xx: never read card ready from secondary AC'97\n");
+                       dev_dbg(chip->card->dev,
+                               "never read card ready from secondary AC'97\n");
        }
 #endif
 
@@ -3187,17 +3202,21 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
        }
 
 #ifndef CONFIG_SND_CS46XX_NEW_DSP
-       snd_printk(KERN_ERR "create - never read ISV3 & ISV4 from AC'97\n");
+       dev_err(chip->card->dev,
+               "create - never read ISV3 & ISV4 from AC'97\n");
        return -EIO;
 #else
        /* This may happen on a cold boot with a Terratec SiXPack 5.1.
           Reloading the driver may help, if there's other soundcards 
           with the same problem I would like to know. (Benny) */
 
-       snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n");
-       snd_printk(KERN_ERR "       Try reloading the ALSA driver, if you find something\n");
-        snd_printk(KERN_ERR "       broken or not working on your soundcard upon\n");
-       snd_printk(KERN_ERR "       this message please report to alsa-devel@alsa-project.org\n");
+       dev_err(chip->card->dev, "never read ISV3 & ISV4 from AC'97\n");
+       dev_err(chip->card->dev,
+               "Try reloading the ALSA driver, if you find something\n");
+       dev_err(chip->card->dev,
+               "broken or not working on your soundcard upon\n");
+       dev_err(chip->card->dev,
+               "this message please report to alsa-devel@alsa-project.org\n");
 
        return -EIO;
 #endif
@@ -3266,13 +3285,13 @@ int snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
        for (i = 0; i < CS46XX_DSP_MODULES; i++) {
                err = load_firmware(chip, &chip->modules[i], module_names[i]);
                if (err < 0) {
-                       snd_printk(KERN_ERR "firmware load error [%s]\n",
+                       dev_err(chip->card->dev, "firmware load error [%s]\n",
                                   module_names[i]);
                        return err;
                }
                err = cs46xx_dsp_load_module(chip, chip->modules[i]);
                if (err < 0) {
-                       snd_printk(KERN_ERR "image download error [%s]\n",
+                       dev_err(chip->card->dev, "image download error [%s]\n",
                                   module_names[i]);
                        return err;
                }
@@ -3288,7 +3307,7 @@ int snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
        /* old image */
        err = snd_cs46xx_download_image(chip);
        if (err < 0) {
-               snd_printk(KERN_ERR "image download error\n");
+               dev_err(chip->card->dev, "image download error\n");
                return err;
        }
 
@@ -3341,7 +3360,7 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
        u32 idx, valid_slots,tmp,powerdown = 0;
        u16 modem_power,pin_config,logic_type;
 
-       snd_printdd ("cs46xx: cs46xx_setup_eapd_slot()+\n");
+       dev_dbg(chip->card->dev, "cs46xx_setup_eapd_slot()+\n");
 
        /*
         *  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)
         * stuff.
         */
        if(chip->nr_ac97_codecs != 2) {
-               snd_printk (KERN_ERR "cs46xx: cs46xx_setup_eapd_slot() - no secondary codec configured\n");
+               dev_err(chip->card->dev,
+                       "cs46xx_setup_eapd_slot() - no secondary codec configured\n");
                return -EINVAL;
        }
 
@@ -3400,7 +3420,7 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
        snd_cs46xx_pokeBA0(chip, BA0_ACOSV, valid_slots);
 
        if ( cs46xx_wait_for_fifo(chip,1) ) {
-         snd_printdd("FIFO is busy\n");
+               dev_dbg(chip->card->dev, "FIFO is busy\n");
          
          return -EINVAL;
        }
@@ -3421,7 +3441,9 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
                 * Wait for command to complete
                 */
                if ( cs46xx_wait_for_fifo(chip,200) ) {
-                       snd_printdd("failed waiting for FIFO at addr (%02X)\n",idx);
+                       dev_dbg(chip->card->dev,
+                               "failed waiting for FIFO at addr (%02X)\n",
+                               idx);
 
                        return -EINVAL;
                }
@@ -3510,14 +3532,14 @@ static void amp_hercules(struct snd_cs46xx *chip, int change)
 
        chip->amplifier += change;
        if (chip->amplifier && !old) {
-               snd_printdd ("Hercules amplifier ON\n");
+               dev_dbg(chip->card->dev, "Hercules amplifier ON\n");
 
                snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, 
                                   EGPIODR_GPOE2 | val1);     /* enable EGPIO2 output */
                snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, 
                                   EGPIOPTR_GPPT2 | val2);   /* open-drain on output */
        } else if (old && !chip->amplifier) {
-               snd_printdd ("Hercules amplifier OFF\n");
+               dev_dbg(chip->card->dev, "Hercules amplifier OFF\n");
                snd_cs46xx_pokeBA0(chip, BA0_EGPIODR,  val1 & ~EGPIODR_GPOE2); /* disable */
                snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, val2 & ~EGPIOPTR_GPPT2); /* disable */
        }
@@ -3525,7 +3547,7 @@ static void amp_hercules(struct snd_cs46xx *chip, int change)
 
 static void voyetra_mixer_init (struct snd_cs46xx *chip)
 {
-       snd_printdd ("initializing Voyetra mixer\n");
+       dev_dbg(chip->card->dev, "initializing Voyetra mixer\n");
 
        /* Enable SPDIF out */
        snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0);
@@ -3543,7 +3565,7 @@ static void hercules_mixer_init (struct snd_cs46xx *chip)
        /* set EGPIO to default */
        hercules_init(chip);
 
-       snd_printdd ("initializing Hercules mixer\n");
+       dev_dbg(chip->card->dev, "initializing Hercules mixer\n");
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
        if (chip->in_suspend)
@@ -3554,7 +3576,9 @@ static void hercules_mixer_init (struct snd_cs46xx *chip)
 
                kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip);
                if ((err = snd_ctl_add(card, kctl)) < 0) {
-                       printk (KERN_ERR "cs46xx: failed to initialize Hercules mixer (%d)\n",err);
+                       dev_err(card->dev,
+                               "failed to initialize Hercules mixer (%d)\n",
+                               err);
                        break;
                }
        }
@@ -3826,8 +3850,7 @@ static int snd_cs46xx_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "cs46xx: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -3932,7 +3955,8 @@ int snd_cs46xx_create(struct snd_card *card,
        chip->ba1_addr = pci_resource_start(pci, 1);
        if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 ||
            chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) {
-               snd_printk(KERN_ERR "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n",
+               dev_err(chip->card->dev,
+                       "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n",
                           chip->ba0_addr, chip->ba1_addr);
                snd_cs46xx_free(chip);
                return -ENOMEM;
@@ -3969,7 +3993,8 @@ int snd_cs46xx_create(struct snd_card *card,
 
        for (cp = &cards[0]; cp->name; cp++) {
                if (cp->vendor == ss_vendor && cp->id == ss_card) {
-                       snd_printdd ("hack for %s enabled\n", cp->name);
+                       dev_dbg(chip->card->dev, "hack for %s enabled\n",
+                               cp->name);
 
                        chip->amplifier_ctrl = cp->amp;
                        chip->active_ctrl = cp->active;
@@ -3982,12 +4007,14 @@ int snd_cs46xx_create(struct snd_card *card,
        }
 
        if (external_amp) {
-               snd_printk(KERN_INFO "Crystal EAPD support forced on.\n");
+               dev_info(chip->card->dev,
+                        "Crystal EAPD support forced on.\n");
                chip->amplifier_ctrl = amp_voyetra;
        }
 
        if (thinkpad) {
-               snd_printk(KERN_INFO "Activating CLKRUN hack for Thinkpad.\n");
+               dev_info(chip->card->dev,
+                        "Activating CLKRUN hack for Thinkpad.\n");
                chip->active_ctrl = clkrun_hack;
                clkrun_init(chip);
        }
@@ -4005,14 +4032,16 @@ int snd_cs46xx_create(struct snd_card *card,
                region = &chip->region.idx[idx];
                if ((region->resource = request_mem_region(region->base, region->size,
                                                           region->name)) == NULL) {
-                       snd_printk(KERN_ERR "unable to request memory region 0x%lx-0x%lx\n",
+                       dev_err(chip->card->dev,
+                               "unable to request memory region 0x%lx-0x%lx\n",
                                   region->base, region->base + region->size - 1);
                        snd_cs46xx_free(chip);
                        return -EBUSY;
                }
                region->remap_addr = ioremap_nocache(region->base, region->size);
                if (region->remap_addr == NULL) {
-                       snd_printk(KERN_ERR "%s ioremap problem\n", region->name);
+                       dev_err(chip->card->dev,
+                               "%s ioremap problem\n", region->name);
                        snd_cs46xx_free(chip);
                        return -ENOMEM;
                }
@@ -4020,7 +4049,7 @@ int snd_cs46xx_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_cs46xx_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_cs46xx_free(chip);
                return -EBUSY;
        }
@@ -4058,8 +4087,6 @@ int snd_cs46xx_create(struct snd_card *card,
 
        chip->active_ctrl(chip, -1); /* disable CLKRUN */
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        return 0;
 }
index 1686b4f4c44fb493538ada5bf14f4965ed645443..1c4a0fb3ffefd4144b32acfc4f81fdb2bd19259c 100644 (file)
@@ -85,12 +85,15 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
                                                address  = (hival & 0x00FFF) << 5;
                                                address |=  loval >> 15;
             
-                                               snd_printdd("handle_wideop[1]: %05x:%05x addr %04x\n",hival,loval,address);
+                                               dev_dbg(chip->card->dev,
+                                                       "handle_wideop[1]: %05x:%05x addr %04x\n",
+                                                       hival, loval, address);
             
                                                if ( !(address & 0x8000) ) {
                                                        address += (ins->code.offset / 2) - overlay_begin_address;
                                                } else {
-                                                       snd_printdd("handle_wideop[1]: ROM symbol not reallocated\n");
+                                                       dev_dbg(chip->card->dev,
+                                                               "handle_wideop[1]: ROM symbol not reallocated\n");
                                                }
             
                                                hival &= 0xFF000;
@@ -102,8 +105,9 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
                                                address  = (hival & 0x00FFF) << 5;
                                                address |=  loval >> 15;
             
-                                               snd_printdd("handle_wideop:[2] %05x:%05x addr %04x\n",hival,loval,address);            
-                                               nreallocated ++;
+                                               dev_dbg(chip->card->dev,
+                                                       "handle_wideop:[2] %05x:%05x addr %04x\n",
+                                                       hival, loval, address);                                         nreallocated++;
                                        } /* wide_opcodes[j] == wide_op */
                                } /* for */
                        } /* mod_type == 0 ... */
@@ -113,7 +117,8 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
                ins->code.data[ins->code.size++] = hival;
        }
 
-       snd_printdd("dsp_spos: %d instructions reallocated\n",nreallocated);
+       dev_dbg(chip->card->dev,
+               "dsp_spos: %d instructions reallocated\n", nreallocated);
        return nreallocated;
 }
 
@@ -157,7 +162,8 @@ static int add_symbols (struct snd_cs46xx * chip, struct dsp_module_desc * modul
 
        for (i = 0;i < module->symbol_table.nsymbols; ++i) {
                if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) {
-                       snd_printk(KERN_ERR "dsp_spos: symbol table is full\n");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: symbol table is full\n");
                        return -ENOMEM;
                }
 
@@ -176,8 +182,11 @@ static int add_symbols (struct snd_cs46xx * chip, struct dsp_module_desc * modul
 
                        ins->symbol_table.nsymbols++;
                } else {
-          /* if (0) printk ("dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n",
-                             module->symbol_table.symbols[i].symbol_name); */
+#if 0
+                       dev_dbg(chip->card->dev,
+                               "dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n",
+                               module->symbol_table.symbols[i].symbol_name); */
+#endif
                }
        }
 
@@ -192,14 +201,15 @@ add_symbol (struct snd_cs46xx * chip, char * symbol_name, u32 address, int type)
        int index;
 
        if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) {
-               snd_printk(KERN_ERR "dsp_spos: symbol table is full\n");
+               dev_err(chip->card->dev, "dsp_spos: symbol table is full\n");
                return NULL;
        }
   
        if (cs46xx_dsp_lookup_symbol(chip,
                                     symbol_name,
                                     type) != NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol <%s> duplicated\n", symbol_name);
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol <%s> duplicated\n", symbol_name);
                return NULL;
        }
 
@@ -305,19 +315,20 @@ static int dsp_load_parameter(struct snd_cs46xx *chip,
        u32 doffset, dsize;
 
        if (!parameter) {
-               snd_printdd("dsp_spos: module got no parameter segment\n");
+               dev_dbg(chip->card->dev,
+                       "dsp_spos: module got no parameter segment\n");
                return 0;
        }
 
        doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET);
        dsize   = parameter->size * 4;
 
-       snd_printdd("dsp_spos: "
-                   "downloading parameter data to chip (%08x-%08x)\n",
+       dev_dbg(chip->card->dev,
+               "dsp_spos: downloading parameter data to chip (%08x-%08x)\n",
                    doffset,doffset + dsize);
        if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
-               snd_printk(KERN_ERR "dsp_spos: "
-                          "failed to download parameter data to DSP\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: failed to download parameter data to DSP\n");
                return -EINVAL;
        }
        return 0;
@@ -329,18 +340,21 @@ static int dsp_load_sample(struct snd_cs46xx *chip,
        u32 doffset, dsize;
 
        if (!sample) {
-               snd_printdd("dsp_spos: module got no sample segment\n");
+               dev_dbg(chip->card->dev,
+                       "dsp_spos: module got no sample segment\n");
                return 0;
        }
 
        doffset = (sample->offset * 4  + DSP_SAMPLE_BYTE_OFFSET);
        dsize   =  sample->size * 4;
 
-       snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
+       dev_dbg(chip->card->dev,
+               "dsp_spos: downloading sample data to chip (%08x-%08x)\n",
                    doffset,doffset + dsize);
 
        if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
-               snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: failed to sample data to DSP\n");
                return -EINVAL;
        }
        return 0;
@@ -354,14 +368,16 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
        int err;
 
        if (ins->nmodules == DSP_MAX_MODULES - 1) {
-               snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: to many modules loaded into DSP\n");
                return -ENOMEM;
        }
 
-       snd_printdd("dsp_spos: loading module %s into DSP\n", module->module_name);
+       dev_dbg(chip->card->dev,
+               "dsp_spos: loading module %s into DSP\n", module->module_name);
   
        if (ins->nmodules == 0) {
-               snd_printdd("dsp_spos: clearing parameter area\n");
+               dev_dbg(chip->card->dev, "dsp_spos: clearing parameter area\n");
                snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE);
        }
   
@@ -371,7 +387,7 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
                return err;
 
        if (ins->nmodules == 0) {
-               snd_printdd("dsp_spos: clearing sample area\n");
+               dev_dbg(chip->card->dev, "dsp_spos: clearing sample area\n");
                snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE);
        }
 
@@ -381,15 +397,17 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
                return err;
 
        if (ins->nmodules == 0) {
-               snd_printdd("dsp_spos: clearing code area\n");
+               dev_dbg(chip->card->dev, "dsp_spos: clearing code area\n");
                snd_cs46xx_clear_BA1(chip, DSP_CODE_BYTE_OFFSET, DSP_CODE_BYTE_SIZE);
        }
 
        if (code == NULL) {
-               snd_printdd("dsp_spos: module got no code segment\n");
+               dev_dbg(chip->card->dev,
+                       "dsp_spos: module got no code segment\n");
        } else {
                if (ins->code.offset + code->size > DSP_CODE_BYTE_SIZE) {
-                       snd_printk(KERN_ERR "dsp_spos: no space available in DSP\n");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: no space available in DSP\n");
                        return -ENOMEM;
                }
 
@@ -401,19 +419,22 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
                if (snd_BUG_ON(!module->symbol_table.symbols))
                        return -ENOMEM;
                if (add_symbols(chip,module)) {
-                       snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: failed to load symbol table\n");
                        return -ENOMEM;
                }
     
                doffset = (code->offset * 4 + ins->code.offset * 4 + DSP_CODE_BYTE_OFFSET);
                dsize   = code->size * 4;
-               snd_printdd("dsp_spos: downloading code to chip (%08x-%08x)\n",
+               dev_dbg(chip->card->dev,
+                       "dsp_spos: downloading code to chip (%08x-%08x)\n",
                            doffset,doffset + dsize);   
 
                module->nfixups = shadow_and_reallocate_code(chip,code->data,code->size,module->overlay_begin_address);
 
                if (snd_cs46xx_download (chip,(ins->code.data + ins->code.offset),doffset,dsize)) {
-                       snd_printk(KERN_ERR "dsp_spos: failed to download code to DSP\n");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: failed to download code to DSP\n");
                        return -EINVAL;
                }
 
@@ -447,7 +468,7 @@ cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, int symb
        }
 
 #if 0
-       printk ("dsp_spos: symbol <%s> type %02x not found\n",
+       dev_err(chip->card->dev, "dsp_spos: symbol <%s> type %02x not found\n",
                symbol_name,symbol_type);
 #endif
 
@@ -910,7 +931,6 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
 }
 #endif /* CONFIG_PROC_FS */
 
-static int debug_tree;
 static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data,
                                   u32  dest, int size)
 {
@@ -919,13 +939,13 @@ static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data,
        int i;
 
        for (i = 0; i < size; ++i) {
-               if (debug_tree) printk ("addr %p, val %08x\n",spdst,task_data[i]);
+               dev_dbg(chip->card->dev, "addr %p, val %08x\n",
+                       spdst, task_data[i]);
                writel(task_data[i],spdst);
                spdst += sizeof(u32);
        }
 }
 
-static int debug_scb;
 static void _dsp_create_scb (struct snd_cs46xx *chip, u32 * scb_data, u32 dest)
 {
        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)
        int i;
 
        for (i = 0; i < 0x10; ++i) {
-               if (debug_scb) printk ("addr %p, val %08x\n",spdst,scb_data[i]);
+               dev_dbg(chip->card->dev, "addr %p, val %08x\n",
+                       spdst, scb_data[i]);
                writel(scb_data[i],spdst);
                spdst += sizeof(u32);
        }
@@ -960,7 +981,8 @@ static struct dsp_scb_descriptor * _map_scb (struct snd_cs46xx *chip, char * nam
        int index;
 
        if (ins->nscb == DSP_MAX_SCB_DESC - 1) {
-               snd_printk(KERN_ERR "dsp_spos: got no place for other SCB\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: got no place for other SCB\n");
                return NULL;
        }
 
@@ -991,7 +1013,8 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size)
        struct dsp_task_descriptor * desc = NULL;
 
        if (ins->ntask == DSP_MAX_TASK_DESC - 1) {
-               snd_printk(KERN_ERR "dsp_spos: got no place for other TASK\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: got no place for other TASK\n");
                return NULL;
        }
 
@@ -1031,7 +1054,7 @@ cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32
                desc->data = scb_data;
                _dsp_create_scb(chip,scb_data,dest);
        } else {
-               snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n");
+               dev_err(chip->card->dev, "dsp_spos: failed to map SCB\n");
 #ifdef CONFIG_PM_SLEEP
                kfree(scb_data);
 #endif
@@ -1052,7 +1075,7 @@ cs46xx_dsp_create_task_tree (struct snd_cs46xx *chip, char * name, u32 * task_da
                desc->data = task_data;
                _dsp_create_task_tree(chip,task_data,dest,size);
        } else {
-               snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n");
+               dev_err(chip->card->dev, "dsp_spos: failed to map TASK\n");
        }
 
        return desc;
@@ -1105,31 +1128,36 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
 
        null_algorithm  = cs46xx_dsp_lookup_symbol(chip, "NULLALGORITHM", SYMBOL_CODE);
        if (null_algorithm == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol NULLALGORITHM not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol NULLALGORITHM not found\n");
                return -EIO;
        }
 
        fg_task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "FGTASKTREEHEADERCODE", SYMBOL_CODE);  
        if (fg_task_tree_header_code == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol FGTASKTREEHEADERCODE not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol FGTASKTREEHEADERCODE not found\n");
                return -EIO;
        }
 
        task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "TASKTREEHEADERCODE", SYMBOL_CODE);  
        if (task_tree_header_code == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol TASKTREEHEADERCODE not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol TASKTREEHEADERCODE not found\n");
                return -EIO;
        }
   
        task_tree_thread = cs46xx_dsp_lookup_symbol(chip, "TASKTREETHREAD", SYMBOL_CODE);
        if (task_tree_thread == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol TASKTREETHREAD not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol TASKTREETHREAD not found\n");
                return -EIO;
        }
 
        magic_snoop_task = cs46xx_dsp_lookup_symbol(chip, "MAGICSNOOPTASK", SYMBOL_CODE);
        if (magic_snoop_task == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol MAGICSNOOPTASK not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol MAGICSNOOPTASK not found\n");
                return -EIO;
        }
   
@@ -1476,7 +1504,7 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
        return 0;
 
  _fail_end:
-       snd_printk(KERN_ERR "dsp_spos: failed to setup SCB's in DSP\n");
+       dev_err(chip->card->dev, "dsp_spos: failed to setup SCB's in DSP\n");
        return -EINVAL;
 }
 
@@ -1491,18 +1519,21 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
 
        s16_async_codec_input_task = cs46xx_dsp_lookup_symbol(chip, "S16_ASYNCCODECINPUTTASK", SYMBOL_CODE);
        if (s16_async_codec_input_task == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n");
                return -EIO;
        }
        spdifo_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFOTASK", SYMBOL_CODE);
        if (spdifo_task == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol SPDIFOTASK not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol SPDIFOTASK not found\n");
                return -EIO;
        }
 
        spdifi_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFITASK", SYMBOL_CODE);
        if (spdifi_task == NULL) {
-               snd_printk(KERN_ERR "dsp_spos: symbol SPDIFITASK not found\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol SPDIFITASK not found\n");
                return -EIO;
        }
 
@@ -1883,7 +1914,8 @@ int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data)
        }
 
        if (i == 25) {
-               snd_printk(KERN_ERR "dsp_spos: SPIOWriteTask not responding\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: SPIOWriteTask not responding\n");
                return -EBUSY;
        }
 
index 409e8764fbeb2a3678b4c01446a699fc631bc2a5..8284bc9b585822a12ffba887a3233fd077af98b3 100644 (file)
@@ -233,8 +233,11 @@ void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb)
 {
        if (scb->proc_info) {
                struct proc_scb_info * scb_info = scb->proc_info->private_data;
+               struct snd_cs46xx *chip = scb_info->chip;
 
-               snd_printdd("cs46xx_dsp_proc_free_scb_desc: freeing %s\n",scb->scb_name);
+               dev_dbg(chip->card->dev,
+                       "cs46xx_dsp_proc_free_scb_desc: freeing %s\n",
+                       scb->scb_name);
 
                snd_info_free_entry(scb->proc_info);
                scb->proc_info = NULL;
@@ -305,7 +308,7 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
        scb_data[SCBfuncEntryPtr] &= 0xFFFF0000;
        scb_data[SCBfuncEntryPtr] |= task_entry->address;
 
-       snd_printdd("dsp_spos: creating SCB <%s>\n",name);
+       dev_dbg(chip->card->dev, "dsp_spos: creating SCB <%s>\n", name);
 
        scb = cs46xx_dsp_create_scb(chip,name,scb_data,dest);
 
@@ -320,9 +323,15 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
        /* update parent SCB */
        if (scb->parent_scb_ptr) {
 #if 0
-               printk ("scb->parent_scb_ptr = %s\n",scb->parent_scb_ptr->scb_name);
-               printk ("scb->parent_scb_ptr->next_scb_ptr = %s\n",scb->parent_scb_ptr->next_scb_ptr->scb_name);
-               printk ("scb->parent_scb_ptr->sub_list_ptr = %s\n",scb->parent_scb_ptr->sub_list_ptr->scb_name);
+               dev_dbg(chip->card->dev,
+                       "scb->parent_scb_ptr = %s\n",
+                       scb->parent_scb_ptr->scb_name);
+               dev_dbg(chip->card->dev,
+                       "scb->parent_scb_ptr->next_scb_ptr = %s\n",
+                       scb->parent_scb_ptr->next_scb_ptr->scb_name);
+               dev_dbg(chip->card->dev,
+                       "scb->parent_scb_ptr->sub_list_ptr = %s\n",
+                       scb->parent_scb_ptr->sub_list_ptr->scb_name);
 #endif
                /* link to  parent SCB */
                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
                                               SYMBOL_CODE);
   
        if (task_entry == NULL) {
-               snd_printk (KERN_ERR "dsp_spos: symbol %s not found\n",task_entry_name);
+               dev_err(chip->card->dev,
+                       "dsp_spos: symbol %s not found\n", task_entry_name);
                return NULL;
        }
   
@@ -582,7 +592,8 @@ cs46xx_dsp_create_pcm_reader_scb(struct snd_cs46xx * chip, char * scb_name,
                                                                 SYMBOL_CODE);
     
                if (ins->null_algorithm == NULL) {
-                       snd_printk (KERN_ERR "dsp_spos: symbol NULLALGORITHM not found\n");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: symbol NULLALGORITHM not found\n");
                        return NULL;
                }    
        }
@@ -612,7 +623,8 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
        unsigned int phiIncr;
        unsigned int correctionPerGOF, correctionPerSec;
 
-       snd_printdd( "dsp_spos: setting %s rate to %u\n",scb_name,rate);
+       dev_dbg(chip->card->dev, "dsp_spos: setting %s rate to %u\n",
+               scb_name, rate);
 
        /*
         *  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,
                                                                 SYMBOL_CODE);
                        
                        if (ins->s16_up == NULL) {
-                               snd_printk (KERN_ERR "dsp_spos: symbol S16_UPSRC not found\n");
+                               dev_err(chip->card->dev,
+                                       "dsp_spos: symbol S16_UPSRC not found\n");
                                return NULL;
                        }    
                }
@@ -1265,7 +1278,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
                   the Sample Rate Converted (which could
                   alter the raw data stream ...) */
                if (sample_rate == 48000) {
-                       snd_printdd ("IEC958 pass through\n");
+                       dev_dbg(chip->card->dev, "IEC958 pass through\n");
                        /* Hack to bypass creating a new SRC */
                        pass_through = 1;
                }
@@ -1299,13 +1312,14 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
        }
 
        if (pcm_index == -1) {
-               snd_printk (KERN_ERR "dsp_spos: no free PCM channel\n");
+               dev_err(chip->card->dev, "dsp_spos: no free PCM channel\n");
                return NULL;
        }
 
        if (src_scb == NULL) {
                if (ins->nsrc_scb >= DSP_MAX_SRC_NR) {
-                       snd_printk(KERN_ERR "dsp_spos: to many SRC instances\n!");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: to many SRC instances\n!");
                        return NULL;
                }
 
@@ -1331,7 +1345,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
 
                snprintf (scb_name,DSP_MAX_SCB_NAME,"SrcTask_SCB%d",src_index);
                
-               snd_printdd( "dsp_spos: creating SRC \"%s\"\n",scb_name);
+               dev_dbg(chip->card->dev,
+                       "dsp_spos: creating SRC \"%s\"\n", scb_name);
                src_scb = cs46xx_dsp_create_src_task_scb(chip,scb_name,
                                                         sample_rate,
                                                         src_output_buffer_addr[src_index],
@@ -1343,7 +1358,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
                                                         pass_through);
 
                if (!src_scb) {
-                       snd_printk (KERN_ERR "dsp_spos: failed to create SRCtaskSCB\n");
+                       dev_err(chip->card->dev,
+                               "dsp_spos: failed to create SRCtaskSCB\n");
                        return NULL;
                }
 
@@ -1355,8 +1371,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
   
        snprintf (scb_name,DSP_MAX_SCB_NAME,"PCMReader_SCB%d",pcm_index);
 
-       snd_printdd( "dsp_spos: creating PCM \"%s\" (%d)\n",scb_name,
-                 pcm_channel_id);
+       dev_dbg(chip->card->dev, "dsp_spos: creating PCM \"%s\" (%d)\n",
+               scb_name, pcm_channel_id);
 
        pcm_scb = cs46xx_dsp_create_pcm_reader_scb(chip,scb_name,
                                                   pcm_reader_buffer_addr[pcm_index],
@@ -1369,7 +1385,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
                            );
 
        if (!pcm_scb) {
-               snd_printk (KERN_ERR "dsp_spos: failed to create PCMreaderSCB\n");
+               dev_err(chip->card->dev,
+                       "dsp_spos: failed to create PCMreaderSCB\n");
                return NULL;
        }
        
@@ -1419,7 +1436,8 @@ int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
                temp |= DMA_RQ_C1_SOURCE_MOD16;
                break; 
        default:
-               snd_printdd ("period size (%d) not supported by HW\n", period_size);
+               dev_dbg(chip->card->dev,
+                       "period size (%d) not supported by HW\n", period_size);
                return -EINVAL;
        }
 
@@ -1457,7 +1475,8 @@ int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip,
                temp |= DMA_RQ_C1_DEST_MOD16;
                break; 
        default:
-               snd_printdd ("period size (%d) not supported by HW\n", period_size);
+               dev_dbg(chip->card->dev,
+                       "period size (%d) not supported by HW\n", period_size);
                return -EINVAL;
        }
 
index c6b82c85e044b9eec35e212f2dc487452651430e..b4e0ff6a99a331b4b3e06ca3ccc3330251687d0d 100644 (file)
@@ -160,17 +160,17 @@ static int snd_cs5530_create(struct snd_card *card,
        sb_base = 0x220 + 0x20 * (map & 3);
 
        if (map & (1<<2))
-               printk(KERN_INFO "CS5530: XpressAudio at 0x%lx\n", sb_base);
+               dev_info(card->dev, "XpressAudio at 0x%lx\n", sb_base);
        else {
-               printk(KERN_ERR "Could not find XpressAudio!\n");
+               dev_err(card->dev, "Could not find XpressAudio!\n");
                snd_cs5530_free(chip);
                return -ENODEV;
        }
 
        if (map & (1<<5))
-               printk(KERN_INFO "CS5530: MPU at 0x300\n");
+               dev_info(card->dev, "MPU at 0x300\n");
        else if (map & (1<<6))
-               printk(KERN_INFO "CS5530: MPU at 0x330\n");
+               dev_info(card->dev, "MPU at 0x330\n");
 
        irq = snd_cs5530_mixer_read(sb_base, 0x80) & 0x0F;
        dma8 = snd_cs5530_mixer_read(sb_base, 0x81);
@@ -182,7 +182,7 @@ static int snd_cs5530_create(struct snd_card *card,
        else if (dma8 & 0x80)
                dma16 = 7;
        else {
-               printk(KERN_ERR "CS5530: No 16bit DMA enabled\n");
+               dev_err(card->dev, "No 16bit DMA enabled\n");
                snd_cs5530_free(chip);
                return -ENODEV;
        }
@@ -194,7 +194,7 @@ static int snd_cs5530_create(struct snd_card *card,
        else if (dma8 & 0x08)
                dma8 = 3;
        else {
-               printk(KERN_ERR "CS5530: No 8bit DMA enabled\n");
+               dev_err(card->dev, "No 8bit DMA enabled\n");
                snd_cs5530_free(chip);
                return -ENODEV;
        }
@@ -208,32 +208,31 @@ static int snd_cs5530_create(struct snd_card *card,
        else if (irq & 8)
                irq = 10;
        else {
-               printk(KERN_ERR "CS5530: SoundBlaster IRQ not set\n");
+               dev_err(card->dev, "SoundBlaster IRQ not set\n");
                snd_cs5530_free(chip);
                return -ENODEV;
        }
 
-       printk(KERN_INFO "CS5530: IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8, 
-                                                                       dma16);
+       dev_info(card->dev, "IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8, dma16);
 
        err = snd_sbdsp_create(card, sb_base, irq, snd_sb16dsp_interrupt, dma8,
                                                dma16, SB_HW_CS5530, &chip->sb);
        if (err < 0) {
-               printk(KERN_ERR "CS5530: Could not create SoundBlaster\n");
+               dev_err(card->dev, "Could not create SoundBlaster\n");
                snd_cs5530_free(chip);
                return err;
        }
 
        err = snd_sb16dsp_pcm(chip->sb, 0, &chip->sb->pcm);
        if (err < 0) {
-               printk(KERN_ERR "CS5530: Could not create PCM\n");
+               dev_err(card->dev, "Could not create PCM\n");
                snd_cs5530_free(chip);
                return err;
        }
 
        err = snd_sbmixer_new(chip->sb);
        if (err < 0) {
-               printk(KERN_ERR "CS5530: Could not create Mixer\n");
+               dev_err(card->dev, "Could not create Mixer\n");
                snd_cs5530_free(chip);
                return err;
        }
@@ -244,7 +243,6 @@ static int snd_cs5530_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
        *rchip = chip;
        return 0;
 }
@@ -264,7 +262,8 @@ static int snd_cs5530_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
 
        if (err < 0)
                return err;
index c0d2835344dab60a8f2fef5f934a103d6fdd933f..edcbbda5c48854a00b0bb00f4d530d18f7bbf43f 100644 (file)
@@ -84,7 +84,8 @@ static void wait_till_cmd_acked(struct cs5535audio *cs5535au, unsigned long time
                udelay(1);
        } while (--timeout);
        if (!timeout)
-               snd_printk(KERN_ERR "Failure writing to cs5535 codec\n");
+               dev_err(cs5535au->card->dev,
+                       "Failure writing to cs5535 codec\n");
 }
 
 static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au,
@@ -109,8 +110,9 @@ static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au,
                udelay(1);
        } while (--timeout);
        if (!timeout)
-               snd_printk(KERN_ERR "Failure reading codec reg 0x%x,"
-                                       "Last value=0x%x\n", reg, val);
+               dev_err(cs5535au->card->dev,
+                       "Failure reading codec reg 0x%x, Last value=0x%x\n",
+                       reg, val);
 
        return (unsigned short) val;
 }
@@ -168,7 +170,7 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
        olpc_prequirks(card, &ac97);
 
        if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) {
-               snd_printk(KERN_ERR "mixer failed\n");
+               dev_err(card->dev, "mixer failed\n");
                return err;
        }
 
@@ -176,7 +178,7 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
 
        err = olpc_quirks(card, cs5535au->ac97);
        if (err < 0) {
-               snd_printk(KERN_ERR "olpc quirks failed\n");
+               dev_err(card->dev, "olpc quirks failed\n");
                return err;
        }
 
@@ -194,8 +196,9 @@ static void process_bm0_irq(struct cs5535audio *cs5535au)
                dma = cs5535au->playback_substream->runtime->private_data;
                snd_pcm_period_elapsed(cs5535au->playback_substream);
        } else {
-               snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n",
-                                       bm_stat);
+               dev_err(cs5535au->card->dev,
+                       "unexpected bm0 irq src, bm_stat=%x\n",
+                       bm_stat);
        }
 }
 
@@ -241,8 +244,9 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)
                                process_bm1_irq(cs5535au);
                                break;
                        default:
-                               snd_printk(KERN_ERR "Unexpected irq src: "
-                                               "0x%x\n", acc_irq_stat);
+                               dev_err(cs5535au->card->dev,
+                                       "Unexpected irq src: 0x%x\n",
+                                       acc_irq_stat);
                                break;
                        }
                }
@@ -287,7 +291,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
 
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
-               printk(KERN_WARNING "unable to get 32bit dma\n");
+               dev_warn(card->dev, "unable to get 32bit dma\n");
                err = -ENXIO;
                goto pcifail;
        }
@@ -312,7 +316,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_cs5535audio_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                err = -EBUSY;
                goto sndfail;
        }
@@ -324,8 +328,6 @@ static int snd_cs5535audio_create(struct snd_card *card,
                                  cs5535au, &ops)) < 0)
                goto sndfail;
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rcs5535au = cs5535au;
        return 0;
 
@@ -353,7 +355,8 @@ static int snd_cs5535audio_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
index e6a44507d55700ef689d6b98438452a53b008a24..3b0fdaca8dc7cdc005dfa35f0844f55068988af5 100644 (file)
@@ -36,7 +36,8 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on)
        err = snd_ac97_update_bits(ac97, AC97_AD_TEST2,
                        1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT);
        if (err < 0) {
-               snd_printk(KERN_ERR "setting High Pass Filter - %d\n", err);
+               dev_err(ac97->bus->card->dev,
+                       "setting High Pass Filter - %d\n", err);
                return;
        }
 
@@ -58,7 +59,7 @@ void olpc_mic_bias(struct snd_ac97 *ac97, int on)
        err = snd_ac97_update_bits(ac97, AC97_AD_MISC,
                        1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT);
        if (err < 0)
-               snd_printk(KERN_ERR "setting MIC Bias - %d\n", err);
+               dev_err(ac97->bus->card->dev, "setting MIC Bias - %d\n", err);
 }
 
 static int olpc_dc_info(struct snd_kcontrol *kctl,
@@ -153,7 +154,7 @@ int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
                return 0;
 
        if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) {
-               printk(KERN_ERR DRV_NAME ": unable to allocate MIC GPIO\n");
+               dev_err(card->dev, "unable to allocate MIC GPIO\n");
                return -EIO;
        }
        gpio_direction_output(OLPC_GPIO_MIC_AC, 0);
index 9ab01a7047cfe3230bbf41c3944c1ab260887c02..9c2dc911d8d7f0fa8231ac5296e361c4097b47a4 100644 (file)
@@ -317,7 +317,7 @@ static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd)
                dma->ops->disable_dma(cs5535au);
                break;
        default:
-               snd_printk(KERN_ERR "unhandled trigger\n");
+               dev_err(cs5535au->card->dev, "unhandled trigger\n");
                err = -EINVAL;
                break;
        }
@@ -335,13 +335,13 @@ static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(struct snd_pcm_substream
        dma = substream->runtime->private_data;
        curdma = dma->ops->read_dma_pntr(cs5535au);
        if (curdma < dma->buf_addr) {
-               snd_printk(KERN_ERR "curdma=%x < %x bufaddr.\n",
+               dev_err(cs5535au->card->dev, "curdma=%x < %x bufaddr.\n",
                                        curdma, dma->buf_addr);
                return 0;
        }
        curdma -= dma->buf_addr;
        if (curdma >= dma->buf_bytes) {
-               snd_printk(KERN_ERR "diff=%x >= %x buf_bytes.\n",
+               dev_err(cs5535au->card->dev, "diff=%x >= %x buf_bytes.\n",
                                        curdma, dma->buf_bytes);
                return 0;
        }
index 6c34def5986d76415eb87f07c227b694dc0005c4..34cc60057d0c45c34da1f852a87e19be252c5a3d 100644 (file)
@@ -74,7 +74,7 @@ static int snd_cs5535audio_suspend(struct device *dev)
        snd_cs5535audio_stop_hardware(cs5535au);
 
        if (pci_save_state(pci)) {
-               printk(KERN_ERR "cs5535audio: pci_save_state failed!\n");
+               dev_err(dev, "pci_save_state failed!\n");
                return -EIO;
        }
        pci_disable_device(pci);
@@ -94,8 +94,7 @@ static int snd_cs5535audio_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "cs5535audio: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -113,7 +112,7 @@ static int snd_cs5535audio_resume(struct device *dev)
        } while (--timeout);
 
        if (!timeout)
-               snd_printk(KERN_ERR "Failure getting AC Link ready\n");
+               dev_err(cs5535au->card->dev, "Failure getting AC Link ready\n");
 
        /* set up rate regs, dma. actual initiation is done in trig */
        for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
index eb86829529eb3e7f56da61324f8f16a87f3a44c6..af632bd08323feaf0f9ab2d3098375e12f38d46b 100644 (file)
@@ -1739,8 +1739,6 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
        if (err < 0)
                goto error1;
 
-       snd_card_set_dev(card, &pci->dev);
-
        *ratc = atc;
        return 0;
 
index d464ad2fc7b71632afd81df4ef0e3ea4dda265f2..98426d09c8bd7ac6e46dd7b49ef272fc0a99bfb8 100644 (file)
@@ -71,7 +71,8 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                dev++;
                return -ENOENT;
        }
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err)
                return err;
        if ((reference_rate != 48000) && (reference_rate != 44100)) {
index 05cfe551ce425b6d4049755688d6d76883e768c8..9f10c9e0df5e853950f9244487261454099a4d59 100644 (file)
@@ -58,7 +58,8 @@ static int get_firmware(const struct firmware **fw_entry,
        snprintf(name, sizeof(name), "ea/%s", card_fw[fw_index].data);
        err = request_firmware(fw_entry, name, pci_device(chip));
        if (err < 0)
-               snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err);
+               dev_err(chip->card->dev,
+                       "get_firmware(): Firmware not available (%d)\n", err);
 #ifdef CONFIG_PM_SLEEP
        else
                chip->fw_cache[fw_index] = *fw_entry;
@@ -563,7 +564,7 @@ static int init_engine(struct snd_pcm_substream *substream,
        err = snd_pcm_lib_malloc_pages(substream,
                                       params_buffer_bytes(hw_params));
        if (err < 0) {
-               snd_printk(KERN_ERR "malloc_pages err=%d\n", err);
+               dev_err(chip->card->dev, "malloc_pages err=%d\n", err);
                spin_lock_irq(&chip->lock);
                free_pipes(chip, pipe);
                spin_unlock_irq(&chip->lock);
@@ -1989,8 +1990,8 @@ static int snd_echo_create(struct snd_card *card,
 
        if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz,
                                              ECHOCARD_NAME)) == NULL) {
+               dev_err(chip->card->dev, "cannot get memory region\n");
                snd_echo_free(chip);
-               snd_printk(KERN_ERR "cannot get memory region\n");
                return -EBUSY;
        }
        chip->dsp_registers = (volatile u32 __iomem *)
@@ -1998,8 +1999,8 @@ static int snd_echo_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
+               dev_err(chip->card->dev, "cannot grab irq\n");
                snd_echo_free(chip);
-               snd_printk(KERN_ERR "cannot grab irq\n");
                return -EBUSY;
        }
        chip->irq = pci->irq;
@@ -2011,8 +2012,8 @@ static int snd_echo_create(struct snd_card *card,
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
                                sizeof(struct comm_page),
                                &chip->commpage_dma_buf) < 0) {
+               dev_err(chip->card->dev, "cannot allocate the comm page\n");
                snd_echo_free(chip);
-               snd_printk(KERN_ERR "cannot allocate the comm page\n");
                return -ENOMEM;
        }
        chip->comm_page_phys = chip->commpage_dma_buf.addr;
@@ -2058,12 +2059,11 @@ static int snd_echo_probe(struct pci_dev *pci,
 
        DE_INIT(("Echoaudio driver starting...\n"));
        i = 0;
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
-       snd_card_set_dev(card, &pci->dev);
-
        chip = NULL;    /* Tells snd_echo_create to allocate chip */
        if ((err = snd_echo_create(card, pci, &chip)) < 0) {
                snd_card_free(card);
@@ -2082,7 +2082,7 @@ static int snd_echo_probe(struct pci_dev *pci,
                chip->dsp_registers_phys, chip->irq);
 
        if ((err = snd_echo_new_pcm(chip)) < 0) {
-               snd_printk(KERN_ERR "new pcm error %d\n", err);
+               dev_err(chip->card->dev, "new pcm error %d\n", err);
                snd_card_free(card);
                return err;
        }
@@ -2090,7 +2090,7 @@ static int snd_echo_probe(struct pci_dev *pci,
 #ifdef ECHOCARD_HAS_MIDI
        if (chip->has_midi) {   /* Some Mia's do not have midi */
                if ((err = snd_echo_midi_create(card, chip)) < 0) {
-                       snd_printk(KERN_ERR "new midi error %d\n", err);
+                       dev_err(chip->card->dev, "new midi error %d\n", err);
                        snd_card_free(card);
                        return err;
                }
@@ -2189,14 +2189,14 @@ static int snd_echo_probe(struct pci_dev *pci,
        err = snd_card_register(card);
        if (err < 0)
                goto ctl_error;
-       snd_printk(KERN_INFO "Card registered: %s\n", card->longname);
+       dev_info(card->dev, "Card registered: %s\n", card->longname);
 
        pci_set_drvdata(pci, chip);
        dev++;
        return 0;
 
 ctl_error:
-       snd_printk(KERN_ERR "new control error %d\n", err);
+       dev_err(card->dev, "new control error %d\n", err);
        snd_card_free(card);
        return err;
 }
@@ -2291,8 +2291,8 @@ static int snd_echo_resume(struct device *dev)
 
        if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
+               dev_err(chip->card->dev, "cannot grab irq\n");
                snd_echo_free(chip);
-               snd_printk(KERN_ERR "cannot grab irq\n");
                return -EBUSY;
        }
        chip->irq = pci->irq;
index d8c670c9d62c4e35cab25ac6e36d09466e2716d9..5a6a217b82e0ae47cd43607a9908663530a1bf1d 100644 (file)
@@ -53,7 +53,7 @@ static int wait_handshake(struct echoaudio *chip)
                udelay(1);
        }
 
-       snd_printk(KERN_ERR "wait_handshake(): Timeout waiting for DSP\n");
+       dev_err(chip->card->dev, "wait_handshake(): Timeout waiting for DSP\n");
        return -EBUSY;
 }
 
@@ -149,7 +149,8 @@ static int read_sn(struct echoaudio *chip)
 
        for (i = 0; i < 5; i++) {
                if (read_dsp(chip, &sn[i])) {
-                       snd_printk(KERN_ERR "Failed to read serial number\n");
+                       dev_err(chip->card->dev,
+                               "Failed to read serial number\n");
                        return -EIO;
                }
        }
@@ -184,7 +185,7 @@ static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic)
 
        err = get_firmware(&fw, chip, asic);
        if (err < 0) {
-               snd_printk(KERN_WARNING "Firmware not found !\n");
+               dev_warn(chip->card->dev, "Firmware not found !\n");
                return err;
        }
 
@@ -247,7 +248,7 @@ static int install_resident_loader(struct echoaudio *chip)
 
        i = get_firmware(&fw, chip, FW_361_LOADER);
        if (i < 0) {
-               snd_printk(KERN_WARNING "Firmware not found !\n");
+               dev_warn(chip->card->dev, "Firmware not found !\n");
                return i;
        }
 
index abfd51c2530ed9172cba8e98fef3714ad4e6b690..7f4dfae0323ad4f8bd8a83b4389b102d7aa5bccc 100644 (file)
@@ -221,7 +221,8 @@ static void snd_echo_midi_output_write(unsigned long data)
                DE_MID(("Try to send %d bytes...\n", bytes));
                sent = write_midi(chip, buf, bytes);
                if (sent < 0) {
-                       snd_printk(KERN_ERR "write_midi() error %d\n", sent);
+                       dev_err(chip->card->dev,
+                               "write_midi() error %d\n", sent);
                        /* retry later */
                        sent = 9000;
                        chip->midi_full = 1;
index 9e1bd0c39a8cf27230bd50196a525d1c2c3f525d..ad9d9f8b48ed0d5bc737a04bfeab404ac20179d2 100644 (file)
@@ -117,7 +117,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        if (max_buffer_size[dev] < 32)
@@ -169,7 +170,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
        if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
                               sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 ||
            wave == NULL) {
-               snd_printk(KERN_WARNING "can't initialize Emu10k1 wavetable synth\n");
+               dev_warn(emu->card->dev,
+                        "can't initialize Emu10k1 wavetable synth\n");
        } else {
                struct snd_emu10k1_synth_arg *arg;
                arg = SNDRV_SEQ_DEVICE_ARGPTR(wave);
@@ -246,8 +248,7 @@ static int snd_emu10k1_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "emu10k1: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index cae36597aa718c3fc13abe95221a2308627c2c8c..3f3ef38d9b6e5f9facddfbddb0d1b2ebfaa8c7d9 100644 (file)
@@ -105,7 +105,7 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
                        vp = &emu->voices[best[i].voice];
                        if ((ch = vp->ch) < 0) {
                                /*
-                               printk(KERN_WARNING
+                               dev_warn(emu->card->dev,
                                       "synth_get_voice: ch < 0 (%d) ??", i);
                                */
                                continue;
@@ -339,7 +339,7 @@ start_voice(struct snd_emux_voice *vp)
                return -EINVAL;
        emem->map_locked++;
        if (snd_emu10k1_memblk_map(hw, emem) < 0) {
-               /* printk(KERN_ERR "emu: cannot map!\n"); */
+               /* dev_err(hw->card->devK, "emu: cannot map!\n"); */
                return -ENOMEM;
        }
        mapped_offset = snd_emu10k1_memblk_offset(emem) >> 1;
index bdd888ec9a8422838144fd93e8c8b8cff92ee4fe..2292697880235b8dd6c440064ba9a7b266d6d370 100644 (file)
@@ -217,7 +217,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
        }
        if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
                /* Hacks for Alice3 to work independent of haP16V driver */
-               snd_printk(KERN_INFO "Audigy2 value: Special config.\n");
+               dev_info(emu->card->dev, "Audigy2 value: Special config.\n");
                /* Setup SRCMulti_I2S SamplingRate */
                tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
                tmp &= 0xfffff1ff;
@@ -723,7 +723,8 @@ static int emu1010_firmware_thread(void *data)
                if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) {
                        /* Audio Dock attached */
                        /* Return to Audio Dock programming mode */
-                       snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
+                       dev_info(emu->card->dev,
+                                "emu1010: Loading Audio Dock Firmware\n");
                        snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK);
 
                        if (!emu->dock_fw) {
@@ -756,19 +757,25 @@ static int emu1010_firmware_thread(void *data)
 
                        snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0);
                        snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg);
-                       snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", reg);
+                       dev_info(emu->card->dev,
+                                "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n",
+                                reg);
                        /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
                        snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
-                       snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg);
+                       dev_info(emu->card->dev,
+                                "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg);
                        if ((reg & 0x1f) != 0x15) {
                                /* FPGA failed to be programmed */
-                               snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg);
+                               dev_info(emu->card->dev,
+                                        "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n",
+                                        reg);
                                continue;
                        }
-                       snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n");
+                       dev_info(emu->card->dev,
+                                "emu1010: Audio Dock Firmware loaded\n");
                        snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp);
                        snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2);
-                       snd_printk(KERN_INFO "Audio Dock ver: %u.%u\n",
+                       dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n",
                                   tmp, tmp2);
                        /* Sync clocking between 1010 and Dock */
                        /* Allow DLL to settle */
@@ -777,7 +784,7 @@ static int emu1010_firmware_thread(void *data)
                        snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE);
                }
        }
-       snd_printk(KERN_INFO "emu1010: firmware thread stopping\n");
+       dev_info(emu->card->dev, "emu1010: firmware thread stopping\n");
        return 0;
 }
 
@@ -818,7 +825,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
        u32 tmp, tmp2, reg;
        int err;
 
-       snd_printk(KERN_INFO "emu1010: Special config.\n");
+       dev_info(emu->card->dev, "emu1010: Special config.\n");
        /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
         * Lock Sound Memory Cache, Lock Tank Memory Cache,
         * Mute all codecs.
@@ -843,7 +850,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
 
        /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
        snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
-       snd_printdd("reg1 = 0x%x\n", reg);
+       dev_dbg(emu->card->dev, "reg1 = 0x%x\n", reg);
        if ((reg & 0x3f) == 0x15) {
                /* FPGA netlist already present so clear it */
                /* Return to programming mode */
@@ -851,13 +858,14 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
                snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02);
        }
        snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
-       snd_printdd("reg2 = 0x%x\n", reg);
+       dev_dbg(emu->card->dev, "reg2 = 0x%x\n", reg);
        if ((reg & 0x3f) == 0x15) {
                /* FPGA failed to return to programming mode */
-               snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n");
+               dev_info(emu->card->dev,
+                        "emu1010: FPGA failed to return to programming mode\n");
                return -ENODEV;
        }
-       snd_printk(KERN_INFO "emu1010: EMU_HANA_ID = 0x%x\n", reg);
+       dev_info(emu->card->dev, "emu1010: EMU_HANA_ID = 0x%x\n", reg);
 
        if (!emu->firmware) {
                const char *filename;
@@ -880,16 +888,19 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
 
                err = request_firmware(&emu->firmware, filename, &emu->pci->dev);
                if (err != 0) {
-                       snd_printk(KERN_ERR "emu1010: firmware: %s not found. Err = %d\n", filename, err);
+                       dev_info(emu->card->dev,
+                                "emu1010: firmware: %s not found. Err = %d\n",
+                                filename, err);
                        return err;
                }
-               snd_printk(KERN_INFO "emu1010: firmware file = %s, size = 0x%zx\n",
+               dev_info(emu->card->dev,
+                        "emu1010: firmware file = %s, size = 0x%zx\n",
                           filename, emu->firmware->size);
        }
 
        err = snd_emu1010_load_firmware(emu, emu->firmware);
        if (err != 0) {
-               snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n");
+               dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n");
                return err;
        }
 
@@ -897,21 +908,23 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
        snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
        if ((reg & 0x3f) != 0x15) {
                /* FPGA failed to be programmed */
-               snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg);
+               dev_info(emu->card->dev,
+                        "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n",
+                        reg);
                return -ENODEV;
        }
 
-       snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n");
+       dev_info(emu->card->dev, "emu1010: Hana Firmware loaded\n");
        snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp);
        snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2);
-       snd_printk(KERN_INFO "emu1010: Hana version: %u.%u\n", tmp, tmp2);
+       dev_info(emu->card->dev, "emu1010: Hana version: %u.%u\n", tmp, tmp2);
        /* Enable 48Volt power to Audio Dock */
        snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON);
 
        snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
-       snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg);
+       dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg);
        snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
-       snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg);
+       dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg);
        snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp);
        /* Optical -> ADAT I/O  */
        /* 0 : SPDIF
@@ -950,7 +963,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
        snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
 
        snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
-       snd_printk(KERN_INFO "emu1010: Card options3 = 0x%x\n", reg);
+       dev_info(emu->card->dev, "emu1010: Card options3 = 0x%x\n", reg);
        /* Default WCLK set to 48kHz. */
        snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00);
        /* Word Clock source, Internal 48kHz x1 */
@@ -1808,7 +1821,9 @@ int snd_emu10k1_create(struct snd_card *card,
        emu->revision = pci->revision;
        pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
        pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
-       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);
+       dev_dbg(card->dev,
+               "vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n",
+               pci->vendor, pci->device, emu->serial, emu->model);
 
        for (c = emu_chip_details; c->vendor; c++) {
                if (c->vendor == pci->vendor && c->device == pci->device) {
@@ -1827,21 +1842,21 @@ int snd_emu10k1_create(struct snd_card *card,
                }
        }
        if (c->vendor == 0) {
-               snd_printk(KERN_ERR "emu10k1: Card not recognised\n");
+               dev_err(card->dev, "emu10k1: Card not recognised\n");
                kfree(emu);
                pci_disable_device(pci);
                return -ENOENT;
        }
        emu->card_capabilities = c;
        if (c->subsystem && !subsystem)
-               snd_printdd("Sound card name = %s\n", c->name);
+               dev_dbg(card->dev, "Sound card name = %s\n", c->name);
        else if (subsystem)
-               snd_printdd("Sound card name = %s, "
+               dev_dbg(card->dev, "Sound card name = %s, "
                        "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. "
                        "Forced to subsystem = 0x%x\n", c->name,
                        pci->vendor, pci->device, emu->serial, c->subsystem);
        else
-               snd_printdd("Sound card name = %s, "
+               dev_dbg(card->dev, "Sound card name = %s, "
                        "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n",
                        c->name, pci->vendor, pci->device,
                        emu->serial);
@@ -1869,7 +1884,9 @@ int snd_emu10k1_create(struct snd_card *card,
        emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
        if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||
            pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
-               snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
+               dev_err(card->dev,
+                       "architecture does not support PCI busmaster DMA with mask 0x%lx\n",
+                       emu->dma_mask);
                kfree(emu);
                pci_disable_device(pci);
                return -ENXIO;
@@ -2021,7 +2038,6 @@ int snd_emu10k1_create(struct snd_card *card,
        snd_emu10k1_proc_init(emu);
 #endif
 
-       snd_card_set_dev(card, &pci->dev);
        *remu = emu;
        return 0;
 
index 662a45876a8b3d9b6e1008173216b32c705776bf..0e069aeab86d1075112daf01fe6384332017eb63 100644 (file)
@@ -50,7 +50,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
                return -EINVAL;
 
        if (sp->v.size == 0) {
-               snd_printd("emu: rom font for sample %d\n", sp->v.sample);
+               dev_dbg(emu->card->dev,
+                       "emu: rom font for sample %d\n", sp->v.sample);
                return 0;
        }
 
@@ -92,7 +93,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
                blocksize *= 2;
        sp->block = snd_emu10k1_synth_alloc(emu, blocksize);
        if (sp->block == NULL) {
-               snd_printd("emu10k1: synth malloc failed (size=%d)\n", blocksize);
+               dev_dbg(emu->card->dev,
+                       "synth malloc failed (size=%d)\n", blocksize);
                /* not ENOMEM (for compatibility with OSS) */
                return -ENOSPC;
        }
index 56ad9d6f200df7daa7de21fea6d7d59ef502c881..efe0175269771b0c674cc854bbe5e1896ef9e6b8 100644 (file)
@@ -369,7 +369,8 @@ static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voi
        if (epcm->substream == NULL)
                return;
 #if 0
-       snd_printk(KERN_INFO "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
+       dev_info(emu->card->dev,
+                "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
                   epcm->substream->ops->pointer(epcm->substream),
                   snd_pcm_lib_period_bytes(epcm->substream),
                   snd_pcm_lib_buffer_bytes(epcm->substream));
@@ -487,7 +488,11 @@ static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream,
        int channel = epcm->voice->number;
        int result = 0;
 
-//     snd_printk(KERN_INFO "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", (int)emu, cmd, (int)substream->ops->pointer(substream));
+       /*
+       dev_dbg(emu->card->dev,
+               "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n",
+               (int)emu, cmd, (int)substream->ops->pointer(substream));
+       */
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -826,7 +831,7 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id)
        // acknowledge the interrupt if necessary
        outl(status, chip->port + IPR);
 
-       // snd_printk(KERN_INFO "interrupt %08x\n", status);
+       /* dev_dbg(chip->card->dev, "interrupt %08x\n", status); */
        return IRQ_HANDLED;
 }
 
@@ -919,7 +924,7 @@ static int snd_emu10k1x_create(struct snd_card *card,
                return err;
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
-               snd_printk(KERN_ERR "error to set 28bit mask DMA\n");
+               dev_err(card->dev, "error to set 28bit mask DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -940,14 +945,15 @@ static int snd_emu10k1x_create(struct snd_card *card,
        chip->port = pci_resource_start(pci, 0);
        if ((chip->res_port = request_region(chip->port, 8,
                                             "EMU10K1X")) == NULL) { 
-               snd_printk(KERN_ERR "emu10k1x: cannot allocate the port 0x%lx\n", chip->port);
+               dev_err(card->dev, "cannot allocate the port 0x%lx\n",
+                       chip->port);
                snd_emu10k1x_free(chip);
                return -EBUSY;
        }
 
        if (request_irq(pci->irq, snd_emu10k1x_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "emu10k1x: cannot grab irq %d\n", pci->irq);
+               dev_err(card->dev, "cannot grab irq %d\n", pci->irq);
                snd_emu10k1x_free(chip);
                return -EBUSY;
        }
@@ -964,7 +970,7 @@ static int snd_emu10k1x_create(struct snd_card *card,
        chip->revision = pci->revision;
        pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
        pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
-       snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model,
+       dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n", chip->model,
                   chip->revision, chip->serial);
 
        outl(0, chip->port + INTE);     
@@ -1248,7 +1254,9 @@ static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu)
                mpu401_read_data(emu, mpu);
 #ifdef CONFIG_SND_DEBUG
        if (timeout <= 0)
-               snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu));
+               dev_err(emu->card->dev,
+                       "cmd: clear rx timeout (status = 0x%x)\n",
+                       mpu401_read_stat(emu, mpu));
 #endif
 }
 
@@ -1322,7 +1330,8 @@ static int snd_emu10k1x_midi_cmd(struct emu10k1x * emu,
        }
        spin_unlock_irqrestore(&midi->input_lock, flags);
        if (!ok) {
-               snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
+               dev_err(emu->card->dev,
+                       "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
                           cmd, emu->port,
                           mpu401_read_stat(emu, midi),
                           mpu401_read_data(emu, midi));
@@ -1564,7 +1573,8 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -1608,8 +1618,6 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
        sprintf(card->longname, "%s at 0x%lx irq %i",
                card->shortname, chip->port, chip->irq);
 
-       snd_card_set_dev(card, &pci->dev);
-
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
                return err;
index 1f9c7c4bbcd8b0f3db5fb8552a24fba5dd9467f8..745f0627c634eb0f678ba1eec736f091f50bce9f 100644 (file)
@@ -1547,7 +1547,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
        /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */
        if (emu->card_capabilities->emu_model) {
                /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */
-               snd_printk(KERN_INFO "EMU outputs on\n");
+               dev_info(emu->card->dev, "EMU outputs on\n");
                for (z = 0; z < 8; z++) {
                        if (emu->card_capabilities->ca0108_chip) {
                                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))
                A_SWITCH(icode, &ptr, tmp + 1, playback + SND_EMU10K1_PLAYBACK_CHANNELS + z, tmp + 1);
                if ((z==1) && (emu->card_capabilities->spdif_bug)) {
                        /* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */
-                       snd_printk(KERN_INFO "Installing spdif_bug patch: %s\n", emu->card_capabilities->name);
+                       dev_info(emu->card->dev,
+                                "Installing spdif_bug patch: %s\n",
+                                emu->card_capabilities->name);
                        A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_00000000);
                        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000);
                } else {
@@ -1595,7 +1597,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
 
        if (emu->card_capabilities->emu_model) {
                if (emu->card_capabilities->ca0108_chip) {
-                       snd_printk(KERN_INFO "EMU2 inputs on\n");
+                       dev_info(emu->card->dev, "EMU2 inputs on\n");
                        for (z = 0; z < 0x10; z++) {
                                snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, 
                                                                        bit_shifter16,
@@ -1603,11 +1605,11 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
                                                                        A_FXBUS2(z*2) );
                        }
                } else {
-                       snd_printk(KERN_INFO "EMU inputs on\n");
+                       dev_info(emu->card->dev, "EMU inputs on\n");
                        /* Capture 16 (originally 8) channels of S32_LE sound */
 
                        /*
-                       printk(KERN_DEBUG "emufx.c: gpr=0x%x, tmp=0x%x\n",
+                       dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n",
                               gpr, tmp);
                        */
                        /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
index f6c3da0d377d19e5a2b0822e07a1c66cd8b7199b..c5ae2a24d8a53f9f31775b2c4ae51fff0db569cf 100644 (file)
@@ -1853,8 +1853,10 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
                if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) {
                        if (emu->card_capabilities->ac97_chip == 1)
                                return err;
-                       snd_printd(KERN_INFO "emu10k1: AC97 is optional on this board\n");
-                       snd_printd(KERN_INFO"          Proceeding without ac97 mixers...\n");
+                       dev_info(emu->card->dev,
+                                "AC97 is optional on this board\n");
+                       dev_info(emu->card->dev,
+                                "Proceeding without ac97 mixers...\n");
                        snd_device_free(emu->card, pbus);
                        goto no_ac97; /* FIXME: get rid of ugly gotos.. */
                }
index 1ec91246dfee5cdff16bf2b68c939d3a90848efc..fdf2b0ada48977c9fd58b6e7794883f60a852146 100644 (file)
@@ -64,7 +64,9 @@ static void mpu401_clear_rx(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mp
                mpu401_read_data(emu, mpu);
 #ifdef CONFIG_SND_DEBUG
        if (timeout <= 0)
-               snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu));
+               dev_err(emu->card->dev,
+                       "cmd: clear rx timeout (status = 0x%x)\n",
+                       mpu401_read_stat(emu, mpu));
 #endif
 }
 
@@ -141,7 +143,8 @@ static int snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_mid
        }
        spin_unlock_irqrestore(&midi->input_lock, flags);
        if (!ok) {
-               snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
+               dev_err(emu->card->dev,
+                       "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
                           cmd, emu->port,
                           mpu401_read_stat(emu, midi),
                           mpu401_read_data(emu, midi));
index 5ae1d045bdcb5f0bfad786ab3cc527adbeb3bc86..f82481bd2542a912924088e8725dc56bf9bbdf23 100644 (file)
@@ -44,7 +44,8 @@ static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu,
        if (epcm->substream == NULL)
                return;
 #if 0
-       printk(KERN_DEBUG "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
+       dev_dbg(emu->card->dev,
+               "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
                        epcm->substream->runtime->hw->pointer(emu, epcm->substream),
                        snd_pcm_lib_period_bytes(epcm->substream),
                        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
                                              &epcm->extra);
                if (err < 0) {
                        /*
-                       printk(KERN_DEBUG "pcm_channel_alloc: "
+                       dev_dbg(emu->card->dev, "pcm_channel_alloc: "
                               "failed extra: voices=%d, frame=%d\n",
                               voices, frame);
                        */
@@ -761,7 +762,8 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream,
        int result = 0;
 
        /*
-       printk(KERN_DEBUG "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n",
+       dev_dbg(emu->card->dev,
+               "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n",
               (int)emu, cmd, substream->ops->pointer(substream))
        */
        spin_lock(&emu->reg_lock);
@@ -815,7 +817,7 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
                outl(epcm->capture_ipr, emu->port + IPR);
                snd_emu10k1_intr_enable(emu, epcm->capture_inte);
                /*
-               printk(KERN_DEBUG "adccr = 0x%x, adcbs = 0x%x\n",
+               dev_dbg(emu->card->dev, "adccr = 0x%x, adcbs = 0x%x\n",
                       epcm->adccr, epcm->adcbs);
                */
                switch (epcm->type) {
@@ -826,7 +828,10 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
                        if (emu->audigy) {
                                snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val);
                                snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2);
-                               snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2);
+                               dev_dbg(emu->card->dev,
+                                       "cr_val=0x%x, cr_val2=0x%x\n",
+                                       epcm->capture_cr_val,
+                                       epcm->capture_cr_val2);
                        } else
                                snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val);
                        break;
@@ -889,7 +894,7 @@ static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *
        }
 #endif
        /*
-       printk(KERN_DEBUG
+       dev_dbg(emu->card->dev,
               "ptr = 0x%lx, buffer_size = 0x%lx, period_size = 0x%lx\n",
               (long)ptr, (long)runtime->buffer_size,
               (long)runtime->period_size);
@@ -1594,7 +1599,8 @@ static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left,
                                                   unsigned int tram_shift)
 {
        /*
-       printk(KERN_DEBUG "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, "
+       dev_dbg(emu->card->dev,
+               "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, "
               "src = 0x%p, count = 0x%x\n",
               dst_left, dst_right, src, count);
        */
@@ -1675,7 +1681,7 @@ static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substre
        unsigned int i;
        
        /*
-       printk(KERN_DEBUG "prepare: etram_pages = 0x%p, dma_area = 0x%x, "
+       dev_dbg(emu->card->dev, "prepare: etram_pages = 0x%p, dma_area = 0x%x, "
               "buffer_size = 0x%x (0x%x)\n",
               emu->fx8010.etram_pages, runtime->dma_area,
               runtime->buffer_size, runtime->buffer_size << 2);
index e4fba49fee4a9cd633e0968203832ac7a1dbc4fe..706b4f0c6806b00495e20cbb9bdccd5bba63491f 100644 (file)
@@ -71,11 +71,8 @@ void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned i
        unsigned long flags;
        unsigned int mask;
 
-       if (!emu) {
-               snd_printk(KERN_ERR "ptr_write: emu is null!\n");
-               dump_stack();
+       if (snd_BUG_ON(!emu))
                return;
-       }
        mask = emu->audigy ? A_PTR_ADDRESS_MASK : PTR_ADDRESS_MASK;
        regptr = ((reg << 16) & mask) | (chn & PTR_CHANNELNUM_MASK);
 
@@ -199,7 +196,7 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
        int err = 0;
 
        if ((reg > 0x7f) || (value > 0x1ff)) {
-               snd_printk(KERN_ERR "i2c_write: invalid values.\n");
+               dev_err(emu->card->dev, "i2c_write: invalid values.\n");
                return -EINVAL;
        }
 
@@ -227,7 +224,7 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
                                break;
 
                        if (timeout > 1000) {
-                               snd_printk(KERN_WARNING
+                               dev_warn(emu->card->dev,
                                           "emu10k1:I2C:timeout status=0x%x\n",
                                           status);
                                break;
@@ -239,8 +236,8 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
        }
 
        if (retry == 10) {
-               snd_printk(KERN_ERR "Writing to ADC failed!\n");
-               snd_printk(KERN_ERR "status=0x%x, reg=%d, value=%d\n",
+               dev_err(emu->card->dev, "Writing to ADC failed!\n");
+               dev_err(emu->card->dev, "status=0x%x, reg=%d, value=%d\n",
                        status, reg, value);
                /* dump_stack(); */
                err = -EINVAL;
index 30bfed6f83398d5f9b17fdf776ce2ab6ebac7a4e..3c5c5e3dc2d97b885bdf861594b82a3b52db12d1 100644 (file)
@@ -41,11 +41,12 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
                orig_status = status;
                handled = 1;
                if ((status & 0xffffffff) == 0xffffffff) {
-                       snd_printk(KERN_INFO "snd-emu10k1: Suspected sound card removal\n");
+                       dev_info(emu->card->dev,
+                                "Suspected sound card removal\n");
                        break;
                }
                if (status & IPR_PCIERROR) {
-                       snd_printk(KERN_ERR "interrupt: PCI error\n");
+                       dev_err(emu->card->dev, "interrupt: PCI error\n");
                        snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE);
                        status &= ~IPR_PCIERROR;
                }
@@ -157,19 +158,22 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
                                struct snd_emu10k1_voice *pvoice = &(emu->p16v_voices[0]);
                                struct snd_emu10k1_voice *cvoice = &(emu->p16v_capture_voice);
 
-                               //printk(KERN_INFO "status2=0x%x\n", status2);
+                               /* dev_dbg(emu->card->dev, "status2=0x%x\n", status2); */
                                orig_status2 = status2;
                                if(status2 & mask) {
                                        if(pvoice->use) {
                                                snd_pcm_period_elapsed(pvoice->epcm->substream);
                                        } else { 
-                                               snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use);
+                                               dev_err(emu->card->dev,
+                                                       "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n",
+                                                       status2, mask, pvoice,
+                                                       pvoice->use);
                                        }
                                }
                                if(status2 & 0x110000) {
-                                       //printk(KERN_INFO "capture int found\n");
+                                       /* dev_info(emu->card->dev, "capture int found\n"); */
                                        if(cvoice->use) {
-                                               //printk(KERN_INFO "capture period_elapsed\n");
+                                               /* dev_info(emu->card->dev, "capture period_elapsed\n"); */
                                                snd_pcm_period_elapsed(cvoice->epcm->substream);
                                        }
                                }
@@ -180,7 +184,8 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
 
                if (status) {
                        unsigned int bits;
-                       snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status);
+                       dev_err(emu->card->dev,
+                               "unhandled interrupt: 0x%08x\n", status);
                        //make sure any interrupts we don't handle are disabled:
                        bits = INTE_FXDSPENABLE |
                                INTE_PCIERRORENABLE |
@@ -202,7 +207,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
                outl(orig_status, emu->port + IPR); /* ack all */
        }
        if (timeout == 1000)
-               snd_printk(KERN_INFO "emu10k1 irq routine failure\n");
+               dev_info(emu->card->dev, "emu10k1 irq routine failure\n");
 
        return IRQ_RETVAL(handled);
 }
index ae709c1ab3a848e3b954d7e04747d423b30d1e55..c68e6dd2fa6772fc88cae359b1b7947f1c4e9796 100644 (file)
@@ -236,11 +236,13 @@ __found_pages:
 static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr)
 {
        if (addr & ~emu->dma_mask) {
-               snd_printk(KERN_ERR "max memory size is 0x%lx (addr = 0x%lx)!!\n", emu->dma_mask, (unsigned long)addr);
+               dev_err(emu->card->dev,
+                       "max memory size is 0x%lx (addr = 0x%lx)!!\n",
+                       emu->dma_mask, (unsigned long)addr);
                return 0;
        }
        if (addr & (EMUPAGESIZE-1)) {
-               snd_printk(KERN_ERR "page is not aligned\n");
+               dev_err(emu->card->dev, "page is not aligned\n");
                return 0;
        }
        return 1;
@@ -331,7 +333,8 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
                else
                        addr = snd_pcm_sgbuf_get_addr(substream, ofs);
                if (! is_valid_page(emu, addr)) {
-                       printk(KERN_ERR "emu: failure page = %d\n", idx);
+                       dev_err(emu->card->dev,
+                               "emu: failure page = %d\n", idx);
                        mutex_unlock(&hdr->block_mutex);
                        return NULL;
                }
@@ -507,7 +510,8 @@ static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset)
                return NULL;
        ptr = emu->page_ptr_table[page];
        if (! ptr) {
-               printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page);
+               dev_err(emu->card->dev,
+                       "access to NULL ptr: page = %d\n", page);
                return NULL;
        }
        ptr += offset & (PAGE_SIZE - 1);
index 7e2025cd6d9cc07a3696cb4f1e038c8b5e3e6ef6..a4fe7f0c945809a5a4da90585d5f0a8a2b8fb4c1 100644 (file)
@@ -168,7 +168,7 @@ static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime)
        struct snd_emu10k1_pcm *epcm = runtime->private_data;
   
        if (epcm) {
-               /* snd_printk(KERN_DEBUG "epcm free: %p\n", epcm); */
+               /* dev_dbg(emu->card->dev, "epcm free: %p\n", epcm); */
                kfree(epcm);
        }
 }
@@ -183,14 +183,14 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
        int err;
 
        epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
-        /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */
+       /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */
 
        if (epcm == NULL)
                return -ENOMEM;
        epcm->emu = emu;
        epcm->substream = substream;
        /*
-       snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n",
+       dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n",
                   substream->pcm->device, channel_id);
        */
        runtime->private_data = epcm;
@@ -203,10 +203,10 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
 
         channel->use=1;
 #if 0 /* debug */
-       snd_printk(KERN_DEBUG
+       dev_dbg(emu->card->dev,
                   "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
                   channel_id, channel, channel->use);
-       printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
+       dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
               channel_id, chip, channel);
 #endif /* debug */
        /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
@@ -231,14 +231,14 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream
        int err;
 
        epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
-       /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */
+       /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */
 
        if (epcm == NULL)
                return -ENOMEM;
        epcm->emu = emu;
        epcm->substream = substream;
        /*
-       snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n",
+       dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n",
                   substream->pcm->device, channel_id);
        */
        runtime->private_data = epcm;
@@ -251,10 +251,10 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream
 
        channel->use=1;
 #if 0 /* debug */
-       snd_printk(KERN_DEBUG
+       dev_dbg(emu->card->dev,
                   "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
                   channel_id, channel, channel->use);
-       printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
+       dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
               channel_id, chip, channel);
 #endif /* debug */
        /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
@@ -349,15 +349,18 @@ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream)
        u32 tmp;
        
 #if 0 /* debug */
-       snd_printk(KERN_DEBUG "prepare:channel_number=%d, rate=%d, "
+       dev_dbg(emu->card->dev,
+               "prepare:channel_number=%d, rate=%d, "
                   "format=0x%x, channels=%d, buffer_size=%ld, "
                   "period_size=%ld, periods=%u, frames_to_bytes=%d\n",
                   channel, runtime->rate, runtime->format, runtime->channels,
                   runtime->buffer_size, runtime->period_size,
                   runtime->periods, frames_to_bytes(runtime, 1));
-       snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
+       dev_dbg(emu->card->dev,
+               "dma_addr=%x, dma_area=%p, table_base=%p\n",
                   runtime->dma_addr, runtime->dma_area, table_base);
-       snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
+       dev_dbg(emu->card->dev,
+               "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
                   emu->p16v_buffer.addr, emu->p16v_buffer.area,
                   emu->p16v_buffer.bytes);
 #endif /* debug */
@@ -405,7 +408,7 @@ static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream)
        u32 tmp;
 
        /*
-       printk(KERN_DEBUG "prepare capture:channel_number=%d, rate=%d, "
+       dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, "
               "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, "
               "frames_to_bytes=%d\n",
               channel, runtime->rate, runtime->format, runtime->channels,
@@ -491,13 +494,13 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
                runtime = s->runtime;
                epcm = runtime->private_data;
                channel = substream->pcm->device-emu->p16v_device_offset;
-               /* snd_printk(KERN_DEBUG "p16v channel=%d\n", channel); */
+               /* dev_dbg(emu->card->dev, "p16v channel=%d\n", channel); */
                epcm->running = running;
                basic |= (0x1<<channel);
                inte |= (INTE2_PLAYBACK_CH_0_LOOP<<channel);
                 snd_pcm_trigger_done(s, substream);
         }
-       /* snd_printk(KERN_DEBUG "basic=0x%x, inte=0x%x\n", basic, inte); */
+       /* dev_dbg(emu->card->dev, "basic=0x%x, inte=0x%x\n", basic, inte); */
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -588,10 +591,10 @@ snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream)
        ptr=ptr2;
        if (ptr >= runtime->buffer_size) {
                ptr -= runtime->buffer_size;
-               printk(KERN_WARNING "buffer capture limited!\n");
+               dev_warn(emu->card->dev, "buffer capture limited!\n");
        }
        /*
-       printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
+       dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
               "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
               ptr1, ptr2, ptr, (int)runtime->buffer_size,
               (int)runtime->period_size, (int)runtime->frame_bits,
@@ -630,7 +633,7 @@ int snd_p16v_free(struct snd_emu10k1 *chip)
        if (chip->p16v_buffer.area) {
                snd_dma_free_pages(&chip->p16v_buffer);
                /*
-               snd_printk(KERN_DEBUG "period lables free: %p\n",
+               dev_dbg(chip->card->dev, "period lables free: %p\n",
                           &chip->p16v_buffer);
                */
        }
@@ -644,7 +647,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)
        int err;
         int capture=1;
   
-       /* snd_printk(KERN_DEBUG "snd_p16v_pcm called. device=%d\n", device); */
+       /* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */
        emu->p16v_device_offset = device;
        if (rpcm)
                *rpcm = NULL;
@@ -672,7 +675,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)
                                                         ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 
                        return err;
                /*
-               snd_printk(KERN_DEBUG
+               dev_dbg(emu->card->dev,
                           "preallocate playback substream: err=%d\n", err);
                */
        }
@@ -686,7 +689,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)
                                                   65536 - 64, 65536 - 64)) < 0)
                        return err;
                /*
-               snd_printk(KERN_DEBUG
+               dev_dbg(emu->card->dev,
                           "preallocate capture substream: err=%d\n", err);
                */
        }
index 101e7cb79cb260dd8f669cda3f952e5ad64a18b2..f16fd5cfb7cd86cac65d882b0a3c43304ac476a3 100644 (file)
@@ -55,7 +55,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
        first_voice = last_voice = 0;
        for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) {
                /*
-               printk(KERN_DEBUG "i %d j %d next free %d!\n",
+               dev_dbg(emu->card->dev, "i %d j %d next free %d!\n",
                       i, j, emu->next_free_voice);
                */
                i %= NUM_G;
@@ -75,7 +75,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
                        }
                }
                if (!skip) {
-                       /* printk(KERN_DEBUG "allocated voice %d\n", i); */
+                       /* dev_dbg(emu->card->dev, "allocated voice %d\n", i); */
                        first_voice = i;
                        last_voice = (i + number) % NUM_G;
                        emu->next_free_voice = last_voice;
@@ -89,7 +89,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
        for (i = 0; i < number; i++) {
                voice = &emu->voices[(first_voice + i) % NUM_G];
                /*
-               printk(kERN_DEBUG "voice alloc - %i, %i of %i\n",
+               dev_dbg(emu->card->dev, "voice alloc - %i, %i of %i\n",
                       voice->number, idx-first_voice+1, number);
                */
                voice->use = 1;
index 61262f396004b50a2aca06af03bfaa9d37686b29..29cd339ffc374582f9e63c0eece91bc8b9a5ce76 100644 (file)
@@ -525,7 +525,7 @@ static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq)
                        return r;
                cond_resched();
        }
-       snd_printk(KERN_ERR "wait src ready timeout 0x%lx [0x%x]\n",
+       dev_err(ensoniq->card->dev, "wait src ready timeout 0x%lx [0x%x]\n",
                   ES_REG(ensoniq, 1371_SMPRATE), r);
        return 0;
 }
@@ -587,7 +587,7 @@ static void snd_es1370_codec_write(struct snd_ak4531 *ak4531,
        unsigned long end_time = jiffies + HZ / 10;
 
 #if 0
-       printk(KERN_DEBUG
+       dev_dbg(ensoniq->card->dev,
               "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n",
               reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
 #endif
@@ -598,7 +598,7 @@ static void snd_es1370_codec_write(struct snd_ak4531 *ak4531,
                }
                schedule_timeout_uninterruptible(1);
        } while (time_after(end_time, jiffies));
-       snd_printk(KERN_ERR "codec write timeout, status = 0x%x\n",
+       dev_err(ensoniq->card->dev, "codec write timeout, status = 0x%x\n",
                   inl(ES_REG(ensoniq, STATUS)));
 }
 
@@ -649,7 +649,7 @@ static void snd_es1371_codec_write(struct snd_ac97 *ac97,
                }
        }
        mutex_unlock(&ensoniq->src_mutex);
-       snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n",
+       dev_err(ensoniq->card->dev, "codec write timeout at 0x%lx [0x%x]\n",
                   ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
 }
 
@@ -706,8 +706,8 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
                        }
                        mutex_unlock(&ensoniq->src_mutex);
                        if (++fail > 10) {
-                               snd_printk(KERN_ERR "codec read timeout (final) "
-                                          "at 0x%lx, reg = 0x%x [0x%x]\n",
+                               dev_err(ensoniq->card->dev,
+                                       "codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n",
                                           ES_REG(ensoniq, 1371_CODEC), reg,
                                           inl(ES_REG(ensoniq, 1371_CODEC)));
                                return 0;
@@ -716,7 +716,7 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
                }
        }
        mutex_unlock(&ensoniq->src_mutex);
-       snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n",
+       dev_err(ensoniq->card->dev, "codec read timeout at 0x%lx [0x%x]\n",
                   ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
        return 0;
 }
@@ -1796,7 +1796,7 @@ static int snd_ensoniq_1370_mixer(struct ensoniq *ensoniq)
 #ifdef SUPPORT_JOYSTICK
 
 #ifdef CHIP1371
-static int snd_ensoniq_get_joystick_port(int dev)
+static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev)
 {
        switch (joystick_port[dev]) {
        case 0: /* disabled */
@@ -1808,12 +1808,13 @@ static int snd_ensoniq_get_joystick_port(int dev)
                return joystick_port[dev];
 
        default:
-               printk(KERN_ERR "ens1371: invalid joystick port %#x", joystick_port[dev]);
+               dev_err(ensoniq->card->dev,
+                       "invalid joystick port %#x", joystick_port[dev]);
                return 0;
        }
 }
 #else
-static inline int snd_ensoniq_get_joystick_port(int dev)
+static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev)
 {
        return joystick[dev] ? 0x200 : 0;
 }
@@ -1824,7 +1825,7 @@ static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)
        struct gameport *gp;
        int io_port;
 
-       io_port = snd_ensoniq_get_joystick_port(dev);
+       io_port = snd_ensoniq_get_joystick_port(ensoniq, dev);
 
        switch (io_port) {
        case 0:
@@ -1835,14 +1836,16 @@ static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)
                        if (request_region(io_port, 8, "ens137x: gameport"))
                                break;
                if (io_port > 0x218) {
-                       printk(KERN_WARNING "ens137x: no gameport ports available\n");
+                       dev_warn(ensoniq->card->dev,
+                                "no gameport ports available\n");
                        return -EBUSY;
                }
                break;
 
        default:
                if (!request_region(io_port, 8, "ens137x: gameport")) {
-                       printk(KERN_WARNING "ens137x: gameport io port %#x in use\n",
+                       dev_warn(ensoniq->card->dev,
+                                "gameport io port %#x in use\n",
                               io_port);
                        return -EBUSY;
                }
@@ -1851,7 +1854,8 @@ static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)
 
        ensoniq->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "ens137x: cannot allocate memory for gameport\n");
+               dev_err(ensoniq->card->dev,
+                       "cannot allocate memory for gameport\n");
                release_region(io_port, 8);
                return -ENOMEM;
        }
@@ -2082,8 +2086,7 @@ static int snd_ensoniq_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR DRIVER_NAME ": pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2137,7 +2140,7 @@ static int snd_ensoniq_create(struct snd_card *card,
        ensoniq->port = pci_resource_start(pci, 0);
        if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, ensoniq)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_ensoniq_free(ensoniq);
                return -EBUSY;
        }
@@ -2145,7 +2148,7 @@ static int snd_ensoniq_create(struct snd_card *card,
 #ifdef CHIP1370
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
                                16, &ensoniq->dma_bug) < 0) {
-               snd_printk(KERN_ERR "unable to allocate space for phantom area - dma_bug\n");
+               dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n");
                snd_ensoniq_free(ensoniq);
                return -EBUSY;
        }
@@ -2180,8 +2183,6 @@ static int snd_ensoniq_create(struct snd_card *card,
 
        snd_ensoniq_proc_init(ensoniq);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rensoniq = ensoniq;
        return 0;
 }
@@ -2437,7 +2438,8 @@ static int snd_audiopci_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
index 9213fb38921c6b7687bfaaa262c6c3b3de0a09d3..34d95bf916b5f2c51e9658ab6b363f611f05b2af 100644 (file)
@@ -254,7 +254,6 @@ MODULE_DEVICE_TABLE(pci, snd_es1938_ids);
 #define WRITE_LOOP_TIMEOUT     0x10000
 #define GET_LOOP_TIMEOUT       0x01000
 
-#undef REG_DEBUG
 /* -----------------------------------------------------------------
  * Write to a mixer register
  * -----------------------------------------------------------------*/
@@ -265,9 +264,7 @@ static void snd_es1938_mixer_write(struct es1938 *chip, unsigned char reg, unsig
        outb(reg, SLSB_REG(chip, MIXERADDR));
        outb(val, SLSB_REG(chip, MIXERDATA));
        spin_unlock_irqrestore(&chip->mixer_lock, flags);
-#ifdef REG_DEBUG
-       snd_printk(KERN_DEBUG "Mixer reg %02x set to %02x\n", reg, val);
-#endif
+       dev_dbg(chip->card->dev, "Mixer reg %02x set to %02x\n", reg, val);
 }
 
 /* -----------------------------------------------------------------
@@ -281,9 +278,7 @@ static int snd_es1938_mixer_read(struct es1938 *chip, unsigned char reg)
        outb(reg, SLSB_REG(chip, MIXERADDR));
        data = inb(SLSB_REG(chip, MIXERDATA));
        spin_unlock_irqrestore(&chip->mixer_lock, flags);
-#ifdef REG_DEBUG
-       snd_printk(KERN_DEBUG "Mixer reg %02x now is %02x\n", reg, data);
-#endif
+       dev_dbg(chip->card->dev, "Mixer reg %02x now is %02x\n", reg, data);
        return data;
 }
 
@@ -302,10 +297,9 @@ static int snd_es1938_mixer_bits(struct es1938 *chip, unsigned char reg,
        if (val != oval) {
                new = (old & ~mask) | (val & mask);
                outb(new, SLSB_REG(chip, MIXERDATA));
-#ifdef REG_DEBUG
-               snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x\n",
+               dev_dbg(chip->card->dev,
+                       "Mixer reg %02x was %02x, set to %02x\n",
                           reg, old, new);
-#endif
        }
        spin_unlock_irqrestore(&chip->mixer_lock, flags);
        return oval;
@@ -324,7 +318,8 @@ static void snd_es1938_write_cmd(struct es1938 *chip, unsigned char cmd)
                        return;
                }
        }
-       printk(KERN_ERR "snd_es1938_write_cmd timeout (0x02%x/0x02%x)\n", cmd, v);
+       dev_err(chip->card->dev,
+               "snd_es1938_write_cmd timeout (0x02%x/0x02%x)\n", cmd, v);
 }
 
 /* -----------------------------------------------------------------
@@ -337,7 +332,7 @@ static int snd_es1938_get_byte(struct es1938 *chip)
        for (i = GET_LOOP_TIMEOUT; i; i--)
                if ((v = inb(SLSB_REG(chip, STATUS))) & 0x80)
                        return inb(SLSB_REG(chip, READDATA));
-       snd_printk(KERN_ERR "get_byte timeout: status 0x02%x\n", v);
+       dev_err(chip->card->dev, "get_byte timeout: status 0x02%x\n", v);
        return -ENODEV;
 }
 
@@ -351,9 +346,7 @@ static void snd_es1938_write(struct es1938 *chip, unsigned char reg, unsigned ch
        snd_es1938_write_cmd(chip, reg);
        snd_es1938_write_cmd(chip, val);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
-#ifdef REG_DEBUG
-       snd_printk(KERN_DEBUG "Reg %02x set to %02x\n", reg, val);
-#endif
+       dev_dbg(chip->card->dev, "Reg %02x set to %02x\n", reg, val);
 }
 
 /* -----------------------------------------------------------------
@@ -368,9 +361,7 @@ static unsigned char snd_es1938_read(struct es1938 *chip, unsigned char reg)
        snd_es1938_write_cmd(chip, reg);
        val = snd_es1938_get_byte(chip);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
-#ifdef REG_DEBUG
-       snd_printk(KERN_DEBUG "Reg %02x now is %02x\n", reg, val);
-#endif
+       dev_dbg(chip->card->dev, "Reg %02x now is %02x\n", reg, val);
        return val;
 }
 
@@ -391,10 +382,8 @@ static int snd_es1938_bits(struct es1938 *chip, unsigned char reg, unsigned char
                snd_es1938_write_cmd(chip, reg);
                new = (old & ~mask) | (val & mask);
                snd_es1938_write_cmd(chip, new);
-#ifdef REG_DEBUG
-               snd_printk(KERN_DEBUG "Reg %02x was %02x, set to %02x\n",
+               dev_dbg(chip->card->dev, "Reg %02x was %02x, set to %02x\n",
                           reg, old, new);
-#endif
        }
        spin_unlock_irqrestore(&chip->reg_lock, flags);
        return oval;
@@ -416,7 +405,7 @@ static void snd_es1938_reset(struct es1938 *chip)
                                goto __next;
                }
        }
-       snd_printk(KERN_ERR "ESS Solo-1 reset failed\n");
+       dev_err(chip->card->dev, "ESS Solo-1 reset failed\n");
 
      __next:
        snd_es1938_write_cmd(chip, ESS_CMD_ENABLEEXT);
@@ -1504,16 +1493,15 @@ static int es1938_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "es1938: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
 
        if (request_irq(pci->irq, snd_es1938_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR "es1938: unable to grab IRQ %d, "
-                      "disabling device\n", pci->irq);
+               dev_err(dev, "unable to grab IRQ %d, disabling device\n",
+                       pci->irq);
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -1545,7 +1533,8 @@ static int snd_es1938_create_gameport(struct es1938 *chip)
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "es1938: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                return -ENOMEM;
        }
 
@@ -1612,7 +1601,8 @@ static int snd_es1938_create(struct snd_card *card,
         /* check, if we can restrict PCI DMA transfers to 24 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 24bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                 return -ENXIO;
         }
@@ -1639,15 +1629,14 @@ static int snd_es1938_create(struct snd_card *card,
        chip->game_port = pci_resource_start(pci, 4);
        if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_es1938_free(chip);
                return -EBUSY;
        }
        chip->irq = pci->irq;
-#ifdef ES1938_DDEBUG
-       snd_printk(KERN_DEBUG "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n",
+       dev_dbg(card->dev,
+               "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n",
                   chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port);
-#endif
 
        chip->ddma_port = chip->vc_port + 0x00;         /* fix from Thomas Sailer */
 
@@ -1658,8 +1647,6 @@ static int snd_es1938_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        return 0;
 }
@@ -1675,21 +1662,22 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
 
        status = inb(SLIO_REG(chip, IRQCONTROL));
 #if 0
-       printk(KERN_DEBUG "Es1938debug - interrupt status: =0x%x\n", status);
+       dev_dbg(chip->card->dev,
+               "Es1938debug - interrupt status: =0x%x\n", status);
 #endif
        
        /* AUDIO 1 */
        if (status & 0x10) {
 #if 0
-                printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 1 interrupt\n");
-               printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n",
                       inw(SLDM_REG(chip, DMACOUNT)));
-               printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n",
                       inl(SLDM_REG(chip, DMAADDR)));
-               printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n",
                       inl(SLDM_REG(chip, DMASTATUS)));
 #endif
@@ -1705,12 +1693,12 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
        /* AUDIO 2 */
        if (status & 0x20) {
 #if 0
-                printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 2 interrupt\n");
-               printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n",
                       inw(SLIO_REG(chip, AUDIO2DMACOUNT)));
-               printk(KERN_DEBUG
+               dev_dbg(chip->card->dev,
                       "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n",
                       inl(SLIO_REG(chip, AUDIO2DMAADDR)));
 
@@ -1808,7 +1796,8 @@ static int snd_es1938_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        for (idx = 0; idx < 5; idx++) {
@@ -1843,7 +1832,7 @@ static int snd_es1938_probe(struct pci_dev *pci,
                            SLSB_REG(chip, FMLOWADDR),
                            SLSB_REG(chip, FMHIGHADDR),
                            OPL3_HW_OPL3, 1, &opl3) < 0) {
-               printk(KERN_ERR "es1938: OPL3 not detected at 0x%lx\n",
+               dev_err(card->dev, "OPL3 not detected at 0x%lx\n",
                           SLSB_REG(chip, FMLOWADDR));
        } else {
                if ((err = snd_opl3_timer_new(opl3, 0, 1)) < 0) {
@@ -1859,7 +1848,7 @@ static int snd_es1938_probe(struct pci_dev *pci,
                                chip->mpu_port,
                                MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
                                -1, &chip->rmidi) < 0) {
-               printk(KERN_ERR "es1938: unable to initialize MPU-401\n");
+               dev_err(card->dev, "unable to initialize MPU-401\n");
        } else {
                // this line is vital for MIDI interrupt handling on ess-solo1
                // andreas@flying-snail.de
index 772cc36f951de1929d9ef69962688cd51f502537..5bb1cf603301e28ef937f7b4416a93dd5008e916 100644 (file)
@@ -632,7 +632,7 @@ static int snd_es1968_ac97_wait(struct es1968 *chip)
                        return 0;
                cond_resched();
        }
-       snd_printd("es1968: ac97 timeout\n");
+       dev_dbg(chip->card->dev, "ac97 timeout\n");
        return 1; /* timeout */
 }
 
@@ -644,7 +644,7 @@ static int snd_es1968_ac97_wait_poll(struct es1968 *chip)
                if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1))
                        return 0;
        }
-       snd_printd("es1968: ac97 timeout\n");
+       dev_dbg(chip->card->dev, "ac97 timeout\n");
        return 1; /* timeout */
 }
 
@@ -687,7 +687,7 @@ static void apu_index_set(struct es1968 *chip, u16 index)
        for (i = 0; i < 1000; i++)
                if (__maestro_read(chip, IDR1_CRAM_POINTER) == index)
                        return;
-       snd_printd("es1968: APU register select failed. (Timeout)\n");
+       dev_dbg(chip->card->dev, "APU register select failed. (Timeout)\n");
 }
 
 /* no spinlock */
@@ -699,7 +699,7 @@ static void apu_data_set(struct es1968 *chip, u16 data)
                        return;
                __maestro_write(chip, IDR0_DATA_PORT, data);
        }
-       snd_printd("es1968: APU register set probably failed (Timeout)!\n");
+       dev_dbg(chip->card->dev, "APU register set probably failed (Timeout)!\n");
 }
 
 /* no spinlock */
@@ -1442,13 +1442,14 @@ snd_es1968_init_dmabuf(struct es1968 *chip)
                                           snd_dma_pci_data(chip->pci),
                                           chip->total_bufsize, &chip->dma);
        if (err < 0 || ! chip->dma.area) {
-               snd_printk(KERN_ERR "es1968: can't allocate dma pages for size %d\n",
+               dev_err(chip->card->dev,
+                       "can't allocate dma pages for size %d\n",
                           chip->total_bufsize);
                return -ENOMEM;
        }
        if ((chip->dma.addr + chip->dma.bytes - 1) & ~((1 << 28) - 1)) {
                snd_dma_free_pages(&chip->dma);
-               snd_printk(KERN_ERR "es1968: DMA buffer beyond 256MB.\n");
+               dev_err(chip->card->dev, "DMA buffer beyond 256MB.\n");
                return -ENOMEM;
        }
 
@@ -1489,7 +1490,8 @@ static int snd_es1968_hw_params(struct snd_pcm_substream *substream,
        }
        chan->memory = snd_es1968_new_memory(chip, size);
        if (chan->memory == NULL) {
-               // snd_printd("cannot allocate dma buffer: size = %d\n", size);
+               dev_dbg(chip->card->dev,
+                       "cannot allocate dma buffer: size = %d\n", size);
                return -ENOMEM;
        }
        snd_pcm_set_runtime_buffer(substream, &chan->memory->buf);
@@ -1715,11 +1717,13 @@ static void es1968_measure_clock(struct es1968 *chip)
 
        /* search 2 APUs (although one apu is enough) */
        if ((apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY)) < 0) {
-               snd_printk(KERN_ERR "Hmm, cannot find empty APU pair!?\n");
+               dev_err(chip->card->dev, "Hmm, cannot find empty APU pair!?\n");
                return;
        }
        if ((memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE)) == NULL) {
-               snd_printk(KERN_ERR "cannot allocate dma buffer - using default clock %d\n", chip->clock);
+               dev_warn(chip->card->dev,
+                        "cannot allocate dma buffer - using default clock %d\n",
+                        chip->clock);
                snd_es1968_free_apu_pair(chip, apu);
                return;
        }
@@ -1780,7 +1784,7 @@ static void es1968_measure_clock(struct es1968 *chip)
        else
                t += stop_time.tv_usec - start_time.tv_usec;
        if (t == 0) {
-               snd_printk(KERN_ERR "?? calculation error..\n");
+               dev_err(chip->card->dev, "?? calculation error..\n");
        } else {
                offset *= 1000;
                offset = (offset / t) * 1000 + ((offset % t) * 1000) / t;
@@ -1788,7 +1792,7 @@ static void es1968_measure_clock(struct es1968 *chip)
                        if (offset >= 40000 && offset <= 50000)
                                chip->clock = (chip->clock * offset) / 48000;
                }
-               printk(KERN_INFO "es1968: clocking to %d\n", chip->clock);
+               dev_info(chip->card->dev, "clocking to %d\n", chip->clock);
        }
        snd_es1968_free_memory(chip, memory);
        snd_es1968_free_apu_pair(chip, apu);
@@ -2108,7 +2112,7 @@ static void snd_es1968_ac97_reset(struct es1968 *chip)
        outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c);
 
 #if 0                          /* the loop here needs to be much better if we want it.. */
-       snd_printk(KERN_INFO "trying software reset\n");
+       dev_info(chip->card->dev, "trying software reset\n");
        /* try and do a software reset */
        outb(0x80 | 0x7c, ioaddr + 0x30);
        for (w = 0;; w++) {
@@ -2416,8 +2420,7 @@ static int es1968_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "es1968: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2479,7 +2482,8 @@ static int snd_es1968_create_gameport(struct es1968 *chip, int dev)
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "es1968: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                release_and_free_resource(r);
                return -ENOMEM;
        }
@@ -2706,7 +2710,8 @@ static int snd_es1968_create(struct snd_card *card,
        /* check, if we can restrict PCI DMA transfers to 28 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 28bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -2740,7 +2745,7 @@ static int snd_es1968_create(struct snd_card *card,
        chip->io_port = pci_resource_start(pci, 0);
        if (request_irq(pci->irq, snd_es1968_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_es1968_free(chip);
                return -EBUSY;
        }
@@ -2770,7 +2775,7 @@ static int snd_es1968_create(struct snd_card *card,
                }
                if (do_pm > 1) {
                        /* not matched; disabling pm */
-                       printk(KERN_INFO "es1968: not attempting power management.\n");
+                       dev_info(card->dev, "not attempting power management.\n");
                        do_pm = 0;
                }
        }
@@ -2783,8 +2788,6 @@ static int snd_es1968_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
 #ifdef CONFIG_SND_ES1968_RADIO
        /* don't play with GPIOs on laptops */
        if (chip->pci->subsystem_vendor != 0x125d)
@@ -2802,7 +2805,7 @@ static int snd_es1968_create(struct snd_card *card,
        for (i = 0; i < ARRAY_SIZE(snd_es1968_tea575x_gpios); i++) {
                chip->tea575x_tuner = i;
                if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) {
-                       snd_printk(KERN_INFO "es1968: detected TEA575x radio type %s\n",
+                       dev_info(card->dev, "detected TEA575x radio type %s\n",
                                   get_tea575x_gpio(chip)->name);
                        strlcpy(chip->tea.card, get_tea575x_gpio(chip)->name,
                                sizeof(chip->tea.card));
@@ -2836,7 +2839,8 @@ static int snd_es1968_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
                 
@@ -2900,7 +2904,7 @@ static int snd_es1968_probe(struct pci_dev *pci,
                                               MPU401_INFO_INTEGRATED |
                                               MPU401_INFO_IRQ_HOOK,
                                               -1, &chip->rmidi)) < 0) {
-                       printk(KERN_WARNING "es1968: skipping MPU-401 MIDI support..\n");
+                       dev_warn(card->dev, "skipping MPU-401 MIDI support..\n");
                }
        }
 
@@ -2909,8 +2913,8 @@ static int snd_es1968_probe(struct pci_dev *pci,
 #ifdef CONFIG_SND_ES1968_INPUT
        err = snd_es1968_input_register(chip);
        if (err)
-               snd_printk(KERN_WARNING "Input device registration "
-                       "failed with error %i", err);
+               dev_warn(card->dev,
+                        "Input device registration failed with error %i", err);
 #endif
 
        snd_es1968_start_irq(chip);
index 45bc8a95b7c44f2f35fdd0013e6695d328bdc69f..db18ccabadd6abb3914b9b1d70c314232fda92ac 100644 (file)
@@ -254,7 +254,7 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97,
                        goto ok1;
                udelay(10);
        }
-       snd_printk(KERN_ERR "AC'97 interface is busy (1)\n");
+       dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
        return;
 
  ok1:
@@ -269,7 +269,7 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97,
                        return;
                udelay(10);
        }
-       snd_printk(KERN_ERR "AC'97 interface #%d is busy (2)\n", ac97->num);
+       dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n", ac97->num);
 }
 
 static 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
                        goto ok1;
                udelay(10);
        }
-       snd_printk(KERN_ERR "AC'97 interface is busy (1)\n");
+       dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
        return 0;
 
  ok1:
@@ -297,7 +297,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short
                        goto ok2;
                udelay(10);
        }
-       snd_printk(KERN_ERR "AC'97 interface #%d is busy (2)\n", ac97->num);
+       dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n", ac97->num);
        return 0;
 
  ok2:
@@ -306,7 +306,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short
                        goto ok3;
                udelay(10);
        }
-       snd_printk(KERN_ERR "AC'97 interface #%d is not valid (2)\n", ac97->num);
+       dev_err(chip->card->dev, "AC'97 interface #%d is not valid (2)\n", ac97->num);
        return 0;
 
  ok3:
@@ -1100,8 +1100,8 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
 
        if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0)
                if (!resume) {
-                       snd_printk(KERN_INFO "Primary AC'97 codec not found, "
-                                           "assume SF64-PCR (tuner-only)\n");
+                       dev_info(chip->card->dev,
+                                "Primary AC'97 codec not found, assume SF64-PCR (tuner-only)\n");
                        chip->tea575x_tuner = 3 | TUNER_ONLY;
                        goto __ac97_ok;
                }
@@ -1225,7 +1225,7 @@ static int snd_fm801_create(struct snd_card *card,
        if ((tea575x_tuner & TUNER_ONLY) == 0) {
                if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED,
                                KBUILD_MODNAME, chip)) {
-                       snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->irq);
+                       dev_err(card->dev, "unable to grab IRQ %d\n", chip->irq);
                        snd_fm801_free(chip);
                        return -EBUSY;
                }
@@ -1251,8 +1251,6 @@ static int snd_fm801_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
 #ifdef CONFIG_SND_FM801_TEA575X_BOOL
        err = v4l2_device_register(&pci->dev, &chip->v4l2_dev);
        if (err < 0) {
@@ -1267,7 +1265,7 @@ static int snd_fm801_create(struct snd_card *card,
        if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
            (tea575x_tuner & TUNER_TYPE_MASK) < 4) {
                if (snd_tea575x_init(&chip->tea, THIS_MODULE)) {
-                       snd_printk(KERN_ERR "TEA575x radio not found\n");
+                       dev_err(card->dev, "TEA575x radio not found\n");
                        snd_fm801_free(chip);
                        return -ENODEV;
                }
@@ -1276,13 +1274,14 @@ static int snd_fm801_create(struct snd_card *card,
                for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
                        chip->tea575x_tuner = tea575x_tuner;
                        if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) {
-                               snd_printk(KERN_INFO "detected TEA575x radio type %s\n",
+                               dev_info(card->dev,
+                                        "detected TEA575x radio type %s\n",
                                           get_tea575x_gpio(chip)->name);
                                break;
                        }
                }
                if (tea575x_tuner == 4) {
-                       snd_printk(KERN_ERR "TEA575x radio not found\n");
+                       dev_err(card->dev, "TEA575x radio not found\n");
                        chip->tea575x_tuner = TUNER_DISABLED;
                }
        }
@@ -1312,7 +1311,8 @@ static int snd_card_fm801_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        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)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "fm801: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index 0e53634dbbd85825249f68a7e4460b6a543d3361..ac17c3fc93883a98eade37bf58a13e5bff56abb3 100644 (file)
@@ -1,8 +1,15 @@
-menuconfig SND_HDA_INTEL
-       tristate "Intel HD Audio"
+menu "HD-Audio"
+
+config SND_HDA
+       tristate
        select SND_PCM
        select SND_VMASTER
        select SND_KCTL_JACK
+
+config SND_HDA_INTEL
+       tristate "HD Audio PCI"
+       depends on SND_PCI
+       select SND_HDA
        help
          Say Y here to include support for Intel "High Definition
          Audio" (Azalia) and its compatible devices.
@@ -13,7 +20,7 @@ menuconfig SND_HDA_INTEL
          To compile this driver as a module, choose M here: the module
          will be called snd-hda-intel.
 
-if SND_HDA_INTEL
+if SND_HDA
 
 config SND_HDA_DSP_LOADER
        bool
@@ -41,7 +48,6 @@ config SND_HDA_HWDEP
 
 config SND_HDA_RECONFIG
        bool "Allow dynamic codec reconfiguration"
-       depends on SND_HDA_HWDEP
        help
          Say Y here to enable the HD-audio codec re-configuration feature.
          This adds the sysfs interfaces to allow user to clear the whole
@@ -50,7 +56,7 @@ config SND_HDA_RECONFIG
 
 config SND_HDA_INPUT_BEEP
        bool "Support digital beep via input layer"
-       depends on INPUT=y || INPUT=SND_HDA_INTEL
+       depends on INPUT=y || INPUT=SND_HDA
        help
          Say Y here to build a digital beep interface for HD-audio
          driver. This interface is used to generate digital beeps.
@@ -76,7 +82,6 @@ config SND_HDA_INPUT_JACK
 config SND_HDA_PATCH_LOADER
        bool "Support initialization patch loading for HD-audio"
        select FW_LOADER
-       select SND_HDA_HWDEP
        select SND_HDA_RECONFIG
        help
          Say Y here to allow the HD-audio driver to load a pseudo
@@ -84,8 +89,6 @@ config SND_HDA_PATCH_LOADER
          start up.  The "patch" file can be specified via patch module
          option, such as patch=hda-init.
 
-         This option turns on hwdep and reconfig features automatically.
-
 config SND_HDA_CODEC_REALTEK
        tristate "Build Realtek HD-audio codec support"
        select SND_HDA_GENERIC
@@ -94,7 +97,7 @@ config SND_HDA_CODEC_REALTEK
          snd-hda-intel driver, such as ALC880.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_REALTEK=m
+       depends on SND_HDA=y && SND_HDA_CODEC_REALTEK=m
 
 config SND_HDA_CODEC_ANALOG
        tristate "Build Analog Device HD-audio codec support"
@@ -104,7 +107,7 @@ config SND_HDA_CODEC_ANALOG
          snd-hda-intel driver, such as AD1986A.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_ANALOG=m
+       depends on SND_HDA=y && SND_HDA_CODEC_ANALOG=m
 
 config SND_HDA_CODEC_SIGMATEL
        tristate "Build IDT/Sigmatel HD-audio codec support"
@@ -114,7 +117,7 @@ config SND_HDA_CODEC_SIGMATEL
          snd-hda-intel driver, such as STAC9200.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_SIGMATEL=m
+       depends on SND_HDA=y && SND_HDA_CODEC_SIGMATEL=m
 
 config SND_HDA_CODEC_VIA
        tristate "Build VIA HD-audio codec support"
@@ -124,7 +127,7 @@ config SND_HDA_CODEC_VIA
          snd-hda-intel driver, such as VT1708.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_VIA=m
+       depends on SND_HDA=y && SND_HDA_CODEC_VIA=m
 
 config SND_HDA_CODEC_HDMI
        tristate "Build HDMI/DisplayPort HD-audio codec support"
@@ -134,7 +137,7 @@ config SND_HDA_CODEC_HDMI
          Intel and Nvidia HDMI/DisplayPort codecs.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_HDMI=m
+       depends on SND_HDA=y && SND_HDA_CODEC_HDMI=m
 
 config SND_HDA_I915
        bool
@@ -149,7 +152,7 @@ config SND_HDA_CODEC_CIRRUS
          snd-hda-intel driver, such as CS4206.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CIRRUS=m
+       depends on SND_HDA=y && SND_HDA_CODEC_CIRRUS=m
 
 config SND_HDA_CODEC_CONEXANT
        tristate "Build Conexant HD-audio codec support"
@@ -159,7 +162,7 @@ config SND_HDA_CODEC_CONEXANT
          snd-hda-intel driver, such as CX20549.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CONEXANT=m
+       depends on SND_HDA=y && SND_HDA_CODEC_CONEXANT=m
 
 config SND_HDA_CODEC_CA0110
        tristate "Build Creative CA0110-IBG codec support"
@@ -169,7 +172,7 @@ config SND_HDA_CODEC_CA0110
          snd-hda-intel driver, found on some Creative X-Fi cards.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CA0110=m
+       depends on SND_HDA=y && SND_HDA_CODEC_CA0110=m
 
 config SND_HDA_CODEC_CA0132
        tristate "Build Creative CA0132 codec support"
@@ -178,7 +181,7 @@ config SND_HDA_CODEC_CA0132
          snd-hda-intel driver.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CA0132=m
+       depends on SND_HDA=y && SND_HDA_CODEC_CA0132=m
 
 config SND_HDA_CODEC_CA0132_DSP
        bool "Support new DSP code for CA0132 codec"
@@ -200,7 +203,7 @@ config SND_HDA_CODEC_CMEDIA
          snd-hda-intel driver, such as CMI9880.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CMEDIA=m
+       depends on SND_HDA=y && SND_HDA_CODEC_CMEDIA=m
 
 config SND_HDA_CODEC_SI3054
        tristate "Build Silicon Labs 3054 HD-modem codec support"
@@ -209,7 +212,7 @@ config SND_HDA_CODEC_SI3054
          (and compatibles) support in snd-hda-intel driver.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_CODEC_SI3054=m
+       depends on SND_HDA=y && SND_HDA_CODEC_SI3054=m
 
 config SND_HDA_GENERIC
        tristate "Enable generic HD-audio codec parser"
@@ -218,7 +221,7 @@ config SND_HDA_GENERIC
          in snd-hda-intel driver.
 
 comment "Set to Y if you want auto-loading the codec driver"
-       depends on SND_HDA_INTEL=y && SND_HDA_GENERIC=m
+       depends on SND_HDA=y && SND_HDA_GENERIC=m
 
 config SND_HDA_POWER_SAVE_DEFAULT
        int "Default time-out for HD-audio power-save mode"
@@ -229,3 +232,5 @@ config SND_HDA_POWER_SAVE_DEFAULT
          power-save mode.  0 means to disable the power-save mode.
 
 endif
+
+endmenu
index 1fcb118e480afc77617c01c6c681f0e24891a27d..d0d0c19ddfc2f83bc23ad6a40c0ef4d069d351c8 100644 (file)
@@ -1,15 +1,16 @@
 snd-hda-intel-objs := hda_intel.o
+snd-hda-controller-objs := hda_controller.o
 # for haswell power well
 snd-hda-intel-$(CONFIG_SND_HDA_I915) +=        hda_i915.o
 
-snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o
+snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o hda_sysfs.o
 snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
 
 # for trace-points
 CFLAGS_hda_codec.o := -I$(src)
-CFLAGS_hda_intel.o := -I$(src)
+CFLAGS_hda_controller.o := -I$(src)
 
 snd-hda-codec-generic-objs :=  hda_generic.o
 snd-hda-codec-realtek-objs :=  patch_realtek.o
@@ -25,7 +26,8 @@ snd-hda-codec-via-objs :=     patch_via.o
 snd-hda-codec-hdmi-objs :=     patch_hdmi.o hda_eld.o
 
 # common driver
-obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o
+obj-$(CONFIG_SND_HDA) := snd-hda-codec.o
+obj-$(CONFIG_SND_HDA) += snd-hda-controller.o
 
 # codec drivers
 obj-$(CONFIG_SND_HDA_GENERIC) += snd-hda-codec-generic.o
index 47ad31c6aa702c1e0783b75f7b5f9ac8ed5bc5dc..90d2fda6c8f99935b810425e64d98b6840e333a4 100644 (file)
@@ -227,10 +227,18 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
                                continue;
                        if (!assoc_line_out)
                                assoc_line_out = assoc;
-                       else if (assoc_line_out != assoc)
+                       else if (assoc_line_out != assoc) {
+                               codec_info(codec,
+                                          "ignore pin 0x%x with mismatching assoc# 0x%x vs 0x%x\n",
+                                          nid, assoc, assoc_line_out);
                                continue;
-                       if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
+                       }
+                       if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) {
+                               codec_info(codec,
+                                          "ignore pin 0x%x, too many assigned pins\n",
+                                          nid);
                                continue;
+                       }
                        line_out[cfg->line_outs].pin = nid;
                        line_out[cfg->line_outs].seq = seq;
                        cfg->line_outs++;
@@ -238,8 +246,12 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
                case AC_JACK_SPEAKER:
                        seq = get_defcfg_sequence(def_conf);
                        assoc = get_defcfg_association(def_conf);
-                       if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
+                       if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) {
+                               codec_info(codec,
+                                          "ignore pin 0x%x, too many assigned pins\n",
+                                          nid);
                                continue;
+                       }
                        speaker_out[cfg->speaker_outs].pin = nid;
                        speaker_out[cfg->speaker_outs].seq = (assoc << 4) | seq;
                        cfg->speaker_outs++;
@@ -247,8 +259,12 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
                case AC_JACK_HP_OUT:
                        seq = get_defcfg_sequence(def_conf);
                        assoc = get_defcfg_association(def_conf);
-                       if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins))
+                       if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) {
+                               codec_info(codec,
+                                          "ignore pin 0x%x, too many assigned pins\n",
+                                          nid);
                                continue;
+                       }
                        hp_out[cfg->hp_outs].pin = nid;
                        hp_out[cfg->hp_outs].seq = (assoc << 4) | seq;
                        cfg->hp_outs++;
@@ -267,8 +283,12 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
                        break;
                case AC_JACK_SPDIF_OUT:
                case AC_JACK_DIG_OTHER_OUT:
-                       if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins))
+                       if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) {
+                               codec_info(codec,
+                                          "ignore pin 0x%x, too many assigned pins\n",
+                                          nid);
                                continue;
+                       }
                        cfg->dig_out_pins[cfg->dig_outs] = nid;
                        cfg->dig_out_type[cfg->dig_outs] =
                                (loc == AC_JACK_LOC_HDMI) ?
@@ -313,9 +333,9 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
                }
 
                if (hsmic)
-                       snd_printdd("Told to look for a headset mic, but didn't find any.\n");
+                       codec_dbg(codec, "Told to look for a headset mic, but didn't find any.\n");
                if (hpmic)
-                       snd_printdd("Told to look for a headphone mic, but didn't find any.\n");
+                       codec_dbg(codec, "Told to look for a headphone mic, but didn't find any.\n");
        }
 
        /* FIX-UP:
@@ -384,33 +404,33 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
        /*
         * debug prints of the parsed results
         */
-       snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n",
+       codec_info(codec, "autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n",
                   cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1],
                   cfg->line_out_pins[2], cfg->line_out_pins[3],
                   cfg->line_out_pins[4],
                   cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" :
                   (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ?
                    "speaker" : "line"));
-       snd_printd("   speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
+       codec_info(codec, "   speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
                   cfg->speaker_outs, cfg->speaker_pins[0],
                   cfg->speaker_pins[1], cfg->speaker_pins[2],
                   cfg->speaker_pins[3], cfg->speaker_pins[4]);
-       snd_printd("   hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
+       codec_info(codec, "   hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
                   cfg->hp_outs, cfg->hp_pins[0],
                   cfg->hp_pins[1], cfg->hp_pins[2],
                   cfg->hp_pins[3], cfg->hp_pins[4]);
-       snd_printd("   mono: mono_out=0x%x\n", cfg->mono_out_pin);
+       codec_info(codec, "   mono: mono_out=0x%x\n", cfg->mono_out_pin);
        if (cfg->dig_outs)
-               snd_printd("   dig-out=0x%x/0x%x\n",
+               codec_info(codec, "   dig-out=0x%x/0x%x\n",
                           cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
-       snd_printd("   inputs:\n");
+       codec_info(codec, "   inputs:\n");
        for (i = 0; i < cfg->num_inputs; i++) {
-               snd_printd("     %s=0x%x\n",
+               codec_info(codec, "     %s=0x%x\n",
                            hda_get_autocfg_input_label(codec, cfg, i),
                            cfg->inputs[i].pin);
        }
        if (cfg->dig_in_pin)
-               snd_printd("   dig-in=0x%x\n", cfg->dig_in_pin);
+               codec_info(codec, "   dig-in=0x%x\n", cfg->dig_in_pin);
 
        return 0;
 }
@@ -774,38 +794,33 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
                case HDA_FIXUP_PINS:
                        if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins)
                                break;
-                       snd_printdd(KERN_INFO SFX
-                                   "%s: Apply pincfg for %s\n",
+                       codec_dbg(codec, "%s: Apply pincfg for %s\n",
                                    codec->chip_name, modelname);
                        snd_hda_apply_pincfgs(codec, fix->v.pins);
                        break;
                case HDA_FIXUP_VERBS:
                        if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs)
                                break;
-                       snd_printdd(KERN_INFO SFX
-                                   "%s: Apply fix-verbs for %s\n",
+                       codec_dbg(codec, "%s: Apply fix-verbs for %s\n",
                                    codec->chip_name, modelname);
                        snd_hda_add_verbs(codec, fix->v.verbs);
                        break;
                case HDA_FIXUP_FUNC:
                        if (!fix->v.func)
                                break;
-                       snd_printdd(KERN_INFO SFX
-                                   "%s: Apply fix-func for %s\n",
+                       codec_dbg(codec, "%s: Apply fix-func for %s\n",
                                    codec->chip_name, modelname);
                        fix->v.func(codec, fix, action);
                        break;
                case HDA_FIXUP_PINCTLS:
                        if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins)
                                break;
-                       snd_printdd(KERN_INFO SFX
-                                   "%s: Apply pinctl for %s\n",
+                       codec_dbg(codec, "%s: Apply pinctl for %s\n",
                                    codec->chip_name, modelname);
                        set_pin_targets(codec, fix->v.pins);
                        break;
                default:
-                       snd_printk(KERN_ERR SFX
-                                  "%s: Invalid fixup type %d\n",
+                       codec_err(codec, "%s: Invalid fixup type %d\n",
                                   codec->chip_name, fix->type);
                        break;
                }
index 0589b39cda6e413a5ef76025638cf80a6bc025b5..8c6c50afc0b732796d3c6d5aa7586d72751de55f 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include <linux/input.h>
-#include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/export.h>
@@ -140,7 +139,10 @@ static void turn_off_beep(struct hda_beep *beep)
 
 static void snd_hda_do_detach(struct hda_beep *beep)
 {
-       input_unregister_device(beep->dev);
+       if (beep->registered)
+               input_unregister_device(beep->dev);
+       else
+               input_free_device(beep->dev);
        beep->dev = NULL;
        turn_off_beep(beep);
 }
@@ -149,7 +151,6 @@ static int snd_hda_do_attach(struct hda_beep *beep)
 {
        struct input_dev *input_dev;
        struct hda_codec *codec = beep->codec;
-       int err;
 
        input_dev = input_allocate_device();
        if (!input_dev)
@@ -167,15 +168,9 @@ static int snd_hda_do_attach(struct hda_beep *beep)
        input_dev->evbit[0] = BIT_MASK(EV_SND);
        input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
        input_dev->event = snd_hda_beep_event;
-       input_dev->dev.parent = &codec->bus->pci->dev;
+       input_dev->dev.parent = &codec->dev;
        input_set_drvdata(input_dev, beep);
 
-       err = input_register_device(input_dev);
-       if (err < 0) {
-               input_free_device(input_dev);
-               printk(KERN_INFO "hda_beep: unable to register input device\n");
-               return err;
-       }
        beep->dev = input_dev;
        return 0;
 }
@@ -245,6 +240,27 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
 }
 EXPORT_SYMBOL_GPL(snd_hda_detach_beep_device);
 
+int snd_hda_register_beep_device(struct hda_codec *codec)
+{
+       struct hda_beep *beep = codec->beep;
+       int err;
+
+       if (!beep || !beep->dev)
+               return 0;
+
+       err = input_register_device(beep->dev);
+       if (err < 0) {
+               codec_err(codec, "hda_beep: unable to register input device\n");
+               input_free_device(beep->dev);
+               codec->beep = NULL;
+               kfree(beep);
+               return err;
+       }
+       beep->registered = true;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_hda_register_beep_device);
+
 static bool ctl_has_mute(struct snd_kcontrol *kcontrol)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
index cb88464676b656e109bd452ffbe1a94114cdcdd4..a63b5e077332a94e5a8e29457d2f6818c258ed6d 100644 (file)
@@ -34,6 +34,7 @@ struct hda_beep {
        char phys[32];
        int tone;
        hda_nid_t nid;
+       unsigned int registered:1;
        unsigned int enabled:1;
        unsigned int linear_tone:1;     /* linear tone for IDT/STAC codec */
        unsigned int playing:1;
@@ -45,6 +46,7 @@ struct hda_beep {
 int snd_hda_enable_beep_device(struct hda_codec *codec, int enable);
 int snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
 void snd_hda_detach_beep_device(struct hda_codec *codec);
+int snd_hda_register_beep_device(struct hda_codec *codec);
 #else
 static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
 {
@@ -53,5 +55,9 @@ static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
 static inline void snd_hda_detach_beep_device(struct hda_codec *codec)
 {
 }
+static inline int snd_hda_register_beep_device(struct hda_codec *codec)
+{
+       return 0;
+}
 #endif
 #endif
index dafcf82139e2bbdcdb4bad0539ad6c616661d892..4c20277a683531fccf5be99f9995d438e961fe92 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/async.h>
@@ -68,6 +67,7 @@ static struct hda_vendor_id hda_vendor_ids[] = {
        { 0x17e8, "Chrontel" },
        { 0x1854, "LG" },
        { 0x1aec, "Wolfson Microelectronics" },
+       { 0x1af4, "QEMU" },
        { 0x434d, "C-Media" },
        { 0x8086, "Intel" },
        { 0x8384, "SigmaTel" },
@@ -201,7 +201,7 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int flags,
 
        if ((codec->addr & ~0xf) || (nid & ~0x7f) ||
            (verb & ~0xfff) || (parm & ~0xffff)) {
-               printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x\n",
+               codec_err(codec, "hda-codec: out of range cmd %x:%x:%x:%x\n",
                       codec->addr, nid, verb, parm);
                return ~0;
        }
@@ -249,8 +249,8 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
        snd_hda_power_down(codec);
        if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) {
                if (bus->response_reset) {
-                       snd_printd("hda_codec: resetting BUS due to "
-                                  "fatal communication error\n");
+                       codec_dbg(codec,
+                                 "resetting BUS due to fatal communication error\n");
                        trace_hda_bus_reset(bus);
                        bus->ops.bus_reset(bus);
                }
@@ -475,8 +475,7 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
 
        if (len > 0 && conn_list) {
                if (len > max_conns) {
-                       snd_printk(KERN_ERR "hda_codec: "
-                                  "Too many connections %d for NID 0x%x\n",
+                       codec_err(codec, "Too many connections %d for NID 0x%x\n",
                                   len, nid);
                        return -EINVAL;
                }
@@ -574,8 +573,8 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
                range_val = !!(parm & (1 << (shift-1))); /* ranges */
                val = parm & mask;
                if (val == 0 && null_count++) {  /* no second chance */
-                       snd_printdd("hda_codec: "
-                                  "invalid CONNECT_LIST verb %x[%i]:%x\n",
+                       codec_dbg(codec,
+                                 "invalid CONNECT_LIST verb %x[%i]:%x\n",
                                    nid, i, parm);
                        return 0;
                }
@@ -583,7 +582,7 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
                if (range_val) {
                        /* ranges between the previous and this one */
                        if (!prev_nid || prev_nid >= val) {
-                               snd_printk(KERN_WARNING "hda_codec: "
+                               codec_warn(codec,
                                           "invalid dep_range_val %x:%x\n",
                                           prev_nid, val);
                                continue;
@@ -660,7 +659,7 @@ int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
        if (!recursive)
                return -1;
        if (recursive > 10) {
-               snd_printd("hda_codec: too deep connection for 0x%x\n", nid);
+               codec_dbg(codec, "too deep connection for 0x%x\n", nid);
                return -1;
        }
        recursive++;
@@ -808,8 +807,7 @@ static int init_unsol_queue(struct hda_bus *bus)
 
        unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
        if (!unsol) {
-               snd_printk(KERN_ERR "hda_codec: "
-                          "can't allocate unsolicited queue\n");
+               dev_err(bus->card->dev, "can't allocate unsolicited queue\n");
                return -ENOMEM;
        }
        INIT_WORK(&unsol->work, process_unsol_events);
@@ -821,51 +819,36 @@ static int init_unsol_queue(struct hda_bus *bus)
 /*
  * destructor
  */
-static void snd_hda_codec_free(struct hda_codec *codec);
-
-static int snd_hda_bus_free(struct hda_bus *bus)
+static void snd_hda_bus_free(struct hda_bus *bus)
 {
-       struct hda_codec *codec, *n;
-
        if (!bus)
-               return 0;
+               return;
+
+       WARN_ON(!list_empty(&bus->codec_list));
        if (bus->workq)
                flush_workqueue(bus->workq);
        if (bus->unsol)
                kfree(bus->unsol);
-       list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
-               snd_hda_codec_free(codec);
-       }
        if (bus->ops.private_free)
                bus->ops.private_free(bus);
        if (bus->workq)
                destroy_workqueue(bus->workq);
 
        kfree(bus);
-       return 0;
 }
 
 static int snd_hda_bus_dev_free(struct snd_device *device)
 {
-       struct hda_bus *bus = device->device_data;
-       bus->shutdown = 1;
-       return snd_hda_bus_free(bus);
+       snd_hda_bus_free(device->device_data);
+       return 0;
 }
 
-#ifdef CONFIG_SND_HDA_HWDEP
-static int snd_hda_bus_dev_register(struct snd_device *device)
+static int snd_hda_bus_dev_disconnect(struct snd_device *device)
 {
        struct hda_bus *bus = device->device_data;
-       struct hda_codec *codec;
-       list_for_each_entry(codec, &bus->codec_list, list) {
-               snd_hda_hwdep_add_sysfs(codec);
-               snd_hda_hwdep_add_power_sysfs(codec);
-       }
+       bus->shutdown = 1;
        return 0;
 }
-#else
-#define snd_hda_bus_dev_register       NULL
-#endif
 
 /**
  * snd_hda_bus_new - create a HDA bus
@@ -882,7 +865,7 @@ int snd_hda_bus_new(struct snd_card *card,
        struct hda_bus *bus;
        int err;
        static struct snd_device_ops dev_ops = {
-               .dev_register = snd_hda_bus_dev_register,
+               .dev_disconnect = snd_hda_bus_dev_disconnect,
                .dev_free = snd_hda_bus_dev_free,
        };
 
@@ -896,7 +879,7 @@ int snd_hda_bus_new(struct snd_card *card,
 
        bus = kzalloc(sizeof(*bus), GFP_KERNEL);
        if (bus == NULL) {
-               snd_printk(KERN_ERR "can't allocate struct hda_bus\n");
+               dev_err(card->dev, "can't allocate struct hda_bus\n");
                return -ENOMEM;
        }
 
@@ -915,7 +898,7 @@ int snd_hda_bus_new(struct snd_card *card,
                 "hd-audio%d", card->number);
        bus->workq = create_singlethread_workqueue(bus->workq_name);
        if (!bus->workq) {
-               snd_printk(KERN_ERR "cannot create workqueue %s\n",
+               dev_err(card->dev, "cannot create workqueue %s\n",
                           bus->workq_name);
                kfree(bus);
                return -ENOMEM;
@@ -959,7 +942,7 @@ find_codec_preset(struct hda_codec *codec)
        mutex_lock(&preset_mutex);
        list_for_each_entry(tbl, &hda_preset_tables, list) {
                if (!try_module_get(tbl->owner)) {
-                       snd_printk(KERN_ERR "hda_codec: cannot module_get\n");
+                       codec_err(codec, "cannot module_get\n");
                        continue;
                }
                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)
 {
        struct hda_pincfg *pin;
 
-#ifdef CONFIG_SND_HDA_HWDEP
+#ifdef CONFIG_SND_HDA_RECONFIG
        {
                unsigned int cfg = 0;
                mutex_lock(&codec->user_mutex);
@@ -1300,7 +1283,7 @@ static void free_hda_cache(struct hda_cache_rec *cache);
 static void free_init_pincfgs(struct hda_codec *codec)
 {
        snd_array_free(&codec->driver_pins);
-#ifdef CONFIG_SND_HDA_HWDEP
+#ifdef CONFIG_SND_HDA_RECONFIG
        snd_array_free(&codec->user_pins);
 #endif
        snd_array_free(&codec->init_pins);
@@ -1374,6 +1357,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
        if (codec->patch_ops.free)
                codec->patch_ops.free(codec);
        hda_call_pm_notify(codec, false); /* cancel leftover refcounts */
+       snd_hda_sysfs_clear(codec);
        unload_parser(codec);
        module_put(codec->owner);
        free_hda_cache(&codec->amp_cache);
@@ -1383,7 +1367,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
        kfree(codec->modelname);
        kfree(codec->wcaps);
        codec->bus->num_codecs--;
-       kfree(codec);
+       put_device(&codec->dev);
 }
 
 static 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,
 static unsigned int hda_set_power_state(struct hda_codec *codec,
                                unsigned int power_state);
 
+static int snd_hda_codec_dev_register(struct snd_device *device)
+{
+       struct hda_codec *codec = device->device_data;
+       int err = device_add(&codec->dev);
+
+       if (err < 0)
+               return err;
+       snd_hda_register_beep_device(codec);
+       return 0;
+}
+
+static int snd_hda_codec_dev_disconnect(struct snd_device *device)
+{
+       struct hda_codec *codec = device->device_data;
+
+       snd_hda_detach_beep_device(codec);
+       device_del(&codec->dev);
+       return 0;
+}
+
+static int snd_hda_codec_dev_free(struct snd_device *device)
+{
+       snd_hda_codec_free(device->device_data);
+       return 0;
+}
+
+/* just free the container */
+static void snd_hda_codec_dev_release(struct device *dev)
+{
+       kfree(container_of(dev, struct hda_codec, dev));
+}
+
 /**
  * snd_hda_codec_new - create a HDA codec
  * @bus: the bus to assign
@@ -1408,6 +1424,11 @@ int snd_hda_codec_new(struct hda_bus *bus,
        char component[31];
        hda_nid_t fg;
        int err;
+       static struct snd_device_ops dev_ops = {
+               .dev_register = snd_hda_codec_dev_register,
+               .dev_disconnect = snd_hda_codec_dev_disconnect,
+               .dev_free = snd_hda_codec_dev_free,
+       };
 
        if (snd_BUG_ON(!bus))
                return -EINVAL;
@@ -1415,17 +1436,27 @@ int snd_hda_codec_new(struct hda_bus *bus,
                return -EINVAL;
 
        if (bus->caddr_tbl[codec_addr]) {
-               snd_printk(KERN_ERR "hda_codec: "
-                          "address 0x%x is already occupied\n", codec_addr);
+               dev_err(bus->card->dev,
+                       "address 0x%x is already occupied\n",
+                       codec_addr);
                return -EBUSY;
        }
 
        codec = kzalloc(sizeof(*codec), GFP_KERNEL);
        if (codec == NULL) {
-               snd_printk(KERN_ERR "can't allocate struct hda_codec\n");
+               dev_err(bus->card->dev, "can't allocate struct hda_codec\n");
                return -ENOMEM;
        }
 
+       device_initialize(&codec->dev);
+       codec->dev.parent = &bus->card->card_dev;
+       codec->dev.class = sound_class;
+       codec->dev.release = snd_hda_codec_dev_release;
+       codec->dev.groups = snd_hda_dev_attr_groups;
+       dev_set_name(&codec->dev, "hdaudioC%dD%d", bus->card->number,
+                    codec_addr);
+       dev_set_drvdata(&codec->dev, codec); /* for sysfs */
+
        codec->bus = bus;
        codec->addr = codec_addr;
        mutex_init(&codec->spdif_mutex);
@@ -1456,11 +1487,13 @@ int snd_hda_codec_new(struct hda_bus *bus,
        hda_keep_power_on(codec);
 #endif
 
+       snd_hda_sysfs_init(codec);
+
        if (codec->bus->modelname) {
                codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
                if (!codec->modelname) {
-                       snd_hda_codec_free(codec);
-                       return -ENODEV;
+                       err = -ENODEV;
+                       goto error;
                }
        }
 
@@ -1484,7 +1517,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
 
        setup_fg_nodes(codec);
        if (!codec->afg && !codec->mfg) {
-               snd_printdd("hda_codec: no AFG or MFG node found\n");
+               dev_err(bus->card->dev, "no AFG or MFG node found\n");
                err = -ENODEV;
                goto error;
        }
@@ -1492,7 +1525,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
        fg = codec->afg ? codec->afg : codec->mfg;
        err = read_widget_caps(codec, fg);
        if (err < 0) {
-               snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
+               dev_err(bus->card->dev, "cannot malloc\n");
                goto error;
        }
        err = read_pin_defaults(codec);
@@ -1528,6 +1561,10 @@ int snd_hda_codec_new(struct hda_bus *bus,
                codec->subsystem_id, codec->revision_id);
        snd_component_add(codec->bus->card, component);
 
+       err = snd_device_new(bus->card, SNDRV_DEV_CODEC, codec, &dev_ops);
+       if (err < 0)
+               goto error;
+
        if (codecp)
                *codecp = codec;
        return 0;
@@ -1550,7 +1587,7 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)
        fg = codec->afg ? codec->afg : codec->mfg;
        err = read_widget_caps(codec, fg);
        if (err < 0) {
-               snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
+               codec_err(codec, "cannot malloc\n");
                return err;
        }
 
@@ -1627,7 +1664,7 @@ int snd_hda_codec_configure(struct hda_codec *codec)
 #endif
                }
                if (!patch) {
-                       printk(KERN_ERR "hda-codec: No codec parser is available\n");
+                       codec_err(codec, "No codec parser is available\n");
                        return -ENODEV;
                }
        }
@@ -1711,9 +1748,9 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
        if (!nid)
                return;
 
-       snd_printdd("hda_codec_setup_stream: "
-                   "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
-                   nid, stream_tag, channel_id, format);
+       codec_dbg(codec,
+                 "hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
+                 nid, stream_tag, channel_id, format);
        p = get_hda_cvt_setup(codec, nid);
        if (!p)
                return;
@@ -1760,7 +1797,7 @@ void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
        if (codec->no_sticky_stream)
                do_now = 1;
 
-       snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid);
+       codec_dbg(codec, "hda_codec_cleanup_stream: NID=0x%x\n", nid);
        p = get_hda_cvt_setup(codec, nid);
        if (p) {
                /* 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,
        uinfo->value.integer.min = 0;
        uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs);
        if (!uinfo->value.integer.max) {
-               printk(KERN_WARNING "hda_codec: "
-                      "num_steps = 0 for NID=0x%x (ctl = %s)\n", nid,
-                      kcontrol->id.name);
+               codec_warn(codec,
+                          "num_steps = 0 for NID=0x%x (ctl = %s)\n",
+                          nid, kcontrol->id.name);
                return -EINVAL;
        }
        return 0;
@@ -2558,8 +2595,8 @@ int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl,
                item->nid = nid;
                return 0;
        }
-       printk(KERN_ERR "hda-codec: no NID for mapping control %s:%d:%d\n",
-              kctl->id.name, kctl->id.index, index);
+       codec_err(codec, "no NID for mapping control %s:%d:%d\n",
+                 kctl->id.name, kctl->id.index, index);
        return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(snd_hda_add_nid);
@@ -2660,6 +2697,7 @@ int snd_hda_codec_reset(struct hda_codec *codec)
                                  bus->pcm_dev_bits);
                }
        }
+       snd_hda_detach_beep_device(codec);
        if (codec->patch_ops.free)
                codec->patch_ops.free(codec);
        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)
                        return -1;
                if (*step_to_check && *step_to_check != step) {
                        snd_printk(KERN_ERR "hda_codec: Mismatching dB step for vmaster slave (%d!=%d)\n",
-                                  *step_to_check, step);
+-                                 *step_to_check, step);
                        return -1;
                }
                *step_to_check = step;
@@ -2821,7 +2859,7 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
 
        err = map_slaves(codec, slaves, suffix, check_slave_present, NULL);
        if (err != 1) {
-               snd_printdd("No slave found for %s\n", name);
+               codec_dbg(codec, "No slave found for %s\n", name);
                return 0;
        }
        kctl = snd_ctl_make_virtual_master(name, tlv);
@@ -3487,7 +3525,7 @@ int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
 
        idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch", idx);
        if (idx < 0) {
-               printk(KERN_ERR "hda_codec: too many IEC958 outputs\n");
+               codec_err(codec, "too many IEC958 outputs\n");
                return -EBUSY;
        }
        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)
 
        idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0);
        if (idx < 0) {
-               printk(KERN_ERR "hda_codec: too many IEC958 inputs\n");
+               codec_err(codec, "too many IEC958 inputs\n");
                return -EBUSY;
        }
        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)
        }
 }
 
-#ifdef CONFIG_SND_HDA_HWDEP
+#ifdef CONFIG_SND_HDA_RECONFIG
 /* execute additional init verbs */
 static void hda_exec_init_verbs(struct hda_codec *codec)
 {
@@ -4118,12 +4156,13 @@ int snd_hda_build_controls(struct hda_bus *bus)
        list_for_each_entry(codec, &bus->codec_list, list) {
                int err = snd_hda_codec_build_controls(codec);
                if (err < 0) {
-                       printk(KERN_ERR "hda_codec: cannot build controls "
-                              "for #%d (error %d)\n", codec->addr, err);
+                       codec_err(codec,
+                                 "cannot build controls for #%d (error %d)\n",
+                                 codec->addr, err);
                        err = snd_hda_codec_reset(codec);
                        if (err < 0) {
-                               printk(KERN_ERR
-                                      "hda_codec: cannot revert codec\n");
+                               codec_err(codec,
+                                         "cannot revert codec\n");
                                return err;
                        }
                }
@@ -4294,7 +4333,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
                break;
        default:
                snd_printdd("invalid format width %d\n",
-                           snd_pcm_format_width(format));
+                         snd_pcm_format_width(format));
                return 0;
        }
 
@@ -4370,10 +4409,10 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
                                rates |= rate_bits[i].alsa_bits;
                }
                if (rates == 0) {
-                       snd_printk(KERN_ERR "hda_codec: rates == 0 "
-                                  "(nid=0x%x, val=0x%x, ovrd=%i)\n",
-                                       nid, val,
-                                       (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0);
+                       codec_err(codec,
+                                 "rates == 0 (nid=0x%x, val=0x%x, ovrd=%i)\n",
+                                 nid, val,
+                                 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0);
                        return -EIO;
                }
                *ratesp = rates;
@@ -4433,12 +4472,11 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
                        bps = 8;
                }
                if (formats == 0) {
-                       snd_printk(KERN_ERR "hda_codec: formats == 0 "
-                                  "(nid=0x%x, val=0x%x, ovrd=%i, "
-                                  "streams=0x%x)\n",
-                                       nid, val,
-                                       (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0,
-                                       streams);
+                       codec_err(codec,
+                                 "formats == 0 (nid=0x%x, val=0x%x, ovrd=%i, streams=0x%x)\n",
+                                 nid, val,
+                                 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0,
+                                 streams);
                        return -EIO;
                }
                if (formatsp)
@@ -4629,7 +4667,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
        int i;
 
        if (type >= HDA_PCM_NTYPES) {
-               snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
+               dev_err(bus->card->dev, "Invalid PCM type %d\n", type);
                return -EINVAL;
        }
 
@@ -4650,10 +4688,11 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
        }
 #endif
 
-       snd_printk(KERN_WARNING "Too many %s devices\n",
+       dev_warn(bus->card->dev, "Too many %s devices\n",
                snd_hda_pcm_type_name[type]);
 #ifndef CONFIG_SND_DYNAMIC_MINORS
-       snd_printk(KERN_WARNING "Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y\n");
+       dev_warn(bus->card->dev,
+                "Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y\n");
 #endif
        return -EAGAIN;
 }
@@ -4691,12 +4730,13 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
                        return 0;
                err = codec->patch_ops.build_pcms(codec);
                if (err < 0) {
-                       printk(KERN_ERR "hda_codec: cannot build PCMs"
-                              "for #%d (error %d)\n", codec->addr, err);
+                       codec_err(codec,
+                                 "cannot build PCMs for #%d (error %d)\n",
+                                 codec->addr, err);
                        err = snd_hda_codec_reset(codec);
                        if (err < 0) {
-                               printk(KERN_ERR
-                                      "hda_codec: cannot revert codec\n");
+                               codec_err(codec,
+                                         "cannot revert codec\n");
                                return err;
                        }
                }
@@ -4715,9 +4755,9 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
                        cpcm->device = dev;
                        err = snd_hda_attach_pcm(codec, cpcm);
                        if (err < 0) {
-                               printk(KERN_ERR "hda_codec: cannot attach "
-                                      "PCM stream %d for codec #%d\n",
-                                      dev, codec->addr);
+                               codec_err(codec,
+                                         "cannot attach PCM stream %d for codec #%d\n",
+                                         dev, codec->addr);
                                continue; /* no fatal error */
                        }
                }
@@ -4786,8 +4826,8 @@ int snd_hda_check_board_config(struct hda_codec *codec,
                for (i = 0; i < num_configs; i++) {
                        if (models[i] &&
                            !strcmp(codec->modelname, models[i])) {
-                               snd_printd(KERN_INFO "hda_codec: model '%s' is "
-                                          "selected\n", models[i]);
+                               codec_info(codec, "model '%s' is selected\n",
+                                          models[i]);
                                return i;
                        }
                }
@@ -4809,10 +4849,9 @@ int snd_hda_check_board_config(struct hda_codec *codec,
                        sprintf(tmp, "#%d", tbl->value);
                        model = tmp;
                }
-               snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
-                           "for config %x:%x (%s)\n",
-                           model, tbl->subvendor, tbl->subdevice,
-                           (tbl->name ? tbl->name : "Unknown device"));
+               codec_info(codec, "model '%s' is selected for config %x:%x (%s)\n",
+                          model, tbl->subvendor, tbl->subdevice,
+                          (tbl->name ? tbl->name : "Unknown device"));
 #endif
                return tbl->value;
        }
@@ -4870,10 +4909,9 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
                        sprintf(tmp, "#%d", tbl->value);
                        model = tmp;
                }
-               snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
-                           "for config %x:%x (%s)\n",
-                           model, tbl->subvendor, tbl->subdevice,
-                           (tbl->name ? tbl->name : "Unknown device"));
+               codec_info(codec, "model '%s' is selected for config %x:%x (%s)\n",
+                          model, tbl->subvendor, tbl->subdevice,
+                          (tbl->name ? tbl->name : "Unknown device"));
 #endif
                return tbl->value;
        }
index ab2a444ba5017b6cab3afa91119355f798e29917..a4233136cb93d83b0ca3f2f583a7896d1b8e0567 100644 (file)
@@ -271,6 +271,7 @@ struct hda_pcm {
 
 /* codec information */
 struct hda_codec {
+       struct device dev;
        struct hda_bus *bus;
        unsigned int addr;      /* codec addr*/
        struct list_head list;  /* list point */
@@ -332,14 +333,17 @@ struct hda_codec {
        struct snd_array driver_pins;   /* pin configs set by codec parser */
        struct snd_array cvt_setups;    /* audio convert setups */
 
-#ifdef CONFIG_SND_HDA_HWDEP
        struct mutex user_mutex;
-       struct snd_hwdep *hwdep;        /* assigned hwdep device */
+#ifdef CONFIG_SND_HDA_RECONFIG
        struct snd_array init_verbs;    /* additional init verbs */
        struct snd_array hints;         /* additional hints */
        struct snd_array user_pins;     /* default pin configs to override */
 #endif
 
+#ifdef CONFIG_SND_HDA_HWDEP
+       struct snd_hwdep *hwdep;        /* assigned hwdep device */
+#endif
+
        /* misc flags */
        unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each
                                             * status change
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
new file mode 100644 (file)
index 0000000..97993e1
--- /dev/null
@@ -0,0 +1,2031 @@
+/*
+ *
+ *  Implementation of primary alsa driver code base for Intel HD Audio.
+ *
+ *  Copyright(c) 2004 Intel Corporation. All rights reserved.
+ *
+ *  Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
+ *                     PeiSen Hou <pshou@realtek.com.tw>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *
+ */
+
+#include <linux/clocksource.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include <sound/initval.h>
+#include "hda_priv.h"
+#include "hda_controller.h"
+
+#define CREATE_TRACE_POINTS
+#include "hda_intel_trace.h"
+
+/* DSP lock helpers */
+#ifdef CONFIG_SND_HDA_DSP_LOADER
+#define dsp_lock_init(dev)     mutex_init(&(dev)->dsp_mutex)
+#define dsp_lock(dev)          mutex_lock(&(dev)->dsp_mutex)
+#define dsp_unlock(dev)                mutex_unlock(&(dev)->dsp_mutex)
+#define dsp_is_locked(dev)     ((dev)->locked)
+#else
+#define dsp_lock_init(dev)     do {} while (0)
+#define dsp_lock(dev)          do {} while (0)
+#define dsp_unlock(dev)                do {} while (0)
+#define dsp_is_locked(dev)     0
+#endif
+
+/*
+ * AZX stream operations.
+ */
+
+/* start a stream */
+static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
+{
+       /*
+        * Before stream start, initialize parameter
+        */
+       azx_dev->insufficient = 1;
+
+       /* enable SIE */
+       azx_writel(chip, INTCTL,
+                  azx_readl(chip, INTCTL) | (1 << azx_dev->index));
+       /* set DMA start and interrupt mask */
+       azx_sd_writeb(chip, azx_dev, SD_CTL,
+                     azx_sd_readb(chip, azx_dev, SD_CTL) |
+                     SD_CTL_DMA_START | SD_INT_MASK);
+}
+
+/* stop DMA */
+static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
+{
+       azx_sd_writeb(chip, azx_dev, SD_CTL,
+                     azx_sd_readb(chip, azx_dev, SD_CTL) &
+                     ~(SD_CTL_DMA_START | SD_INT_MASK));
+       azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
+}
+
+/* stop a stream */
+void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
+{
+       azx_stream_clear(chip, azx_dev);
+       /* disable SIE */
+       azx_writel(chip, INTCTL,
+                  azx_readl(chip, INTCTL) & ~(1 << azx_dev->index));
+}
+EXPORT_SYMBOL_GPL(azx_stream_stop);
+
+/* reset stream */
+static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
+{
+       unsigned char val;
+       int timeout;
+
+       azx_stream_clear(chip, azx_dev);
+
+       azx_sd_writeb(chip, azx_dev, SD_CTL,
+                     azx_sd_readb(chip, azx_dev, SD_CTL) |
+                     SD_CTL_STREAM_RESET);
+       udelay(3);
+       timeout = 300;
+       while (!((val = azx_sd_readb(chip, azx_dev, SD_CTL)) &
+                SD_CTL_STREAM_RESET) && --timeout)
+               ;
+       val &= ~SD_CTL_STREAM_RESET;
+       azx_sd_writeb(chip, azx_dev, SD_CTL, val);
+       udelay(3);
+
+       timeout = 300;
+       /* waiting for hardware to report that the stream is out of reset */
+       while (((val = azx_sd_readb(chip, azx_dev, SD_CTL)) &
+               SD_CTL_STREAM_RESET) && --timeout)
+               ;
+
+       /* reset first position - may not be synced with hw at this time */
+       *azx_dev->posbuf = 0;
+}
+
+/*
+ * set up the SD for streaming
+ */
+static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
+{
+       unsigned int val;
+       /* make sure the run bit is zero for SD */
+       azx_stream_clear(chip, azx_dev);
+       /* program the stream_tag */
+       val = azx_sd_readl(chip, azx_dev, SD_CTL);
+       val = (val & ~SD_CTL_STREAM_TAG_MASK) |
+               (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT);
+       if (!azx_snoop(chip))
+               val |= SD_CTL_TRAFFIC_PRIO;
+       azx_sd_writel(chip, azx_dev, SD_CTL, val);
+
+       /* program the length of samples in cyclic buffer */
+       azx_sd_writel(chip, azx_dev, SD_CBL, azx_dev->bufsize);
+
+       /* program the stream format */
+       /* this value needs to be the same as the one programmed */
+       azx_sd_writew(chip, azx_dev, SD_FORMAT, azx_dev->format_val);
+
+       /* program the stream LVI (last valid index) of the BDL */
+       azx_sd_writew(chip, azx_dev, SD_LVI, azx_dev->frags - 1);
+
+       /* program the BDL address */
+       /* lower BDL address */
+       azx_sd_writel(chip, azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
+       /* upper BDL address */
+       azx_sd_writel(chip, azx_dev, SD_BDLPU,
+                     upper_32_bits(azx_dev->bdl.addr));
+
+       /* enable the position buffer */
+       if (chip->position_fix[0] != POS_FIX_LPIB ||
+           chip->position_fix[1] != POS_FIX_LPIB) {
+               if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
+                       azx_writel(chip, DPLBASE,
+                               (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
+       }
+
+       /* set the interrupt enable bits in the descriptor control register */
+       azx_sd_writel(chip, azx_dev, SD_CTL,
+                     azx_sd_readl(chip, azx_dev, SD_CTL) | SD_INT_MASK);
+
+       return 0;
+}
+
+/* assign a stream for the PCM */
+static inline struct azx_dev *
+azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
+{
+       int dev, i, nums;
+       struct azx_dev *res = NULL;
+       /* make a non-zero unique key for the substream */
+       int key = (substream->pcm->device << 16) | (substream->number << 2) |
+               (substream->stream + 1);
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               dev = chip->playback_index_offset;
+               nums = chip->playback_streams;
+       } else {
+               dev = chip->capture_index_offset;
+               nums = chip->capture_streams;
+       }
+       for (i = 0; i < nums; i++, dev++) {
+               struct azx_dev *azx_dev = &chip->azx_dev[dev];
+               dsp_lock(azx_dev);
+               if (!azx_dev->opened && !dsp_is_locked(azx_dev)) {
+                       res = azx_dev;
+                       if (res->assigned_key == key) {
+                               res->opened = 1;
+                               res->assigned_key = key;
+                               dsp_unlock(azx_dev);
+                               return azx_dev;
+                       }
+               }
+               dsp_unlock(azx_dev);
+       }
+       if (res) {
+               dsp_lock(res);
+               res->opened = 1;
+               res->assigned_key = key;
+               dsp_unlock(res);
+       }
+       return res;
+}
+
+/* release the assigned stream */
+static inline void azx_release_device(struct azx_dev *azx_dev)
+{
+       azx_dev->opened = 0;
+}
+
+static cycle_t azx_cc_read(const struct cyclecounter *cc)
+{
+       struct azx_dev *azx_dev = container_of(cc, struct azx_dev, azx_cc);
+       struct snd_pcm_substream *substream = azx_dev->substream;
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+
+       return azx_readl(chip, WALLCLK);
+}
+
+static void azx_timecounter_init(struct snd_pcm_substream *substream,
+                               bool force, cycle_t last)
+{
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       struct timecounter *tc = &azx_dev->azx_tc;
+       struct cyclecounter *cc = &azx_dev->azx_cc;
+       u64 nsec;
+
+       cc->read = azx_cc_read;
+       cc->mask = CLOCKSOURCE_MASK(32);
+
+       /*
+        * Converting from 24 MHz to ns means applying a 125/3 factor.
+        * To avoid any saturation issues in intermediate operations,
+        * the 125 factor is applied first. The division is applied
+        * last after reading the timecounter value.
+        * Applying the 1/3 factor as part of the multiplication
+        * requires at least 20 bits for a decent precision, however
+        * overflows occur after about 4 hours or less, not a option.
+        */
+
+       cc->mult = 125; /* saturation after 195 years */
+       cc->shift = 0;
+
+       nsec = 0; /* audio time is elapsed time since trigger */
+       timecounter_init(tc, cc, nsec);
+       if (force)
+               /*
+                * force timecounter to use predefined value,
+                * used for synchronized starts
+                */
+               tc->cycle_last = last;
+}
+
+static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream,
+                               u64 nsec)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
+       u64 codec_frames, codec_nsecs;
+
+       if (!hinfo->ops.get_delay)
+               return nsec;
+
+       codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream);
+       codec_nsecs = div_u64(codec_frames * 1000000000LL,
+                             substream->runtime->rate);
+
+       if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+               return nsec + codec_nsecs;
+
+       return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
+}
+
+/*
+ * set up a BDL entry
+ */
+static int setup_bdle(struct azx *chip,
+                     struct snd_dma_buffer *dmab,
+                     struct azx_dev *azx_dev, u32 **bdlp,
+                     int ofs, int size, int with_ioc)
+{
+       u32 *bdl = *bdlp;
+
+       while (size > 0) {
+               dma_addr_t addr;
+               int chunk;
+
+               if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
+                       return -EINVAL;
+
+               addr = snd_sgbuf_get_addr(dmab, ofs);
+               /* program the address field of the BDL entry */
+               bdl[0] = cpu_to_le32((u32)addr);
+               bdl[1] = cpu_to_le32(upper_32_bits(addr));
+               /* program the size field of the BDL entry */
+               chunk = snd_sgbuf_get_chunk_size(dmab, ofs, size);
+               /* one BDLE cannot cross 4K boundary on CTHDA chips */
+               if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY) {
+                       u32 remain = 0x1000 - (ofs & 0xfff);
+                       if (chunk > remain)
+                               chunk = remain;
+               }
+               bdl[2] = cpu_to_le32(chunk);
+               /* program the IOC to enable interrupt
+                * only when the whole fragment is processed
+                */
+               size -= chunk;
+               bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
+               bdl += 4;
+               azx_dev->frags++;
+               ofs += chunk;
+       }
+       *bdlp = bdl;
+       return ofs;
+}
+
+/*
+ * set up BDL entries
+ */
+static int azx_setup_periods(struct azx *chip,
+                            struct snd_pcm_substream *substream,
+                            struct azx_dev *azx_dev)
+{
+       u32 *bdl;
+       int i, ofs, periods, period_bytes;
+       int pos_adj = 0;
+
+       /* reset BDL address */
+       azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
+       azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
+
+       period_bytes = azx_dev->period_bytes;
+       periods = azx_dev->bufsize / period_bytes;
+
+       /* program the initial BDL entries */
+       bdl = (u32 *)azx_dev->bdl.area;
+       ofs = 0;
+       azx_dev->frags = 0;
+
+       if (chip->bdl_pos_adj)
+               pos_adj = chip->bdl_pos_adj[chip->dev_index];
+       if (!azx_dev->no_period_wakeup && pos_adj > 0) {
+               struct snd_pcm_runtime *runtime = substream->runtime;
+               int pos_align = pos_adj;
+               pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
+               if (!pos_adj)
+                       pos_adj = pos_align;
+               else
+                       pos_adj = ((pos_adj + pos_align - 1) / pos_align) *
+                               pos_align;
+               pos_adj = frames_to_bytes(runtime, pos_adj);
+               if (pos_adj >= period_bytes) {
+                       dev_warn(chip->card->dev,"Too big adjustment %d\n",
+                                pos_adj);
+                       pos_adj = 0;
+               } else {
+                       ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
+                                        azx_dev,
+                                        &bdl, ofs, pos_adj, true);
+                       if (ofs < 0)
+                               goto error;
+               }
+       } else
+               pos_adj = 0;
+
+       for (i = 0; i < periods; i++) {
+               if (i == periods - 1 && pos_adj)
+                       ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
+                                        azx_dev, &bdl, ofs,
+                                        period_bytes - pos_adj, 0);
+               else
+                       ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
+                                        azx_dev, &bdl, ofs,
+                                        period_bytes,
+                                        !azx_dev->no_period_wakeup);
+               if (ofs < 0)
+                       goto error;
+       }
+       return 0;
+
+ error:
+       dev_err(chip->card->dev, "Too many BDL entries: buffer=%d, period=%d\n",
+               azx_dev->bufsize, period_bytes);
+       return -EINVAL;
+}
+
+/*
+ * PCM ops
+ */
+
+static int azx_pcm_close(struct snd_pcm_substream *substream)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
+       struct azx *chip = apcm->chip;
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       unsigned long flags;
+
+       mutex_lock(&chip->open_mutex);
+       spin_lock_irqsave(&chip->reg_lock, flags);
+       azx_dev->substream = NULL;
+       azx_dev->running = 0;
+       spin_unlock_irqrestore(&chip->reg_lock, flags);
+       azx_release_device(azx_dev);
+       hinfo->ops.close(hinfo, apcm->codec, substream);
+       snd_hda_power_down(apcm->codec);
+       mutex_unlock(&chip->open_mutex);
+       return 0;
+}
+
+static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
+                            struct snd_pcm_hw_params *hw_params)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+       int ret;
+
+       dsp_lock(get_azx_dev(substream));
+       if (dsp_is_locked(get_azx_dev(substream))) {
+               ret = -EBUSY;
+               goto unlock;
+       }
+
+       ret = chip->ops->substream_alloc_pages(chip, substream,
+                                         params_buffer_bytes(hw_params));
+unlock:
+       dsp_unlock(get_azx_dev(substream));
+       return ret;
+}
+
+static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       struct azx *chip = apcm->chip;
+       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
+       int err;
+
+       /* reset BDL address */
+       dsp_lock(azx_dev);
+       if (!dsp_is_locked(azx_dev)) {
+               azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
+               azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
+               azx_sd_writel(chip, azx_dev, SD_CTL, 0);
+               azx_dev->bufsize = 0;
+               azx_dev->period_bytes = 0;
+               azx_dev->format_val = 0;
+       }
+
+       snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
+
+       err = chip->ops->substream_free_pages(chip, substream);
+       azx_dev->prepared = 0;
+       dsp_unlock(azx_dev);
+       return err;
+}
+
+static int azx_pcm_prepare(struct snd_pcm_substream *substream)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       unsigned int bufsize, period_bytes, format_val, stream_tag;
+       int err;
+       struct hda_spdif_out *spdif =
+               snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
+       unsigned short ctls = spdif ? spdif->ctls : 0;
+
+       dsp_lock(azx_dev);
+       if (dsp_is_locked(azx_dev)) {
+               err = -EBUSY;
+               goto unlock;
+       }
+
+       azx_stream_reset(chip, azx_dev);
+       format_val = snd_hda_calc_stream_format(runtime->rate,
+                                               runtime->channels,
+                                               runtime->format,
+                                               hinfo->maxbps,
+                                               ctls);
+       if (!format_val) {
+               dev_err(chip->card->dev,
+                       "invalid format_val, rate=%d, ch=%d, format=%d\n",
+                       runtime->rate, runtime->channels, runtime->format);
+               err = -EINVAL;
+               goto unlock;
+       }
+
+       bufsize = snd_pcm_lib_buffer_bytes(substream);
+       period_bytes = snd_pcm_lib_period_bytes(substream);
+
+       dev_dbg(chip->card->dev, "azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
+               bufsize, format_val);
+
+       if (bufsize != azx_dev->bufsize ||
+           period_bytes != azx_dev->period_bytes ||
+           format_val != azx_dev->format_val ||
+           runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
+               azx_dev->bufsize = bufsize;
+               azx_dev->period_bytes = period_bytes;
+               azx_dev->format_val = format_val;
+               azx_dev->no_period_wakeup = runtime->no_period_wakeup;
+               err = azx_setup_periods(chip, substream, azx_dev);
+               if (err < 0)
+                       goto unlock;
+       }
+
+       /* when LPIB delay correction gives a small negative value,
+        * we ignore it; currently set the threshold statically to
+        * 64 frames
+        */
+       if (runtime->period_size > 64)
+               azx_dev->delay_negative_threshold = -frames_to_bytes(runtime, 64);
+       else
+               azx_dev->delay_negative_threshold = 0;
+
+       /* wallclk has 24Mhz clock source */
+       azx_dev->period_wallclk = (((runtime->period_size * 24000) /
+                                               runtime->rate) * 1000);
+       azx_setup_controller(chip, azx_dev);
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               azx_dev->fifo_size =
+                       azx_sd_readw(chip, azx_dev, SD_FIFOSIZE) + 1;
+       else
+               azx_dev->fifo_size = 0;
+
+       stream_tag = azx_dev->stream_tag;
+       /* CA-IBG chips need the playback stream starting from 1 */
+       if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) &&
+           stream_tag > chip->capture_streams)
+               stream_tag -= chip->capture_streams;
+       err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag,
+                                    azx_dev->format_val, substream);
+
+ unlock:
+       if (!err)
+               azx_dev->prepared = 1;
+       dsp_unlock(azx_dev);
+       return err;
+}
+
+static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+       struct azx_dev *azx_dev;
+       struct snd_pcm_substream *s;
+       int rstart = 0, start, nsync = 0, sbits = 0;
+       int nwait, timeout;
+
+       azx_dev = get_azx_dev(substream);
+       trace_azx_pcm_trigger(chip, azx_dev, cmd);
+
+       if (dsp_is_locked(azx_dev) || !azx_dev->prepared)
+               return -EPIPE;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               rstart = 1;
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+       case SNDRV_PCM_TRIGGER_RESUME:
+               start = 1;
+               break;
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
+       case SNDRV_PCM_TRIGGER_STOP:
+               start = 0;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       snd_pcm_group_for_each_entry(s, substream) {
+               if (s->pcm->card != substream->pcm->card)
+                       continue;
+               azx_dev = get_azx_dev(s);
+               sbits |= 1 << azx_dev->index;
+               nsync++;
+               snd_pcm_trigger_done(s, substream);
+       }
+
+       spin_lock(&chip->reg_lock);
+
+       /* first, set SYNC bits of corresponding streams */
+       if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
+               azx_writel(chip, OLD_SSYNC,
+                       azx_readl(chip, OLD_SSYNC) | sbits);
+       else
+               azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) | sbits);
+
+       snd_pcm_group_for_each_entry(s, substream) {
+               if (s->pcm->card != substream->pcm->card)
+                       continue;
+               azx_dev = get_azx_dev(s);
+               if (start) {
+                       azx_dev->start_wallclk = azx_readl(chip, WALLCLK);
+                       if (!rstart)
+                               azx_dev->start_wallclk -=
+                                               azx_dev->period_wallclk;
+                       azx_stream_start(chip, azx_dev);
+               } else {
+                       azx_stream_stop(chip, azx_dev);
+               }
+               azx_dev->running = start;
+       }
+       spin_unlock(&chip->reg_lock);
+       if (start) {
+               /* wait until all FIFOs get ready */
+               for (timeout = 5000; timeout; timeout--) {
+                       nwait = 0;
+                       snd_pcm_group_for_each_entry(s, substream) {
+                               if (s->pcm->card != substream->pcm->card)
+                                       continue;
+                               azx_dev = get_azx_dev(s);
+                               if (!(azx_sd_readb(chip, azx_dev, SD_STS) &
+                                     SD_STS_FIFO_READY))
+                                       nwait++;
+                       }
+                       if (!nwait)
+                               break;
+                       cpu_relax();
+               }
+       } else {
+               /* wait until all RUN bits are cleared */
+               for (timeout = 5000; timeout; timeout--) {
+                       nwait = 0;
+                       snd_pcm_group_for_each_entry(s, substream) {
+                               if (s->pcm->card != substream->pcm->card)
+                                       continue;
+                               azx_dev = get_azx_dev(s);
+                               if (azx_sd_readb(chip, azx_dev, SD_CTL) &
+                                   SD_CTL_DMA_START)
+                                       nwait++;
+                       }
+                       if (!nwait)
+                               break;
+                       cpu_relax();
+               }
+       }
+       spin_lock(&chip->reg_lock);
+       /* reset SYNC bits */
+       if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
+               azx_writel(chip, OLD_SSYNC,
+                       azx_readl(chip, OLD_SSYNC) & ~sbits);
+       else
+               azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits);
+       if (start) {
+               azx_timecounter_init(substream, 0, 0);
+               if (nsync > 1) {
+                       cycle_t cycle_last;
+
+                       /* same start cycle for master and group */
+                       azx_dev = get_azx_dev(substream);
+                       cycle_last = azx_dev->azx_tc.cycle_last;
+
+                       snd_pcm_group_for_each_entry(s, substream) {
+                               if (s->pcm->card != substream->pcm->card)
+                                       continue;
+                               azx_timecounter_init(s, 1, cycle_last);
+                       }
+               }
+       }
+       spin_unlock(&chip->reg_lock);
+       return 0;
+}
+
+/* get the current DMA position with correction on VIA chips */
+static unsigned int azx_via_get_position(struct azx *chip,
+                                        struct azx_dev *azx_dev)
+{
+       unsigned int link_pos, mini_pos, bound_pos;
+       unsigned int mod_link_pos, mod_dma_pos, mod_mini_pos;
+       unsigned int fifo_size;
+
+       link_pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
+       if (azx_dev->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               /* Playback, no problem using link position */
+               return link_pos;
+       }
+
+       /* Capture */
+       /* For new chipset,
+        * use mod to get the DMA position just like old chipset
+        */
+       mod_dma_pos = le32_to_cpu(*azx_dev->posbuf);
+       mod_dma_pos %= azx_dev->period_bytes;
+
+       /* azx_dev->fifo_size can't get FIFO size of in stream.
+        * Get from base address + offset.
+        */
+       fifo_size = readw(chip->remap_addr + VIA_IN_STREAM0_FIFO_SIZE_OFFSET);
+
+       if (azx_dev->insufficient) {
+               /* Link position never gather than FIFO size */
+               if (link_pos <= fifo_size)
+                       return 0;
+
+               azx_dev->insufficient = 0;
+       }
+
+       if (link_pos <= fifo_size)
+               mini_pos = azx_dev->bufsize + link_pos - fifo_size;
+       else
+               mini_pos = link_pos - fifo_size;
+
+       /* Find nearest previous boudary */
+       mod_mini_pos = mini_pos % azx_dev->period_bytes;
+       mod_link_pos = link_pos % azx_dev->period_bytes;
+       if (mod_link_pos >= fifo_size)
+               bound_pos = link_pos - mod_link_pos;
+       else if (mod_dma_pos >= mod_mini_pos)
+               bound_pos = mini_pos - mod_mini_pos;
+       else {
+               bound_pos = mini_pos - mod_mini_pos + azx_dev->period_bytes;
+               if (bound_pos >= azx_dev->bufsize)
+                       bound_pos = 0;
+       }
+
+       /* Calculate real DMA position we want */
+       return bound_pos + mod_dma_pos;
+}
+
+unsigned int azx_get_position(struct azx *chip,
+                             struct azx_dev *azx_dev,
+                             bool with_check)
+{
+       struct snd_pcm_substream *substream = azx_dev->substream;
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       unsigned int pos;
+       int stream = substream->stream;
+       struct hda_pcm_stream *hinfo = apcm->hinfo[stream];
+       int delay = 0;
+
+       switch (chip->position_fix[stream]) {
+       case POS_FIX_LPIB:
+               /* read LPIB */
+               pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
+               break;
+       case POS_FIX_VIACOMBO:
+               pos = azx_via_get_position(chip, azx_dev);
+               break;
+       default:
+               /* use the position buffer */
+               pos = le32_to_cpu(*azx_dev->posbuf);
+               if (with_check && chip->position_fix[stream] == POS_FIX_AUTO) {
+                       if (!pos || pos == (u32)-1) {
+                               dev_info(chip->card->dev,
+                                        "Invalid position buffer, using LPIB read method instead.\n");
+                               chip->position_fix[stream] = POS_FIX_LPIB;
+                               pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
+                       } else
+                               chip->position_fix[stream] = POS_FIX_POSBUF;
+               }
+               break;
+       }
+
+       if (pos >= azx_dev->bufsize)
+               pos = 0;
+
+       /* calculate runtime delay from LPIB */
+       if (substream->runtime &&
+           chip->position_fix[stream] == POS_FIX_POSBUF &&
+           (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
+               unsigned int lpib_pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
+               if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+                       delay = pos - lpib_pos;
+               else
+                       delay = lpib_pos - pos;
+               if (delay < 0) {
+                       if (delay >= azx_dev->delay_negative_threshold)
+                               delay = 0;
+                       else
+                               delay += azx_dev->bufsize;
+               }
+               if (delay >= azx_dev->period_bytes) {
+                       dev_info(chip->card->dev,
+                                "Unstable LPIB (%d >= %d); disabling LPIB delay counting\n",
+                                delay, azx_dev->period_bytes);
+                       delay = 0;
+                       chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
+               }
+               delay = bytes_to_frames(substream->runtime, delay);
+       }
+
+       if (substream->runtime) {
+               if (hinfo->ops.get_delay)
+                       delay += hinfo->ops.get_delay(hinfo, apcm->codec,
+                                                     substream);
+               substream->runtime->delay = delay;
+       }
+
+       trace_azx_get_position(chip, azx_dev, pos, delay);
+       return pos;
+}
+EXPORT_SYMBOL_GPL(azx_get_position);
+
+static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       return bytes_to_frames(substream->runtime,
+                              azx_get_position(chip, azx_dev, false));
+}
+
+static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream,
+                               struct timespec *ts)
+{
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       u64 nsec;
+
+       nsec = timecounter_read(&azx_dev->azx_tc);
+       nsec = div_u64(nsec, 3); /* can be optimized */
+       nsec = azx_adjust_codec_delay(substream, nsec);
+
+       *ts = ns_to_timespec(nsec);
+
+       return 0;
+}
+
+static struct snd_pcm_hardware azx_pcm_hw = {
+       .info =                 (SNDRV_PCM_INFO_MMAP |
+                                SNDRV_PCM_INFO_INTERLEAVED |
+                                SNDRV_PCM_INFO_BLOCK_TRANSFER |
+                                SNDRV_PCM_INFO_MMAP_VALID |
+                                /* No full-resume yet implemented */
+                                /* SNDRV_PCM_INFO_RESUME |*/
+                                SNDRV_PCM_INFO_PAUSE |
+                                SNDRV_PCM_INFO_SYNC_START |
+                                SNDRV_PCM_INFO_HAS_WALL_CLOCK |
+                                SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
+       .formats =              SNDRV_PCM_FMTBIT_S16_LE,
+       .rates =                SNDRV_PCM_RATE_48000,
+       .rate_min =             48000,
+       .rate_max =             48000,
+       .channels_min =         2,
+       .channels_max =         2,
+       .buffer_bytes_max =     AZX_MAX_BUF_SIZE,
+       .period_bytes_min =     128,
+       .period_bytes_max =     AZX_MAX_BUF_SIZE / 2,
+       .periods_min =          2,
+       .periods_max =          AZX_MAX_FRAG,
+       .fifo_size =            0,
+};
+
+static int azx_pcm_open(struct snd_pcm_substream *substream)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
+       struct azx *chip = apcm->chip;
+       struct azx_dev *azx_dev;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       unsigned long flags;
+       int err;
+       int buff_step;
+
+       mutex_lock(&chip->open_mutex);
+       azx_dev = azx_assign_device(chip, substream);
+       if (azx_dev == NULL) {
+               mutex_unlock(&chip->open_mutex);
+               return -EBUSY;
+       }
+       runtime->hw = azx_pcm_hw;
+       runtime->hw.channels_min = hinfo->channels_min;
+       runtime->hw.channels_max = hinfo->channels_max;
+       runtime->hw.formats = hinfo->formats;
+       runtime->hw.rates = hinfo->rates;
+       snd_pcm_limit_hw_rates(runtime);
+       snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+
+       /* avoid wrap-around with wall-clock */
+       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
+                                    20,
+                                    178000000);
+
+       if (chip->align_buffer_size)
+               /* constrain buffer sizes to be multiple of 128
+                  bytes. This is more efficient in terms of memory
+                  access but isn't required by the HDA spec and
+                  prevents users from specifying exact period/buffer
+                  sizes. For example for 44.1kHz, a period size set
+                  to 20ms will be rounded to 19.59ms. */
+               buff_step = 128;
+       else
+               /* Don't enforce steps on buffer sizes, still need to
+                  be multiple of 4 bytes (HDA spec). Tested on Intel
+                  HDA controllers, may not work on all devices where
+                  option needs to be disabled */
+               buff_step = 4;
+
+       snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
+                                  buff_step);
+       snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+                                  buff_step);
+       snd_hda_power_up_d3wait(apcm->codec);
+       err = hinfo->ops.open(hinfo, apcm->codec, substream);
+       if (err < 0) {
+               azx_release_device(azx_dev);
+               snd_hda_power_down(apcm->codec);
+               mutex_unlock(&chip->open_mutex);
+               return err;
+       }
+       snd_pcm_limit_hw_rates(runtime);
+       /* sanity check */
+       if (snd_BUG_ON(!runtime->hw.channels_min) ||
+           snd_BUG_ON(!runtime->hw.channels_max) ||
+           snd_BUG_ON(!runtime->hw.formats) ||
+           snd_BUG_ON(!runtime->hw.rates)) {
+               azx_release_device(azx_dev);
+               hinfo->ops.close(hinfo, apcm->codec, substream);
+               snd_hda_power_down(apcm->codec);
+               mutex_unlock(&chip->open_mutex);
+               return -EINVAL;
+       }
+
+       /* disable WALLCLOCK timestamps for capture streams
+          until we figure out how to handle digital inputs */
+       if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+               runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK;
+
+       spin_lock_irqsave(&chip->reg_lock, flags);
+       azx_dev->substream = substream;
+       azx_dev->running = 0;
+       spin_unlock_irqrestore(&chip->reg_lock, flags);
+
+       runtime->private_data = azx_dev;
+       snd_pcm_set_sync(substream);
+       mutex_unlock(&chip->open_mutex);
+       return 0;
+}
+
+static int azx_pcm_mmap(struct snd_pcm_substream *substream,
+                       struct vm_area_struct *area)
+{
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+       if (chip->ops->pcm_mmap_prepare)
+               chip->ops->pcm_mmap_prepare(substream, area);
+       return snd_pcm_lib_default_mmap(substream, area);
+}
+
+static struct snd_pcm_ops azx_pcm_ops = {
+       .open = azx_pcm_open,
+       .close = azx_pcm_close,
+       .ioctl = snd_pcm_lib_ioctl,
+       .hw_params = azx_pcm_hw_params,
+       .hw_free = azx_pcm_hw_free,
+       .prepare = azx_pcm_prepare,
+       .trigger = azx_pcm_trigger,
+       .pointer = azx_pcm_pointer,
+       .wall_clock =  azx_get_wallclock_tstamp,
+       .mmap = azx_pcm_mmap,
+       .page = snd_pcm_sgbuf_ops_page,
+};
+
+static void azx_pcm_free(struct snd_pcm *pcm)
+{
+       struct azx_pcm *apcm = pcm->private_data;
+       if (apcm) {
+               list_del(&apcm->list);
+               kfree(apcm);
+       }
+}
+
+#define MAX_PREALLOC_SIZE      (32 * 1024 * 1024)
+
+static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
+                                struct hda_pcm *cpcm)
+{
+       struct azx *chip = bus->private_data;
+       struct snd_pcm *pcm;
+       struct azx_pcm *apcm;
+       int pcm_dev = cpcm->device;
+       unsigned int size;
+       int s, err;
+
+       list_for_each_entry(apcm, &chip->pcm_list, list) {
+               if (apcm->pcm->device == pcm_dev) {
+                       dev_err(chip->card->dev, "PCM %d already exists\n",
+                               pcm_dev);
+                       return -EBUSY;
+               }
+       }
+       err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
+                         cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
+                         cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
+                         &pcm);
+       if (err < 0)
+               return err;
+       strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
+       apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
+       if (apcm == NULL)
+               return -ENOMEM;
+       apcm->chip = chip;
+       apcm->pcm = pcm;
+       apcm->codec = codec;
+       pcm->private_data = apcm;
+       pcm->private_free = azx_pcm_free;
+       if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
+               pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
+       list_add_tail(&apcm->list, &chip->pcm_list);
+       cpcm->pcm = pcm;
+       for (s = 0; s < 2; s++) {
+               apcm->hinfo[s] = &cpcm->stream[s];
+               if (cpcm->stream[s].substreams)
+                       snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
+       }
+       /* buffer pre-allocation */
+       size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
+       if (size > MAX_PREALLOC_SIZE)
+               size = MAX_PREALLOC_SIZE;
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
+                                             chip->card->dev,
+                                             size, MAX_PREALLOC_SIZE);
+       /* link to codec */
+       pcm->dev = &codec->dev;
+       return 0;
+}
+
+/*
+ * CORB / RIRB interface
+ */
+static int azx_alloc_cmd_io(struct azx *chip)
+{
+       int err;
+
+       /* single page (at least 4096 bytes) must suffice for both ringbuffes */
+       err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
+                                        PAGE_SIZE, &chip->rb);
+       if (err < 0)
+               dev_err(chip->card->dev, "cannot allocate CORB/RIRB\n");
+       return err;
+}
+EXPORT_SYMBOL_GPL(azx_alloc_cmd_io);
+
+static void azx_init_cmd_io(struct azx *chip)
+{
+       int timeout;
+
+       spin_lock_irq(&chip->reg_lock);
+       /* CORB set up */
+       chip->corb.addr = chip->rb.addr;
+       chip->corb.buf = (u32 *)chip->rb.area;
+       azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
+       azx_writel(chip, CORBUBASE, upper_32_bits(chip->corb.addr));
+
+       /* set the corb size to 256 entries (ULI requires explicitly) */
+       azx_writeb(chip, CORBSIZE, 0x02);
+       /* set the corb write pointer to 0 */
+       azx_writew(chip, CORBWP, 0);
+
+       /* reset the corb hw read pointer */
+       azx_writew(chip, CORBRP, ICH6_CORBRP_RST);
+       for (timeout = 1000; timeout > 0; timeout--) {
+               if ((azx_readw(chip, CORBRP) & ICH6_CORBRP_RST) == ICH6_CORBRP_RST)
+                       break;
+               udelay(1);
+       }
+       if (timeout <= 0)
+               dev_err(chip->card->dev, "CORB reset timeout#1, CORBRP = %d\n",
+                       azx_readw(chip, CORBRP));
+
+       azx_writew(chip, CORBRP, 0);
+       for (timeout = 1000; timeout > 0; timeout--) {
+               if (azx_readw(chip, CORBRP) == 0)
+                       break;
+               udelay(1);
+       }
+       if (timeout <= 0)
+               dev_err(chip->card->dev, "CORB reset timeout#2, CORBRP = %d\n",
+                       azx_readw(chip, CORBRP));
+
+       /* enable corb dma */
+       azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN);
+
+       /* RIRB set up */
+       chip->rirb.addr = chip->rb.addr + 2048;
+       chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
+       chip->rirb.wp = chip->rirb.rp = 0;
+       memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds));
+       azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
+       azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
+
+       /* set the rirb size to 256 entries (ULI requires explicitly) */
+       azx_writeb(chip, RIRBSIZE, 0x02);
+       /* reset the rirb hw write pointer */
+       azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST);
+       /* set N=1, get RIRB response interrupt for new entry */
+       if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
+               azx_writew(chip, RINTCNT, 0xc0);
+       else
+               azx_writew(chip, RINTCNT, 1);
+       /* enable rirb dma and response irq */
+       azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
+       spin_unlock_irq(&chip->reg_lock);
+}
+EXPORT_SYMBOL_GPL(azx_init_cmd_io);
+
+static void azx_free_cmd_io(struct azx *chip)
+{
+       spin_lock_irq(&chip->reg_lock);
+       /* disable ringbuffer DMAs */
+       azx_writeb(chip, RIRBCTL, 0);
+       azx_writeb(chip, CORBCTL, 0);
+       spin_unlock_irq(&chip->reg_lock);
+}
+EXPORT_SYMBOL_GPL(azx_free_cmd_io);
+
+static unsigned int azx_command_addr(u32 cmd)
+{
+       unsigned int addr = cmd >> 28;
+
+       if (addr >= AZX_MAX_CODECS) {
+               snd_BUG();
+               addr = 0;
+       }
+
+       return addr;
+}
+
+/* send a command */
+static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
+{
+       struct azx *chip = bus->private_data;
+       unsigned int addr = azx_command_addr(val);
+       unsigned int wp, rp;
+
+       spin_lock_irq(&chip->reg_lock);
+
+       /* add command to corb */
+       wp = azx_readw(chip, CORBWP);
+       if (wp == 0xffff) {
+               /* something wrong, controller likely turned to D3 */
+               spin_unlock_irq(&chip->reg_lock);
+               return -EIO;
+       }
+       wp++;
+       wp %= ICH6_MAX_CORB_ENTRIES;
+
+       rp = azx_readw(chip, CORBRP);
+       if (wp == rp) {
+               /* oops, it's full */
+               spin_unlock_irq(&chip->reg_lock);
+               return -EAGAIN;
+       }
+
+       chip->rirb.cmds[addr]++;
+       chip->corb.buf[wp] = cpu_to_le32(val);
+       azx_writew(chip, CORBWP, wp);
+
+       spin_unlock_irq(&chip->reg_lock);
+
+       return 0;
+}
+
+#define ICH6_RIRB_EX_UNSOL_EV  (1<<4)
+
+/* retrieve RIRB entry - called from interrupt handler */
+static void azx_update_rirb(struct azx *chip)
+{
+       unsigned int rp, wp;
+       unsigned int addr;
+       u32 res, res_ex;
+
+       wp = azx_readw(chip, RIRBWP);
+       if (wp == 0xffff) {
+               /* something wrong, controller likely turned to D3 */
+               return;
+       }
+
+       if (wp == chip->rirb.wp)
+               return;
+       chip->rirb.wp = wp;
+
+       while (chip->rirb.rp != wp) {
+               chip->rirb.rp++;
+               chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES;
+
+               rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */
+               res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]);
+               res = le32_to_cpu(chip->rirb.buf[rp]);
+               addr = res_ex & 0xf;
+               if ((addr >= AZX_MAX_CODECS) || !(chip->codec_mask & (1 << addr))) {
+                       dev_err(chip->card->dev, "spurious response %#x:%#x, rp = %d, wp = %d",
+                               res, res_ex,
+                               chip->rirb.rp, wp);
+                       snd_BUG();
+               }
+               else if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
+                       snd_hda_queue_unsol_event(chip->bus, res, res_ex);
+               else if (chip->rirb.cmds[addr]) {
+                       chip->rirb.res[addr] = res;
+                       smp_wmb();
+                       chip->rirb.cmds[addr]--;
+               } else if (printk_ratelimit()) {
+                       dev_err(chip->card->dev, "spurious response %#x:%#x, last cmd=%#08x\n",
+                               res, res_ex,
+                               chip->last_cmd[addr]);
+               }
+       }
+}
+
+/* receive a response */
+static unsigned int azx_rirb_get_response(struct hda_bus *bus,
+                                         unsigned int addr)
+{
+       struct azx *chip = bus->private_data;
+       unsigned long timeout;
+       unsigned long loopcounter;
+       int do_poll = 0;
+
+ again:
+       timeout = jiffies + msecs_to_jiffies(1000);
+
+       for (loopcounter = 0;; loopcounter++) {
+               if (chip->polling_mode || do_poll) {
+                       spin_lock_irq(&chip->reg_lock);
+                       azx_update_rirb(chip);
+                       spin_unlock_irq(&chip->reg_lock);
+               }
+               if (!chip->rirb.cmds[addr]) {
+                       smp_rmb();
+                       bus->rirb_error = 0;
+
+                       if (!do_poll)
+                               chip->poll_count = 0;
+                       return chip->rirb.res[addr]; /* the last value */
+               }
+               if (time_after(jiffies, timeout))
+                       break;
+               if (bus->needs_damn_long_delay || loopcounter > 3000)
+                       msleep(2); /* temporary workaround */
+               else {
+                       udelay(10);
+                       cond_resched();
+               }
+       }
+
+       if (!bus->no_response_fallback)
+               return -1;
+
+       if (!chip->polling_mode && chip->poll_count < 2) {
+               dev_dbg(chip->card->dev,
+                       "azx_get_response timeout, polling the codec once: last cmd=0x%08x\n",
+                       chip->last_cmd[addr]);
+               do_poll = 1;
+               chip->poll_count++;
+               goto again;
+       }
+
+
+       if (!chip->polling_mode) {
+               dev_warn(chip->card->dev,
+                        "azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n",
+                        chip->last_cmd[addr]);
+               chip->polling_mode = 1;
+               goto again;
+       }
+
+       if (chip->msi) {
+               dev_warn(chip->card->dev,
+                        "No response from codec, disabling MSI: last cmd=0x%08x\n",
+                        chip->last_cmd[addr]);
+               if (chip->ops->disable_msi_reset_irq(chip) &&
+                   chip->ops->disable_msi_reset_irq(chip) < 0) {
+                       bus->rirb_error = 1;
+                       return -1;
+               }
+               goto again;
+       }
+
+       if (chip->probing) {
+               /* If this critical timeout happens during the codec probing
+                * phase, this is likely an access to a non-existing codec
+                * slot.  Better to return an error and reset the system.
+                */
+               return -1;
+       }
+
+       /* a fatal communication error; need either to reset or to fallback
+        * to the single_cmd mode
+        */
+       bus->rirb_error = 1;
+       if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) {
+               bus->response_reset = 1;
+               return -1; /* give a chance to retry */
+       }
+
+       dev_err(chip->card->dev,
+               "azx_get_response timeout, switching to single_cmd mode: last cmd=0x%08x\n",
+               chip->last_cmd[addr]);
+       chip->single_cmd = 1;
+       bus->response_reset = 0;
+       /* release CORB/RIRB */
+       azx_free_cmd_io(chip);
+       /* disable unsolicited responses */
+       azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_UNSOL);
+       return -1;
+}
+
+/*
+ * Use the single immediate command instead of CORB/RIRB for simplicity
+ *
+ * Note: according to Intel, this is not preferred use.  The command was
+ *       intended for the BIOS only, and may get confused with unsolicited
+ *       responses.  So, we shouldn't use it for normal operation from the
+ *       driver.
+ *       I left the codes, however, for debugging/testing purposes.
+ */
+
+/* receive a response */
+static int azx_single_wait_for_response(struct azx *chip, unsigned int addr)
+{
+       int timeout = 50;
+
+       while (timeout--) {
+               /* check IRV busy bit */
+               if (azx_readw(chip, IRS) & ICH6_IRS_VALID) {
+                       /* reuse rirb.res as the response return value */
+                       chip->rirb.res[addr] = azx_readl(chip, IR);
+                       return 0;
+               }
+               udelay(1);
+       }
+       if (printk_ratelimit())
+               dev_dbg(chip->card->dev, "get_response timeout: IRS=0x%x\n",
+                       azx_readw(chip, IRS));
+       chip->rirb.res[addr] = -1;
+       return -EIO;
+}
+
+/* send a command */
+static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
+{
+       struct azx *chip = bus->private_data;
+       unsigned int addr = azx_command_addr(val);
+       int timeout = 50;
+
+       bus->rirb_error = 0;
+       while (timeout--) {
+               /* check ICB busy bit */
+               if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
+                       /* Clear IRV valid bit */
+                       azx_writew(chip, IRS, azx_readw(chip, IRS) |
+                                  ICH6_IRS_VALID);
+                       azx_writel(chip, IC, val);
+                       azx_writew(chip, IRS, azx_readw(chip, IRS) |
+                                  ICH6_IRS_BUSY);
+                       return azx_single_wait_for_response(chip, addr);
+               }
+               udelay(1);
+       }
+       if (printk_ratelimit())
+               dev_dbg(chip->card->dev,
+                       "send_cmd timeout: IRS=0x%x, val=0x%x\n",
+                       azx_readw(chip, IRS), val);
+       return -EIO;
+}
+
+/* receive a response */
+static unsigned int azx_single_get_response(struct hda_bus *bus,
+                                           unsigned int addr)
+{
+       struct azx *chip = bus->private_data;
+       return chip->rirb.res[addr];
+}
+
+/*
+ * The below are the main callbacks from hda_codec.
+ *
+ * They are just the skeleton to call sub-callbacks according to the
+ * current setting of chip->single_cmd.
+ */
+
+/* send a command */
+static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
+{
+       struct azx *chip = bus->private_data;
+
+       if (chip->disabled)
+               return 0;
+       chip->last_cmd[azx_command_addr(val)] = val;
+       if (chip->single_cmd)
+               return azx_single_send_cmd(bus, val);
+       else
+               return azx_corb_send_cmd(bus, val);
+}
+EXPORT_SYMBOL_GPL(azx_send_cmd);
+
+/* get a response */
+static unsigned int azx_get_response(struct hda_bus *bus,
+                                    unsigned int addr)
+{
+       struct azx *chip = bus->private_data;
+       if (chip->disabled)
+               return 0;
+       if (chip->single_cmd)
+               return azx_single_get_response(bus, addr);
+       else
+               return azx_rirb_get_response(bus, addr);
+}
+EXPORT_SYMBOL_GPL(azx_get_response);
+
+#ifdef CONFIG_SND_HDA_DSP_LOADER
+/*
+ * DSP loading code (e.g. for CA0132)
+ */
+
+/* use the first stream for loading DSP */
+static struct azx_dev *
+azx_get_dsp_loader_dev(struct azx *chip)
+{
+       return &chip->azx_dev[chip->playback_index_offset];
+}
+
+static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
+                               unsigned int byte_size,
+                               struct snd_dma_buffer *bufp)
+{
+       u32 *bdl;
+       struct azx *chip = bus->private_data;
+       struct azx_dev *azx_dev;
+       int err;
+
+       azx_dev = azx_get_dsp_loader_dev(chip);
+
+       dsp_lock(azx_dev);
+       spin_lock_irq(&chip->reg_lock);
+       if (azx_dev->running || azx_dev->locked) {
+               spin_unlock_irq(&chip->reg_lock);
+               err = -EBUSY;
+               goto unlock;
+       }
+       azx_dev->prepared = 0;
+       chip->saved_azx_dev = *azx_dev;
+       azx_dev->locked = 1;
+       spin_unlock_irq(&chip->reg_lock);
+
+       err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV_SG,
+                                        byte_size, bufp);
+       if (err < 0)
+               goto err_alloc;
+
+       azx_dev->bufsize = byte_size;
+       azx_dev->period_bytes = byte_size;
+       azx_dev->format_val = format;
+
+       azx_stream_reset(chip, azx_dev);
+
+       /* reset BDL address */
+       azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
+       azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
+
+       azx_dev->frags = 0;
+       bdl = (u32 *)azx_dev->bdl.area;
+       err = setup_bdle(chip, bufp, azx_dev, &bdl, 0, byte_size, 0);
+       if (err < 0)
+               goto error;
+
+       azx_setup_controller(chip, azx_dev);
+       dsp_unlock(azx_dev);
+       return azx_dev->stream_tag;
+
+ error:
+       chip->ops->dma_free_pages(chip, bufp);
+ err_alloc:
+       spin_lock_irq(&chip->reg_lock);
+       if (azx_dev->opened)
+               *azx_dev = chip->saved_azx_dev;
+       azx_dev->locked = 0;
+       spin_unlock_irq(&chip->reg_lock);
+ unlock:
+       dsp_unlock(azx_dev);
+       return err;
+}
+
+static void azx_load_dsp_trigger(struct hda_bus *bus, bool start)
+{
+       struct azx *chip = bus->private_data;
+       struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
+
+       if (start)
+               azx_stream_start(chip, azx_dev);
+       else
+               azx_stream_stop(chip, azx_dev);
+       azx_dev->running = start;
+}
+
+static void azx_load_dsp_cleanup(struct hda_bus *bus,
+                                struct snd_dma_buffer *dmab)
+{
+       struct azx *chip = bus->private_data;
+       struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
+
+       if (!dmab->area || !azx_dev->locked)
+               return;
+
+       dsp_lock(azx_dev);
+       /* reset BDL address */
+       azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
+       azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
+       azx_sd_writel(chip, azx_dev, SD_CTL, 0);
+       azx_dev->bufsize = 0;
+       azx_dev->period_bytes = 0;
+       azx_dev->format_val = 0;
+
+       chip->ops->dma_free_pages(chip, dmab);
+       dmab->area = NULL;
+
+       spin_lock_irq(&chip->reg_lock);
+       if (azx_dev->opened)
+               *azx_dev = chip->saved_azx_dev;
+       azx_dev->locked = 0;
+       spin_unlock_irq(&chip->reg_lock);
+       dsp_unlock(azx_dev);
+}
+#endif /* CONFIG_SND_HDA_DSP_LOADER */
+
+int azx_alloc_stream_pages(struct azx *chip)
+{
+       int i, err;
+       struct snd_card *card = chip->card;
+
+       for (i = 0; i < chip->num_streams; i++) {
+               dsp_lock_init(&chip->azx_dev[i]);
+               /* allocate memory for the BDL for each stream */
+               err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
+                                                BDL_SIZE,
+                                                &chip->azx_dev[i].bdl);
+               if (err < 0) {
+                       dev_err(card->dev, "cannot allocate BDL\n");
+                       return -ENOMEM;
+               }
+       }
+       /* allocate memory for the position buffer */
+       err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
+                                        chip->num_streams * 8, &chip->posbuf);
+       if (err < 0) {
+               dev_err(card->dev, "cannot allocate posbuf\n");
+               return -ENOMEM;
+       }
+
+       /* allocate CORB/RIRB */
+       err = azx_alloc_cmd_io(chip);
+       if (err < 0)
+               return err;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(azx_alloc_stream_pages);
+
+void azx_free_stream_pages(struct azx *chip)
+{
+       int i;
+       if (chip->azx_dev) {
+               for (i = 0; i < chip->num_streams; i++)
+                       if (chip->azx_dev[i].bdl.area)
+                               chip->ops->dma_free_pages(
+                                       chip, &chip->azx_dev[i].bdl);
+       }
+       if (chip->rb.area)
+               chip->ops->dma_free_pages(chip, &chip->rb);
+       if (chip->posbuf.area)
+               chip->ops->dma_free_pages(chip, &chip->posbuf);
+}
+EXPORT_SYMBOL_GPL(azx_free_stream_pages);
+
+/*
+ * Lowlevel interface
+ */
+
+/* enter link reset */
+void azx_enter_link_reset(struct azx *chip)
+{
+       unsigned long timeout;
+
+       /* reset controller */
+       azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET);
+
+       timeout = jiffies + msecs_to_jiffies(100);
+       while ((azx_readb(chip, GCTL) & ICH6_GCTL_RESET) &&
+                       time_before(jiffies, timeout))
+               usleep_range(500, 1000);
+}
+EXPORT_SYMBOL_GPL(azx_enter_link_reset);
+
+/* exit link reset */
+static void azx_exit_link_reset(struct azx *chip)
+{
+       unsigned long timeout;
+
+       azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET);
+
+       timeout = jiffies + msecs_to_jiffies(100);
+       while (!azx_readb(chip, GCTL) &&
+                       time_before(jiffies, timeout))
+               usleep_range(500, 1000);
+}
+
+/* reset codec link */
+static int azx_reset(struct azx *chip, int full_reset)
+{
+       if (!full_reset)
+               goto __skip;
+
+       /* clear STATESTS */
+       azx_writew(chip, STATESTS, STATESTS_INT_MASK);
+
+       /* reset controller */
+       azx_enter_link_reset(chip);
+
+       /* delay for >= 100us for codec PLL to settle per spec
+        * Rev 0.9 section 5.5.1
+        */
+       usleep_range(500, 1000);
+
+       /* Bring controller out of reset */
+       azx_exit_link_reset(chip);
+
+       /* Brent Chartrand said to wait >= 540us for codecs to initialize */
+       usleep_range(1000, 1200);
+
+      __skip:
+       /* check to see if controller is ready */
+       if (!azx_readb(chip, GCTL)) {
+               dev_dbg(chip->card->dev, "azx_reset: controller not ready!\n");
+               return -EBUSY;
+       }
+
+       /* Accept unsolicited responses */
+       if (!chip->single_cmd)
+               azx_writel(chip, GCTL, azx_readl(chip, GCTL) |
+                          ICH6_GCTL_UNSOL);
+
+       /* detect codecs */
+       if (!chip->codec_mask) {
+               chip->codec_mask = azx_readw(chip, STATESTS);
+               dev_dbg(chip->card->dev, "codec_mask = 0x%x\n",
+                       chip->codec_mask);
+       }
+
+       return 0;
+}
+
+/* enable interrupts */
+static void azx_int_enable(struct azx *chip)
+{
+       /* enable controller CIE and GIE */
+       azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) |
+                  ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN);
+}
+
+/* disable interrupts */
+static void azx_int_disable(struct azx *chip)
+{
+       int i;
+
+       /* disable interrupts in stream descriptor */
+       for (i = 0; i < chip->num_streams; i++) {
+               struct azx_dev *azx_dev = &chip->azx_dev[i];
+               azx_sd_writeb(chip, azx_dev, SD_CTL,
+                             azx_sd_readb(chip, azx_dev, SD_CTL) &
+                                       ~SD_INT_MASK);
+       }
+
+       /* disable SIE for all streams */
+       azx_writeb(chip, INTCTL, 0);
+
+       /* disable controller CIE and GIE */
+       azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) &
+                  ~(ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN));
+}
+
+/* clear interrupts */
+static void azx_int_clear(struct azx *chip)
+{
+       int i;
+
+       /* clear stream status */
+       for (i = 0; i < chip->num_streams; i++) {
+               struct azx_dev *azx_dev = &chip->azx_dev[i];
+               azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK);
+       }
+
+       /* clear STATESTS */
+       azx_writew(chip, STATESTS, STATESTS_INT_MASK);
+
+       /* clear rirb status */
+       azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
+
+       /* clear int status */
+       azx_writel(chip, INTSTS, ICH6_INT_CTRL_EN | ICH6_INT_ALL_STREAM);
+}
+
+/*
+ * reset and start the controller registers
+ */
+void azx_init_chip(struct azx *chip, int full_reset)
+{
+       if (chip->initialized)
+               return;
+
+       /* reset controller */
+       azx_reset(chip, full_reset);
+
+       /* initialize interrupts */
+       azx_int_clear(chip);
+       azx_int_enable(chip);
+
+       /* initialize the codec command I/O */
+       if (!chip->single_cmd)
+               azx_init_cmd_io(chip);
+
+       /* program the position buffer */
+       azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
+       azx_writel(chip, DPUBASE, upper_32_bits(chip->posbuf.addr));
+
+       chip->initialized = 1;
+}
+EXPORT_SYMBOL_GPL(azx_init_chip);
+
+void azx_stop_chip(struct azx *chip)
+{
+       if (!chip->initialized)
+               return;
+
+       /* disable interrupts */
+       azx_int_disable(chip);
+       azx_int_clear(chip);
+
+       /* disable CORB/RIRB */
+       azx_free_cmd_io(chip);
+
+       /* disable position buffer */
+       azx_writel(chip, DPLBASE, 0);
+       azx_writel(chip, DPUBASE, 0);
+
+       chip->initialized = 0;
+}
+EXPORT_SYMBOL_GPL(azx_stop_chip);
+
+/*
+ * interrupt handler
+ */
+irqreturn_t azx_interrupt(int irq, void *dev_id)
+{
+       struct azx *chip = dev_id;
+       struct azx_dev *azx_dev;
+       u32 status;
+       u8 sd_status;
+       int i;
+
+#ifdef CONFIG_PM_RUNTIME
+       if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME)
+               if (chip->card->dev->power.runtime_status != RPM_ACTIVE)
+                       return IRQ_NONE;
+#endif
+
+       spin_lock(&chip->reg_lock);
+
+       if (chip->disabled) {
+               spin_unlock(&chip->reg_lock);
+               return IRQ_NONE;
+       }
+
+       status = azx_readl(chip, INTSTS);
+       if (status == 0 || status == 0xffffffff) {
+               spin_unlock(&chip->reg_lock);
+               return IRQ_NONE;
+       }
+
+       for (i = 0; i < chip->num_streams; i++) {
+               azx_dev = &chip->azx_dev[i];
+               if (status & azx_dev->sd_int_sta_mask) {
+                       sd_status = azx_sd_readb(chip, azx_dev, SD_STS);
+                       azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK);
+                       if (!azx_dev->substream || !azx_dev->running ||
+                           !(sd_status & SD_INT_COMPLETE))
+                               continue;
+                       /* check whether this IRQ is really acceptable */
+                       if (!chip->ops->position_check ||
+                           chip->ops->position_check(chip, azx_dev)) {
+                               spin_unlock(&chip->reg_lock);
+                               snd_pcm_period_elapsed(azx_dev->substream);
+                               spin_lock(&chip->reg_lock);
+                       }
+               }
+       }
+
+       /* clear rirb int */
+       status = azx_readb(chip, RIRBSTS);
+       if (status & RIRB_INT_MASK) {
+               if (status & RIRB_INT_RESPONSE) {
+                       if (chip->driver_caps & AZX_DCAPS_RIRB_PRE_DELAY)
+                               udelay(80);
+                       azx_update_rirb(chip);
+               }
+               azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
+       }
+
+       spin_unlock(&chip->reg_lock);
+
+       return IRQ_HANDLED;
+}
+EXPORT_SYMBOL_GPL(azx_interrupt);
+
+/*
+ * Codec initerface
+ */
+
+/*
+ * Probe the given codec address
+ */
+static int probe_codec(struct azx *chip, int addr)
+{
+       unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
+               (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
+       unsigned int res;
+
+       mutex_lock(&chip->bus->cmd_mutex);
+       chip->probing = 1;
+       azx_send_cmd(chip->bus, cmd);
+       res = azx_get_response(chip->bus, addr);
+       chip->probing = 0;
+       mutex_unlock(&chip->bus->cmd_mutex);
+       if (res == -1)
+               return -EIO;
+       dev_dbg(chip->card->dev, "codec #%d probed OK\n", addr);
+       return 0;
+}
+
+static void azx_bus_reset(struct hda_bus *bus)
+{
+       struct azx *chip = bus->private_data;
+
+       bus->in_reset = 1;
+       azx_stop_chip(chip);
+       azx_init_chip(chip, 1);
+#ifdef CONFIG_PM
+       if (chip->initialized) {
+               struct azx_pcm *p;
+               list_for_each_entry(p, &chip->pcm_list, list)
+                       snd_pcm_suspend_all(p->pcm);
+               snd_hda_suspend(chip->bus);
+               snd_hda_resume(chip->bus);
+       }
+#endif
+       bus->in_reset = 0;
+}
+
+#ifdef CONFIG_PM
+/* power-up/down the controller */
+static void azx_power_notify(struct hda_bus *bus, bool power_up)
+{
+       struct azx *chip = bus->private_data;
+
+       if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
+               return;
+
+       if (power_up)
+               pm_runtime_get_sync(chip->card->dev);
+       else
+               pm_runtime_put_sync(chip->card->dev);
+}
+#endif
+
+static int get_jackpoll_interval(struct azx *chip)
+{
+       int i;
+       unsigned int j;
+
+       if (!chip->jackpoll_ms)
+               return 0;
+
+       i = chip->jackpoll_ms[chip->dev_index];
+       if (i == 0)
+               return 0;
+       if (i < 50 || i > 60000)
+               j = 0;
+       else
+               j = msecs_to_jiffies(i);
+       if (j == 0)
+               dev_warn(chip->card->dev,
+                        "jackpoll_ms value out of range: %d\n", i);
+       return j;
+}
+
+/* Codec initialization */
+int azx_codec_create(struct azx *chip, const char *model,
+                    unsigned int max_slots,
+                    int *power_save_to)
+{
+       struct hda_bus_template bus_temp;
+       int c, codecs, err;
+
+       memset(&bus_temp, 0, sizeof(bus_temp));
+       bus_temp.private_data = chip;
+       bus_temp.modelname = model;
+       bus_temp.pci = chip->pci;
+       bus_temp.ops.command = azx_send_cmd;
+       bus_temp.ops.get_response = azx_get_response;
+       bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
+       bus_temp.ops.bus_reset = azx_bus_reset;
+#ifdef CONFIG_PM
+       bus_temp.power_save = power_save_to;
+       bus_temp.ops.pm_notify = azx_power_notify;
+#endif
+#ifdef CONFIG_SND_HDA_DSP_LOADER
+       bus_temp.ops.load_dsp_prepare = azx_load_dsp_prepare;
+       bus_temp.ops.load_dsp_trigger = azx_load_dsp_trigger;
+       bus_temp.ops.load_dsp_cleanup = azx_load_dsp_cleanup;
+#endif
+
+       err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
+       if (err < 0)
+               return err;
+
+       if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
+               dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
+               chip->bus->needs_damn_long_delay = 1;
+       }
+
+       codecs = 0;
+       if (!max_slots)
+               max_slots = AZX_DEFAULT_CODECS;
+
+       /* First try to probe all given codec slots */
+       for (c = 0; c < max_slots; c++) {
+               if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
+                       if (probe_codec(chip, c) < 0) {
+                               /* Some BIOSen give you wrong codec addresses
+                                * that don't exist
+                                */
+                               dev_warn(chip->card->dev,
+                                        "Codec #%d probe error; disabling it...\n", c);
+                               chip->codec_mask &= ~(1 << c);
+                               /* More badly, accessing to a non-existing
+                                * codec often screws up the controller chip,
+                                * and disturbs the further communications.
+                                * Thus if an error occurs during probing,
+                                * better to reset the controller chip to
+                                * get back to the sanity state.
+                                */
+                               azx_stop_chip(chip);
+                               azx_init_chip(chip, 1);
+                       }
+               }
+       }
+
+       /* AMD chipsets often cause the communication stalls upon certain
+        * sequence like the pin-detection.  It seems that forcing the synced
+        * access works around the stall.  Grrr...
+        */
+       if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
+               dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
+               chip->bus->sync_write = 1;
+               chip->bus->allow_bus_reset = 1;
+       }
+
+       /* Then create codec instances */
+       for (c = 0; c < max_slots; c++) {
+               if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
+                       struct hda_codec *codec;
+                       err = snd_hda_codec_new(chip->bus, c, &codec);
+                       if (err < 0)
+                               continue;
+                       codec->jackpoll_interval = get_jackpoll_interval(chip);
+                       codec->beep_mode = chip->beep_mode;
+                       codecs++;
+               }
+       }
+       if (!codecs) {
+               dev_err(chip->card->dev, "no codecs initialized\n");
+               return -ENXIO;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(azx_codec_create);
+
+/* configure each codec instance */
+int azx_codec_configure(struct azx *chip)
+{
+       struct hda_codec *codec;
+       list_for_each_entry(codec, &chip->bus->codec_list, list) {
+               snd_hda_codec_configure(codec);
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(azx_codec_configure);
+
+/* mixer creation - all stuff is implemented in hda module */
+int azx_mixer_create(struct azx *chip)
+{
+       return snd_hda_build_controls(chip->bus);
+}
+EXPORT_SYMBOL_GPL(azx_mixer_create);
+
+
+/* initialize SD streams */
+int azx_init_stream(struct azx *chip)
+{
+       int i;
+
+       /* initialize each stream (aka device)
+        * assign the starting bdl address to each stream (device)
+        * and initialize
+        */
+       for (i = 0; i < chip->num_streams; i++) {
+               struct azx_dev *azx_dev = &chip->azx_dev[i];
+               azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
+               /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
+               azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
+               /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
+               azx_dev->sd_int_sta_mask = 1 << i;
+               /* stream tag: must be non-zero and unique */
+               azx_dev->index = i;
+               azx_dev->stream_tag = i + 1;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(azx_init_stream);
+
+MODULE_LICENSE("GPL");
+MODULE_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 (file)
index 0000000..1d2e3be
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  Common functionality for the alsa driver code base for HD Audio.
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ */
+
+#ifndef __SOUND_HDA_CONTROLLER_H
+#define __SOUND_HDA_CONTROLLER_H
+
+#include <sound/core.h>
+#include <sound/initval.h>
+#include "hda_codec.h"
+#include "hda_priv.h"
+
+/* PCM setup */
+static inline struct azx_dev *get_azx_dev(struct snd_pcm_substream *substream)
+{
+       return substream->runtime->private_data;
+}
+unsigned int azx_get_position(struct azx *chip,
+                             struct azx_dev *azx_dev,
+                             bool with_check);
+
+/* Stream control. */
+void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev);
+
+/* Allocation functions. */
+int azx_alloc_stream_pages(struct azx *chip);
+void azx_free_stream_pages(struct azx *chip);
+
+/* Low level azx interface */
+void azx_init_chip(struct azx *chip, int full_reset);
+void azx_stop_chip(struct azx *chip);
+void azx_enter_link_reset(struct azx *chip);
+irqreturn_t azx_interrupt(int irq, void *dev_id);
+
+/* Codec interface */
+int azx_codec_create(struct azx *chip, const char *model,
+                    unsigned int max_slots,
+                    int *power_save_to);
+int azx_codec_configure(struct azx *chip);
+int azx_mixer_create(struct azx *chip);
+int azx_init_stream(struct azx *chip);
+
+#endif /* __SOUND_HDA_CONTROLLER_H */
index 79ca80f6c77ada6d182a86b9880f3ce9125726f5..46690a7f48f6eef0b8e60e530c0991938695c7ca 100644 (file)
@@ -153,7 +153,7 @@ static unsigned int hdmi_get_eld_data(struct hda_codec *codec, hda_nid_t nid,
        val = snd_hda_codec_read(codec, nid, 0,
                                        AC_VERB_GET_HDMI_ELDD, byte_index);
 #ifdef BE_PARANOID
-       printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val);
+       codec_info(codec, "HDMI: ELD data byte %d: 0x%x\n", byte_index, val);
 #endif
        return val;
 }
@@ -332,11 +332,11 @@ int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
        size = snd_hdmi_get_eld_size(codec, nid);
        if (size == 0) {
                /* wfg: workaround for ASUS P5E-VM HDMI board */
-               snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n");
+               codec_info(codec, "HDMI: ELD buf size is 0, force 128\n");
                size = 128;
        }
        if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) {
-               snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size);
+               codec_info(codec, "HDMI: invalid ELD buf size %d\n", size);
                return -ERANGE;
        }
 
@@ -348,8 +348,7 @@ int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
                 * Just abort. The caller will repoll after a while.
                 */
                if (!(val & AC_ELDD_ELD_VALID)) {
-                       snd_printd(KERN_INFO
-                                 "HDMI: invalid ELD data byte %d\n", i);
+                       codec_info(codec, "HDMI: invalid ELD data byte %d\n", i);
                        ret = -EINVAL;
                        goto error;
                }
@@ -361,7 +360,7 @@ int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
                 * correctly writes ELD content before setting ELD_valid bit.
                 */
                if (!val && !i) {
-                       snd_printdd(KERN_INFO "HDMI: 0 ELD data\n");
+                       codec_dbg(codec, "HDMI: 0 ELD data\n");
                        ret = -EINVAL;
                        goto error;
                }
@@ -681,7 +680,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
        spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0);
 
        if (spkalloc <= 0) {
-               snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n");
+               codec_info(codec, "HDMI ATI/AMD: no speaker allocation for ELD\n");
                return -EINVAL;
        }
 
@@ -722,7 +721,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
                sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
 
                if (sink_desc_len > ELD_MAX_MNL) {
-                       snd_printd(KERN_INFO "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n",
+                       codec_info(codec, "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n",
                                   sink_desc_len);
                        sink_desc_len = ELD_MAX_MNL;
                }
@@ -764,7 +763,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
        }
 
        if (pos == ELD_FIXED_BYTES + sink_desc_len) {
-               snd_printd(KERN_INFO "HDMI ATI/AMD: no audio descriptors for ELD\n");
+               codec_info(codec, "HDMI ATI/AMD: no audio descriptors for ELD\n");
                return -EINVAL;
        }
 
index d9a09bdd09db656891aa51f910753b686dc79964..16133881e967074aa906c340ee9d87bd593e6983 100644 (file)
@@ -79,7 +79,7 @@ static void free_kctls(struct hda_gen_spec *spec)
        snd_array_free(&spec->kctls);
 }
 
-void snd_hda_gen_spec_free(struct hda_gen_spec *spec)
+static void snd_hda_gen_spec_free(struct hda_gen_spec *spec)
 {
        if (!spec)
                return;
@@ -87,7 +87,6 @@ void snd_hda_gen_spec_free(struct hda_gen_spec *spec)
        snd_array_free(&spec->paths);
        snd_array_free(&spec->loopback_list);
 }
-EXPORT_SYMBOL_GPL(snd_hda_gen_spec_free);
 
 /*
  * store user hints
@@ -347,7 +346,8 @@ static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid,
        return is_ctl_used(codec, val, type);
 }
 
-static void print_nid_path(const char *pfx, struct nid_path *path)
+static void print_nid_path(struct hda_codec *codec,
+                          const char *pfx, struct nid_path *path)
 {
        char buf[40];
        int i;
@@ -359,7 +359,7 @@ static void print_nid_path(const char *pfx, struct nid_path *path)
                sprintf(tmp, ":%02x", path->path[i]);
                strlcat(buf, tmp, sizeof(buf));
        }
-       snd_printdd("%s path: depth=%d %s\n", pfx, path->depth, buf);
+       codec_dbg(codec, "%s path: depth=%d %s\n", pfx, path->depth, buf);
 }
 
 /* called recursively */
@@ -762,7 +762,7 @@ void snd_hda_activate_path(struct hda_codec *codec, struct nid_path *path,
                                                    AC_PWRST_D0);
                }
                if (enable && path->multi[i])
-                       snd_hda_codec_write_cache(codec, nid, 0,
+                       snd_hda_codec_update_cache(codec, nid, 0,
                                            AC_VERB_SET_CONNECT_SEL,
                                            path->idx[i]);
                if (has_amp_in(codec, path, i))
@@ -1261,7 +1261,7 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
                        dac = dacs[i] = 0;
                        badness += bad->no_dac;
                } else {
-                       /* print_nid_path("output", path); */
+                       /* print_nid_path(codec, "output", path); */
                        path->active = true;
                        path_idx[i] = snd_hda_get_path_idx(codec, path);
                        badness += assign_out_path_ctls(codec, path);
@@ -1388,7 +1388,7 @@ static int fill_multi_ios(struct hda_codec *codec,
                                badness++;
                                continue;
                        }
-                       /* print_nid_path("multiio", path); */
+                       /* print_nid_path(codec, "multiio", path); */
                        spec->multi_io[spec->multi_ios].pin = nid;
                        spec->multi_io[spec->multi_ios].dac = dac;
                        spec->out_paths[cfg->line_outs + spec->multi_ios] =
@@ -1445,7 +1445,7 @@ static bool map_singles(struct hda_codec *codec, int outs,
                if (path) {
                        dacs[i] = dac;
                        found = true;
-                       /* print_nid_path("output", path); */
+                       /* print_nid_path(codec, "output", path); */
                        path->active = true;
                        path_idx[i] = snd_hda_get_path_idx(codec, path);
                }
@@ -1483,7 +1483,7 @@ static int check_aamix_out_path(struct hda_codec *codec, int path_idx)
        }
        if (!path)
                return 0;
-       /* print_nid_path("output-aamix", path); */
+       /* print_nid_path(codec, "output-aamix", path); */
        path->active = false; /* unused as default */
        return snd_hda_get_path_idx(codec, path);
 }
@@ -1700,7 +1700,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
 #define DEBUG_BADNESS
 
 #ifdef DEBUG_BADNESS
-#define debug_badness  snd_printdd
+#define debug_badness(fmt, args...)    codec_dbg(codec, fmt, ##args)
 #else
 #define debug_badness(...)
 #endif
@@ -1713,7 +1713,7 @@ static inline void print_nid_path_idx(struct hda_codec *codec,
 
        path = snd_hda_get_path_from_idx(codec, idx);
        if (path)
-               print_nid_path(pfx, path);
+               print_nid_path(codec, pfx, path);
 }
 
 static void debug_show_configs(struct hda_codec *codec,
@@ -1781,7 +1781,7 @@ static void fill_all_dac_nids(struct hda_codec *codec)
                if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT)
                        continue;
                if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) {
-                       snd_printk(KERN_ERR "hda: Too many DACs!\n");
+                       codec_err(codec, "Too many DACs!\n");
                        break;
                }
                spec->all_dacs[spec->num_all_dacs++] = nid;
@@ -2430,7 +2430,7 @@ static int create_hp_mic(struct hda_codec *codec)
        spec->hp_mic_pin = nid;
        /* we can't handle auto-mic together with HP-mic */
        spec->suppress_auto_mic = 1;
-       snd_printdd("hda-codec: Enable shared I/O jack on NID 0x%x\n", nid);
+       codec_dbg(codec, "Enable shared I/O jack on NID 0x%x\n", nid);
        return 0;
 }
 
@@ -2884,7 +2884,7 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
        path = snd_hda_add_new_path(codec, pin, mix_nid, 0);
        if (!path)
                return -EINVAL;
-       print_nid_path("loopback", path);
+       print_nid_path(codec, "loopback", path);
        spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path);
 
        idx = path->idx[path->depth - 1];
@@ -2912,7 +2912,7 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
                path = snd_hda_add_new_path(codec, spec->mixer_nid,
                                            spec->mixer_merge_nid, 0);
                if (path) {
-                       print_nid_path("loopback-merge", path);
+                       print_nid_path(codec, "loopback-merge", path);
                        path->active = true;
                        spec->loopback_merge_path =
                                snd_hda_get_path_idx(codec, path);
@@ -2991,7 +2991,7 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
                        }
                }
 
-               snd_printdd("hda-codec: enabling ADC switching\n");
+               codec_dbg(codec, "enabling ADC switching\n");
                spec->dyn_adc_switch = 1;
        } else if (nums != spec->num_adc_nids) {
                /* shrink the invalid adcs and input paths */
@@ -3015,7 +3015,7 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
 
        if (imux->num_items == 1 ||
            (imux->num_items == 2 && spec->hp_mic)) {
-               snd_printdd("hda-codec: reducing to a single ADC\n");
+               codec_dbg(codec, "reducing to a single ADC\n");
                spec->num_adc_nids = 1; /* reduce to a single ADC */
        }
 
@@ -3046,7 +3046,7 @@ static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin,
                path = snd_hda_add_new_path(codec, pin, adc, anchor);
                if (!path)
                        continue;
-               print_nid_path("input", path);
+               print_nid_path(codec, "input", path);
                spec->input_paths[imux_idx][c] =
                        snd_hda_get_path_idx(codec, path);
 
@@ -3712,7 +3712,7 @@ static void parse_digital(struct hda_codec *codec)
                path = snd_hda_add_new_path(codec, dig_nid, pin, 0);
                if (!path)
                        continue;
-               print_nid_path("digout", path);
+               print_nid_path(codec, "digout", path);
                path->active = true;
                spec->digout_paths[i] = snd_hda_get_path_idx(codec, path);
                set_pin_target(codec, pin, PIN_OUT, false);
@@ -3739,7 +3739,7 @@ static void parse_digital(struct hda_codec *codec)
                                continue;
                        path = snd_hda_add_new_path(codec, pin, dig_nid, 0);
                        if (path) {
-                               print_nid_path("digin", path);
+                               print_nid_path(codec, "digin", path);
                                path->active = true;
                                spec->dig_in_nid = dig_nid;
                                spec->digin_path = snd_hda_get_path_idx(codec, path);
@@ -4170,8 +4170,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
                hda_nid_t nid = cfg->hp_pins[i];
                if (!is_jack_detectable(codec, nid))
                        continue;
-               snd_printdd("hda-codec: Enable HP auto-muting on NID 0x%x\n",
-                           nid);
+               codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid);
                snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT,
                                                    call_hp_automute);
                spec->detect_hp = 1;
@@ -4183,7 +4182,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
                                hda_nid_t nid = cfg->line_out_pins[i];
                                if (!is_jack_detectable(codec, nid))
                                        continue;
-                               snd_printdd("hda-codec: Enable Line-Out auto-muting on NID 0x%x\n", nid);
+                               codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid);
                                snd_hda_jack_detect_enable_callback(codec, nid,
                                                                    HDA_GEN_FRONT_EVENT,
                                                                    call_line_automute);
@@ -4303,7 +4302,7 @@ static int check_auto_mic_availability(struct hda_codec *codec)
        spec->auto_mic = 1;
        spec->num_adc_nids = 1;
        spec->cur_mux[0] = spec->am_entry[0].idx;
-       snd_printdd("hda-codec: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
+       codec_dbg(codec, "Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
                    spec->am_entry[0].pin,
                    spec->am_entry[1].pin,
                    spec->am_entry[2].pin);
@@ -5350,7 +5349,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_init);
  */
 void snd_hda_gen_free(struct hda_codec *codec)
 {
-       snd_hda_detach_beep_device(codec);
+       snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
        snd_hda_gen_spec_free(codec->spec);
        kfree(codec->spec);
        codec->spec = NULL;
index c908afbe4d94662fcaa92cf4009efc64b2114680..bb2dea743986b365813a9e55ed2342ecd4f25c07 100644 (file)
@@ -297,7 +297,6 @@ struct hda_gen_spec {
 };
 
 int snd_hda_gen_spec_init(struct hda_gen_spec *spec);
-void snd_hda_gen_spec_free(struct hda_gen_spec *spec);
 
 int snd_hda_gen_init(struct hda_codec *codec);
 void snd_hda_gen_free(struct hda_codec *codec);
index 72d8389fb399c1802d645686ae0dbc2ee379a2b4..014a7849e8fdbf2a2f18c55e281f7499561f89db 100644 (file)
 
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/compat.h>
-#include <linux/mutex.h>
-#include <linux/ctype.h>
-#include <linux/string.h>
-#include <linux/export.h>
 #include <sound/core.h>
 #include "hda_codec.h"
 #include "hda_local.h"
 #include <sound/hda_hwdep.h>
 #include <sound/minors.h>
 
-/* hint string pair */
-struct hda_hint {
-       const char *key;
-       const char *val;        /* contained in the same alloc as key */
-};
-
 /*
  * write/read an out-of-bound verb
  */
@@ -105,26 +94,6 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
        return 0;
 }
 
-static void clear_hwdep_elements(struct hda_codec *codec)
-{
-       int i;
-
-       /* clear init verbs */
-       snd_array_free(&codec->init_verbs);
-       /* clear hints */
-       for (i = 0; i < codec->hints.used; i++) {
-               struct hda_hint *hint = snd_array_elem(&codec->hints, i);
-               kfree(hint->key); /* we don't need to free hint->val */
-       }
-       snd_array_free(&codec->hints);
-       snd_array_free(&codec->user_pins);
-}
-
-static void hwdep_free(struct snd_hwdep *hwdep)
-{
-       clear_hwdep_elements(hwdep->private_data);
-}
-
 int snd_hda_create_hwdep(struct hda_codec *codec)
 {
        char hwname[16];
@@ -139,8 +108,8 @@ int snd_hda_create_hwdep(struct hda_codec *codec)
        sprintf(hwdep->name, "HDA Codec %d", codec->addr);
        hwdep->iface = SNDRV_HWDEP_IFACE_HDA;
        hwdep->private_data = codec;
-       hwdep->private_free = hwdep_free;
        hwdep->exclusive = 1;
+       hwdep->groups = snd_hda_dev_attr_groups;
 
        hwdep->ops.open = hda_hwdep_open;
        hwdep->ops.ioctl = hda_hwdep_ioctl;
@@ -148,740 +117,8 @@ int snd_hda_create_hwdep(struct hda_codec *codec)
        hwdep->ops.ioctl_compat = hda_hwdep_ioctl_compat;
 #endif
 
-       mutex_init(&codec->user_mutex);
-       snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
-       snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
-       snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
-
-       return 0;
-}
-
-#ifdef CONFIG_PM
-static ssize_t power_on_acct_show(struct device *dev,
-                                 struct device_attribute *attr,
-                                 char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       snd_hda_update_power_acct(codec);
-       return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
-}
-
-static ssize_t power_off_acct_show(struct device *dev,
-                                  struct device_attribute *attr,
-                                  char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       snd_hda_update_power_acct(codec);
-       return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
-}
-
-static struct device_attribute power_attrs[] = {
-       __ATTR_RO(power_on_acct),
-       __ATTR_RO(power_off_acct),
-};
-
-int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec)
-{
-       struct snd_hwdep *hwdep = codec->hwdep;
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(power_attrs); i++)
-               snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card,
-                                         hwdep->device, &power_attrs[i]);
-       return 0;
-}
-#endif /* CONFIG_PM */
-
-#ifdef CONFIG_SND_HDA_RECONFIG
-
-/*
- * sysfs interface
- */
-
-static int clear_codec(struct hda_codec *codec)
-{
-       int err;
-
-       err = snd_hda_codec_reset(codec);
-       if (err < 0) {
-               snd_printk(KERN_ERR "The codec is being used, can't free.\n");
-               return err;
-       }
-       clear_hwdep_elements(codec);
-       return 0;
-}
-
-static int reconfig_codec(struct hda_codec *codec)
-{
-       int err;
-
-       snd_hda_power_up(codec);
-       snd_printk(KERN_INFO "hda-codec: reconfiguring\n");
-       err = snd_hda_codec_reset(codec);
-       if (err < 0) {
-               snd_printk(KERN_ERR
-                          "The codec is being used, can't reconfigure.\n");
-               goto error;
-       }
-       err = snd_hda_codec_configure(codec);
-       if (err < 0)
-               goto error;
-       /* rebuild PCMs */
-       err = snd_hda_codec_build_pcms(codec);
-       if (err < 0)
-               goto error;
-       /* rebuild mixers */
-       err = snd_hda_codec_build_controls(codec);
-       if (err < 0)
-               goto error;
-       err = snd_card_register(codec->bus->card);
- error:
-       snd_hda_power_down(codec);
-       return err;
-}
-
-/*
- * allocate a string at most len chars, and remove the trailing EOL
- */
-static char *kstrndup_noeol(const char *src, size_t len)
-{
-       char *s = kstrndup(src, len, GFP_KERNEL);
-       char *p;
-       if (!s)
-               return NULL;
-       p = strchr(s, '\n');
-       if (p)
-               *p = 0;
-       return s;
-}
-
-#define CODEC_INFO_SHOW(type)                                  \
-static ssize_t type##_show(struct device *dev,                 \
-                          struct device_attribute *attr,       \
-                          char *buf)                           \
-{                                                              \
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);         \
-       struct hda_codec *codec = hwdep->private_data;          \
-       return sprintf(buf, "0x%x\n", codec->type);             \
-}
-
-#define CODEC_INFO_STR_SHOW(type)                              \
-static ssize_t type##_show(struct device *dev,                 \
-                            struct device_attribute *attr,     \
-                                       char *buf)              \
-{                                                              \
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);         \
-       struct hda_codec *codec = hwdep->private_data;          \
-       return sprintf(buf, "%s\n",                             \
-                      codec->type ? codec->type : "");         \
-}
-
-CODEC_INFO_SHOW(vendor_id);
-CODEC_INFO_SHOW(subsystem_id);
-CODEC_INFO_SHOW(revision_id);
-CODEC_INFO_SHOW(afg);
-CODEC_INFO_SHOW(mfg);
-CODEC_INFO_STR_SHOW(vendor_name);
-CODEC_INFO_STR_SHOW(chip_name);
-CODEC_INFO_STR_SHOW(modelname);
-
-#define CODEC_INFO_STORE(type)                                 \
-static ssize_t type##_store(struct device *dev,                        \
-                           struct device_attribute *attr,      \
-                           const char *buf, size_t count)      \
-{                                                              \
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);         \
-       struct hda_codec *codec = hwdep->private_data;          \
-       unsigned long val;                                      \
-       int err = kstrtoul(buf, 0, &val);                       \
-       if (err < 0)                                            \
-               return err;                                     \
-       codec->type = val;                                      \
-       return count;                                           \
-}
-
-#define CODEC_INFO_STR_STORE(type)                             \
-static ssize_t type##_store(struct device *dev,                        \
-                           struct device_attribute *attr,      \
-                           const char *buf, size_t count)      \
-{                                                              \
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);         \
-       struct hda_codec *codec = hwdep->private_data;          \
-       char *s = kstrndup_noeol(buf, 64);                      \
-       if (!s)                                                 \
-               return -ENOMEM;                                 \
-       kfree(codec->type);                                     \
-       codec->type = s;                                        \
-       return count;                                           \
-}
-
-CODEC_INFO_STORE(vendor_id);
-CODEC_INFO_STORE(subsystem_id);
-CODEC_INFO_STORE(revision_id);
-CODEC_INFO_STR_STORE(vendor_name);
-CODEC_INFO_STR_STORE(chip_name);
-CODEC_INFO_STR_STORE(modelname);
-
-#define CODEC_ACTION_STORE(type)                               \
-static ssize_t type##_store(struct device *dev,                        \
-                           struct device_attribute *attr,      \
-                           const char *buf, size_t count)      \
-{                                                              \
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);         \
-       struct hda_codec *codec = hwdep->private_data;          \
-       int err = 0;                                            \
-       if (*buf)                                               \
-               err = type##_codec(codec);                      \
-       return err < 0 ? err : count;                           \
-}
-
-CODEC_ACTION_STORE(reconfig);
-CODEC_ACTION_STORE(clear);
-
-static ssize_t init_verbs_show(struct device *dev,
-                              struct device_attribute *attr,
-                              char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       int i, len = 0;
-       mutex_lock(&codec->user_mutex);
-       for (i = 0; i < codec->init_verbs.used; i++) {
-               struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
-               len += snprintf(buf + len, PAGE_SIZE - len,
-                               "0x%02x 0x%03x 0x%04x\n",
-                               v->nid, v->verb, v->param);
-       }
-       mutex_unlock(&codec->user_mutex);
-       return len;
-}
-
-static int parse_init_verbs(struct hda_codec *codec, const char *buf)
-{
-       struct hda_verb *v;
-       int nid, verb, param;
-
-       if (sscanf(buf, "%i %i %i", &nid, &verb, &param) != 3)
-               return -EINVAL;
-       if (!nid || !verb)
-               return -EINVAL;
-       mutex_lock(&codec->user_mutex);
-       v = snd_array_new(&codec->init_verbs);
-       if (!v) {
-               mutex_unlock(&codec->user_mutex);
-               return -ENOMEM;
-       }
-       v->nid = nid;
-       v->verb = verb;
-       v->param = param;
-       mutex_unlock(&codec->user_mutex);
-       return 0;
-}
-
-static ssize_t init_verbs_store(struct device *dev,
-                               struct device_attribute *attr,
-                               const char *buf, size_t count)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       int err = parse_init_verbs(codec, buf);
-       if (err < 0)
-               return err;
-       return count;
-}
-
-static ssize_t hints_show(struct device *dev,
-                         struct device_attribute *attr,
-                         char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       int i, len = 0;
-       mutex_lock(&codec->user_mutex);
-       for (i = 0; i < codec->hints.used; i++) {
-               struct hda_hint *hint = snd_array_elem(&codec->hints, i);
-               len += snprintf(buf + len, PAGE_SIZE - len,
-                               "%s = %s\n", hint->key, hint->val);
-       }
-       mutex_unlock(&codec->user_mutex);
-       return len;
-}
-
-static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
-{
-       int i;
-
-       for (i = 0; i < codec->hints.used; i++) {
-               struct hda_hint *hint = snd_array_elem(&codec->hints, i);
-               if (!strcmp(hint->key, key))
-                       return hint;
-       }
-       return NULL;
-}
-
-static void remove_trail_spaces(char *str)
-{
-       char *p;
-       if (!*str)
-               return;
-       p = str + strlen(str) - 1;
-       for (; isspace(*p); p--) {
-               *p = 0;
-               if (p == str)
-                       return;
-       }
-}
-
-#define MAX_HINTS      1024
-
-static int parse_hints(struct hda_codec *codec, const char *buf)
-{
-       char *key, *val;
-       struct hda_hint *hint;
-       int err = 0;
-
-       buf = skip_spaces(buf);
-       if (!*buf || *buf == '#' || *buf == '\n')
-               return 0;
-       if (*buf == '=')
-               return -EINVAL;
-       key = kstrndup_noeol(buf, 1024);
-       if (!key)
-               return -ENOMEM;
-       /* extract key and val */
-       val = strchr(key, '=');
-       if (!val) {
-               kfree(key);
-               return -EINVAL;
-       }
-       *val++ = 0;
-       val = skip_spaces(val);
-       remove_trail_spaces(key);
-       remove_trail_spaces(val);
-       mutex_lock(&codec->user_mutex);
-       hint = get_hint(codec, key);
-       if (hint) {
-               /* replace */
-               kfree(hint->key);
-               hint->key = key;
-               hint->val = val;
-               goto unlock;
-       }
-       /* allocate a new hint entry */
-       if (codec->hints.used >= MAX_HINTS)
-               hint = NULL;
-       else
-               hint = snd_array_new(&codec->hints);
-       if (hint) {
-               hint->key = key;
-               hint->val = val;
-       } else {
-               err = -ENOMEM;
-       }
- unlock:
-       mutex_unlock(&codec->user_mutex);
-       if (err)
-               kfree(key);
-       return err;
-}
-
-static ssize_t hints_store(struct device *dev,
-                          struct device_attribute *attr,
-                          const char *buf, size_t count)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       int err = parse_hints(codec, buf);
-       if (err < 0)
-               return err;
-       return count;
-}
-
-static ssize_t pin_configs_show(struct hda_codec *codec,
-                               struct snd_array *list,
-                               char *buf)
-{
-       int i, len = 0;
-       mutex_lock(&codec->user_mutex);
-       for (i = 0; i < list->used; i++) {
-               struct hda_pincfg *pin = snd_array_elem(list, i);
-               len += sprintf(buf + len, "0x%02x 0x%08x\n",
-                              pin->nid, pin->cfg);
-       }
-       mutex_unlock(&codec->user_mutex);
-       return len;
-}
-
-static ssize_t init_pin_configs_show(struct device *dev,
-                                    struct device_attribute *attr,
-                                    char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       return pin_configs_show(codec, &codec->init_pins, buf);
-}
-
-static ssize_t user_pin_configs_show(struct device *dev,
-                                    struct device_attribute *attr,
-                                    char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       return pin_configs_show(codec, &codec->user_pins, buf);
-}
-
-static ssize_t driver_pin_configs_show(struct device *dev,
-                                      struct device_attribute *attr,
-                                      char *buf)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       return pin_configs_show(codec, &codec->driver_pins, buf);
-}
-
-#define MAX_PIN_CONFIGS                32
-
-static int parse_user_pin_configs(struct hda_codec *codec, const char *buf)
-{
-       int nid, cfg, err;
-
-       if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
-               return -EINVAL;
-       if (!nid)
-               return -EINVAL;
-       mutex_lock(&codec->user_mutex);
-       err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
-       mutex_unlock(&codec->user_mutex);
-       return err;
-}
-
-static ssize_t user_pin_configs_store(struct device *dev,
-                                     struct device_attribute *attr,
-                                     const char *buf, size_t count)
-{
-       struct snd_hwdep *hwdep = dev_get_drvdata(dev);
-       struct hda_codec *codec = hwdep->private_data;
-       int err = parse_user_pin_configs(codec, buf);
-       if (err < 0)
-               return err;
-       return count;
-}
-
-#define CODEC_ATTR_RW(type) \
-       __ATTR(type, 0644, type##_show, type##_store)
-#define CODEC_ATTR_RO(type) \
-       __ATTR_RO(type)
-#define CODEC_ATTR_WO(type) \
-       __ATTR(type, 0200, NULL, type##_store)
-
-static struct device_attribute codec_attrs[] = {
-       CODEC_ATTR_RW(vendor_id),
-       CODEC_ATTR_RW(subsystem_id),
-       CODEC_ATTR_RW(revision_id),
-       CODEC_ATTR_RO(afg),
-       CODEC_ATTR_RO(mfg),
-       CODEC_ATTR_RW(vendor_name),
-       CODEC_ATTR_RW(chip_name),
-       CODEC_ATTR_RW(modelname),
-       CODEC_ATTR_RW(init_verbs),
-       CODEC_ATTR_RW(hints),
-       CODEC_ATTR_RO(init_pin_configs),
-       CODEC_ATTR_RW(user_pin_configs),
-       CODEC_ATTR_RO(driver_pin_configs),
-       CODEC_ATTR_WO(reconfig),
-       CODEC_ATTR_WO(clear),
-};
-
-/*
- * create sysfs files on hwdep directory
- */
-int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
-{
-       struct snd_hwdep *hwdep = codec->hwdep;
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(codec_attrs); i++)
-               snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card,
-                                         hwdep->device, &codec_attrs[i]);
-       return 0;
-}
-
-/*
- * Look for hint string
- */
-const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
-{
-       struct hda_hint *hint = get_hint(codec, key);
-       return hint ? hint->val : NULL;
-}
-EXPORT_SYMBOL_GPL(snd_hda_get_hint);
-
-int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
-{
-       const char *p;
-       int ret;
-
-       mutex_lock(&codec->user_mutex);
-       p = snd_hda_get_hint(codec, key);
-       if (!p || !*p)
-               ret = -ENOENT;
-       else {
-               switch (toupper(*p)) {
-               case 'T': /* true */
-               case 'Y': /* yes */
-               case '1':
-                       ret = 1;
-                       break;
-               default:
-                       ret = 0;
-                       break;
-               }
-       }
-       mutex_unlock(&codec->user_mutex);
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_hda_get_bool_hint);
-
-int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
-{
-       const char *p;
-       unsigned long val;
-       int ret;
-
-       mutex_lock(&codec->user_mutex);
-       p = snd_hda_get_hint(codec, key);
-       if (!p)
-               ret = -ENOENT;
-       else if (kstrtoul(p, 0, &val))
-               ret = -EINVAL;
-       else {
-               *valp = val;
-               ret = 0;
-       }
-       mutex_unlock(&codec->user_mutex);
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_hda_get_int_hint);
-#endif /* CONFIG_SND_HDA_RECONFIG */
-
-#ifdef CONFIG_SND_HDA_PATCH_LOADER
+       /* link to codec */
+       hwdep->dev = &codec->dev;
 
-/* parser mode */
-enum {
-       LINE_MODE_NONE,
-       LINE_MODE_CODEC,
-       LINE_MODE_MODEL,
-       LINE_MODE_PINCFG,
-       LINE_MODE_VERB,
-       LINE_MODE_HINT,
-       LINE_MODE_VENDOR_ID,
-       LINE_MODE_SUBSYSTEM_ID,
-       LINE_MODE_REVISION_ID,
-       LINE_MODE_CHIP_NAME,
-       NUM_LINE_MODES,
-};
-
-static inline int strmatch(const char *a, const char *b)
-{
-       return strnicmp(a, b, strlen(b)) == 0;
-}
-
-/* parse the contents after the line "[codec]"
- * accept only the line with three numbers, and assign the current codec
- */
-static void parse_codec_mode(char *buf, struct hda_bus *bus,
-                            struct hda_codec **codecp)
-{
-       int vendorid, subid, caddr;
-       struct hda_codec *codec;
-
-       *codecp = NULL;
-       if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
-               list_for_each_entry(codec, &bus->codec_list, list) {
-                       if ((vendorid <= 0 || codec->vendor_id == vendorid) &&
-                           (subid <= 0 || codec->subsystem_id == subid) &&
-                           codec->addr == caddr) {
-                               *codecp = codec;
-                               break;
-                       }
-               }
-       }
-}
-
-/* parse the contents after the other command tags, [pincfg], [verb],
- * [vendor_id], [subsystem_id], [revision_id], [chip_name], [hint] and [model]
- * just pass to the sysfs helper (only when any codec was specified)
- */
-static void parse_pincfg_mode(char *buf, struct hda_bus *bus,
-                             struct hda_codec **codecp)
-{
-       parse_user_pin_configs(*codecp, buf);
-}
-
-static void parse_verb_mode(char *buf, struct hda_bus *bus,
-                           struct hda_codec **codecp)
-{
-       parse_init_verbs(*codecp, buf);
-}
-
-static void parse_hint_mode(char *buf, struct hda_bus *bus,
-                           struct hda_codec **codecp)
-{
-       parse_hints(*codecp, buf);
-}
-
-static void parse_model_mode(char *buf, struct hda_bus *bus,
-                            struct hda_codec **codecp)
-{
-       kfree((*codecp)->modelname);
-       (*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
-}
-
-static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
-                                struct hda_codec **codecp)
-{
-       kfree((*codecp)->chip_name);
-       (*codecp)->chip_name = kstrdup(buf, GFP_KERNEL);
-}
-
-#define DEFINE_PARSE_ID_MODE(name) \
-static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
-                                struct hda_codec **codecp) \
-{ \
-       unsigned long val; \
-       if (!kstrtoul(buf, 0, &val)) \
-               (*codecp)->name = val; \
-}
-
-DEFINE_PARSE_ID_MODE(vendor_id);
-DEFINE_PARSE_ID_MODE(subsystem_id);
-DEFINE_PARSE_ID_MODE(revision_id);
-
-
-struct hda_patch_item {
-       const char *tag;
-       const char *alias;
-       void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc);
-};
-
-static struct hda_patch_item patch_items[NUM_LINE_MODES] = {
-       [LINE_MODE_CODEC] = {
-               .tag = "[codec]",
-               .parser = parse_codec_mode,
-       },
-       [LINE_MODE_MODEL] = {
-               .tag = "[model]",
-               .parser = parse_model_mode,
-       },
-       [LINE_MODE_VERB] = {
-               .tag = "[verb]",
-               .alias = "[init_verbs]",
-               .parser = parse_verb_mode,
-       },
-       [LINE_MODE_PINCFG] = {
-               .tag = "[pincfg]",
-               .alias = "[user_pin_configs]",
-               .parser = parse_pincfg_mode,
-       },
-       [LINE_MODE_HINT] = {
-               .tag = "[hint]",
-               .alias = "[hints]",
-               .parser = parse_hint_mode
-       },
-       [LINE_MODE_VENDOR_ID] = {
-               .tag = "[vendor_id]",
-               .parser = parse_vendor_id_mode,
-       },
-       [LINE_MODE_SUBSYSTEM_ID] = {
-               .tag = "[subsystem_id]",
-               .parser = parse_subsystem_id_mode,
-       },
-       [LINE_MODE_REVISION_ID] = {
-               .tag = "[revision_id]",
-               .parser = parse_revision_id_mode,
-       },
-       [LINE_MODE_CHIP_NAME] = {
-               .tag = "[chip_name]",
-               .parser = parse_chip_name_mode,
-       },
-};
-
-/* check the line starting with '[' -- change the parser mode accodingly */
-static int parse_line_mode(char *buf, struct hda_bus *bus)
-{
-       int i;
-       for (i = 0; i < ARRAY_SIZE(patch_items); i++) {
-               if (!patch_items[i].tag)
-                       continue;
-               if (strmatch(buf, patch_items[i].tag))
-                       return i;
-               if (patch_items[i].alias && strmatch(buf, patch_items[i].alias))
-                       return i;
-       }
-       return LINE_MODE_NONE;
-}
-
-/* copy one line from the buffer in fw, and update the fields in fw
- * return zero if it reaches to the end of the buffer, or non-zero
- * if successfully copied a line
- *
- * the spaces at the beginning and the end of the line are stripped
- */
-static int get_line_from_fw(char *buf, int size, size_t *fw_size_p,
-                           const void **fw_data_p)
-{
-       int len;
-       size_t fw_size = *fw_size_p;
-       const char *p = *fw_data_p;
-
-       while (isspace(*p) && fw_size) {
-               p++;
-               fw_size--;
-       }
-       if (!fw_size)
-               return 0;
-
-       for (len = 0; len < fw_size; len++) {
-               if (!*p)
-                       break;
-               if (*p == '\n') {
-                       p++;
-                       len++;
-                       break;
-               }
-               if (len < size)
-                       *buf++ = *p++;
-       }
-       *buf = 0;
-       *fw_size_p = fw_size - len;
-       *fw_data_p = p;
-       remove_trail_spaces(buf);
-       return 1;
-}
-
-/*
- * load a "patch" firmware file and parse it
- */
-int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf)
-{
-       char buf[128];
-       struct hda_codec *codec;
-       int line_mode;
-
-       line_mode = LINE_MODE_NONE;
-       codec = NULL;
-       while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) {
-               if (!*buf || *buf == '#' || *buf == '\n')
-                       continue;
-               if (*buf == '[')
-                       line_mode = parse_line_mode(buf, bus);
-               else if (patch_items[line_mode].parser &&
-                        (codec || line_mode <= LINE_MODE_CODEC))
-                       patch_items[line_mode].parser(buf, bus, &codec);
-       }
        return 0;
 }
-EXPORT_SYMBOL_GPL(snd_hda_load_patch);
-#endif /* CONFIG_SND_HDA_PATCH_LOADER */
index 76c13d5b3ca0d7295d24e22f660ba1a4d733fa01..9d07e4edacdb4026fcd1b7cbdb7c85974b2a8489 100644 (file)
@@ -30,7 +30,7 @@ void hda_display_power(bool enable)
        if (!get_power || !put_power)
                return;
 
-       snd_printdd("HDA display power %s \n",
+       pr_debug("HDA display power %s \n",
                        enable ? "Enable" : "Disable");
        if (enable)
                get_power();
@@ -44,7 +44,7 @@ int hda_i915_init(void)
 
        get_power = symbol_request(i915_request_power_well);
        if (!get_power) {
-               snd_printk(KERN_WARNING "hda-i915: get_power symbol get fail\n");
+               pr_warn("hda-i915: get_power symbol get fail\n");
                return -ENODEV;
        }
 
@@ -55,7 +55,7 @@ int hda_i915_init(void)
                return -ENODEV;
        }
 
-       snd_printd("HDA driver get symbol successfully from i915 module\n");
+       pr_debug("HDA driver get symbol successfully from i915 module\n");
 
        return err;
 }
index e354ab1ec20f2dcd942931582761cc10b5543648..77ca894f82845964192cdc20476002f3cdec63a0 100644 (file)
@@ -63,6 +63,8 @@
 #include <linux/firmware.h>
 #include "hda_codec.h"
 #include "hda_i915.h"
+#include "hda_controller.h"
+#include "hda_priv.h"
 
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
@@ -127,6 +129,7 @@ static struct kernel_param_ops param_ops_xint = {
 #define param_check_xint param_check_int
 
 static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
+static int *power_save_addr = &power_save;
 module_param(power_save, xint, 0644);
 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
                 "(in second, 0 = disable).");
@@ -138,6 +141,8 @@ MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
 static bool power_save_controller = 1;
 module_param(power_save_controller, bool, 0644);
 MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
+#else
+static int *power_save_addr;
 #endif /* CONFIG_PM */
 
 static int align_buffer_size = -1;
@@ -149,10 +154,8 @@ MODULE_PARM_DESC(align_buffer_size,
 static bool hda_snoop = true;
 module_param_named(snoop, hda_snoop, bool, 0444);
 MODULE_PARM_DESC(snoop, "Enable/disable snooping");
-#define azx_snoop(chip)                (chip)->snoop
 #else
 #define hda_snoop              true
-#define azx_snoop(chip)                true
 #endif
 
 
@@ -191,12 +194,6 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
                         "{ULI, M5461}}");
 MODULE_DESCRIPTION("Intel HDA driver");
 
-#ifdef CONFIG_SND_VERBOSE_PRINTK
-#define SFX    /* nop */
-#else
-#define SFX    "hda-intel "
-#endif
-
 #if defined(CONFIG_PM) && defined(CONFIG_VGA_SWITCHEROO)
 #if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
 #define SUPPORT_VGA_SWITCHEROO
@@ -204,366 +201,9 @@ MODULE_DESCRIPTION("Intel HDA driver");
 #endif
 
 
-/*
- * registers
- */
-#define ICH6_REG_GCAP                  0x00
-#define   ICH6_GCAP_64OK       (1 << 0)   /* 64bit address support */
-#define   ICH6_GCAP_NSDO       (3 << 1)   /* # of serial data out signals */
-#define   ICH6_GCAP_BSS                (31 << 3)  /* # of bidirectional streams */
-#define   ICH6_GCAP_ISS                (15 << 8)  /* # of input streams */
-#define   ICH6_GCAP_OSS                (15 << 12) /* # of output streams */
-#define ICH6_REG_VMIN                  0x02
-#define ICH6_REG_VMAJ                  0x03
-#define ICH6_REG_OUTPAY                        0x04
-#define ICH6_REG_INPAY                 0x06
-#define ICH6_REG_GCTL                  0x08
-#define   ICH6_GCTL_RESET      (1 << 0)   /* controller reset */
-#define   ICH6_GCTL_FCNTRL     (1 << 1)   /* flush control */
-#define   ICH6_GCTL_UNSOL      (1 << 8)   /* accept unsol. response enable */
-#define ICH6_REG_WAKEEN                        0x0c
-#define ICH6_REG_STATESTS              0x0e
-#define ICH6_REG_GSTS                  0x10
-#define   ICH6_GSTS_FSTS       (1 << 1)   /* flush status */
-#define ICH6_REG_INTCTL                        0x20
-#define ICH6_REG_INTSTS                        0x24
-#define ICH6_REG_WALLCLK               0x30    /* 24Mhz source */
-#define ICH6_REG_OLD_SSYNC             0x34    /* SSYNC for old ICH */
-#define ICH6_REG_SSYNC                 0x38
-#define ICH6_REG_CORBLBASE             0x40
-#define ICH6_REG_CORBUBASE             0x44
-#define ICH6_REG_CORBWP                        0x48
-#define ICH6_REG_CORBRP                        0x4a
-#define   ICH6_CORBRP_RST      (1 << 15)  /* read pointer reset */
-#define ICH6_REG_CORBCTL               0x4c
-#define   ICH6_CORBCTL_RUN     (1 << 1)   /* enable DMA */
-#define   ICH6_CORBCTL_CMEIE   (1 << 0)   /* enable memory error irq */
-#define ICH6_REG_CORBSTS               0x4d
-#define   ICH6_CORBSTS_CMEI    (1 << 0)   /* memory error indication */
-#define ICH6_REG_CORBSIZE              0x4e
-
-#define ICH6_REG_RIRBLBASE             0x50
-#define ICH6_REG_RIRBUBASE             0x54
-#define ICH6_REG_RIRBWP                        0x58
-#define   ICH6_RIRBWP_RST      (1 << 15)  /* write pointer reset */
-#define ICH6_REG_RINTCNT               0x5a
-#define ICH6_REG_RIRBCTL               0x5c
-#define   ICH6_RBCTL_IRQ_EN    (1 << 0)   /* enable IRQ */
-#define   ICH6_RBCTL_DMA_EN    (1 << 1)   /* enable DMA */
-#define   ICH6_RBCTL_OVERRUN_EN        (1 << 2)   /* enable overrun irq */
-#define ICH6_REG_RIRBSTS               0x5d
-#define   ICH6_RBSTS_IRQ       (1 << 0)   /* response irq */
-#define   ICH6_RBSTS_OVERRUN   (1 << 2)   /* overrun irq */
-#define ICH6_REG_RIRBSIZE              0x5e
-
-#define ICH6_REG_IC                    0x60
-#define ICH6_REG_IR                    0x64
-#define ICH6_REG_IRS                   0x68
-#define   ICH6_IRS_VALID       (1<<1)
-#define   ICH6_IRS_BUSY                (1<<0)
-
-#define ICH6_REG_DPLBASE               0x70
-#define ICH6_REG_DPUBASE               0x74
-#define   ICH6_DPLBASE_ENABLE  0x1     /* Enable position buffer */
-
-/* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
-enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
-
-/* stream register offsets from stream base */
-#define ICH6_REG_SD_CTL                        0x00
-#define ICH6_REG_SD_STS                        0x03
-#define ICH6_REG_SD_LPIB               0x04
-#define ICH6_REG_SD_CBL                        0x08
-#define ICH6_REG_SD_LVI                        0x0c
-#define ICH6_REG_SD_FIFOW              0x0e
-#define ICH6_REG_SD_FIFOSIZE           0x10
-#define ICH6_REG_SD_FORMAT             0x12
-#define ICH6_REG_SD_BDLPL              0x18
-#define ICH6_REG_SD_BDLPU              0x1c
-
-/* PCI space */
-#define ICH6_PCIREG_TCSEL      0x44
-
-/*
- * other constants
- */
-
-/* max number of SDs */
-/* ICH, ATI and VIA have 4 playback and 4 capture */
-#define ICH6_NUM_CAPTURE       4
-#define ICH6_NUM_PLAYBACK      4
-
-/* ULI has 6 playback and 5 capture */
-#define ULI_NUM_CAPTURE                5
-#define ULI_NUM_PLAYBACK       6
-
-/* ATI HDMI may have up to 8 playbacks and 0 capture */
-#define ATIHDMI_NUM_CAPTURE    0
-#define ATIHDMI_NUM_PLAYBACK   8
-
-/* TERA has 4 playback and 3 capture */
-#define TERA_NUM_CAPTURE       3
-#define TERA_NUM_PLAYBACK      4
-
-/* this number is statically defined for simplicity */
-#define MAX_AZX_DEV            16
-
-/* max number of fragments - we may use more if allocating more pages for BDL */
-#define BDL_SIZE               4096
-#define AZX_MAX_BDL_ENTRIES    (BDL_SIZE / 16)
-#define AZX_MAX_FRAG           32
-/* max buffer size - no h/w limit, you can increase as you like */
-#define AZX_MAX_BUF_SIZE       (1024*1024*1024)
-
-/* RIRB int mask: overrun[2], response[0] */
-#define RIRB_INT_RESPONSE      0x01
-#define RIRB_INT_OVERRUN       0x04
-#define RIRB_INT_MASK          0x05
-
-/* STATESTS int mask: S3,SD2,SD1,SD0 */
-#define AZX_MAX_CODECS         8
-#define AZX_DEFAULT_CODECS     4
-#define STATESTS_INT_MASK      ((1 << AZX_MAX_CODECS) - 1)
-
-/* SD_CTL bits */
-#define SD_CTL_STREAM_RESET    0x01    /* stream reset bit */
-#define SD_CTL_DMA_START       0x02    /* stream DMA start bit */
-#define SD_CTL_STRIPE          (3 << 16)       /* stripe control */
-#define SD_CTL_TRAFFIC_PRIO    (1 << 18)       /* traffic priority */
-#define SD_CTL_DIR             (1 << 19)       /* bi-directional stream */
-#define SD_CTL_STREAM_TAG_MASK (0xf << 20)
-#define SD_CTL_STREAM_TAG_SHIFT        20
-
-/* SD_CTL and SD_STS */
-#define SD_INT_DESC_ERR                0x10    /* descriptor error interrupt */
-#define SD_INT_FIFO_ERR                0x08    /* FIFO error interrupt */
-#define SD_INT_COMPLETE                0x04    /* completion interrupt */
-#define SD_INT_MASK            (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
-                                SD_INT_COMPLETE)
-
-/* SD_STS */
-#define SD_STS_FIFO_READY      0x20    /* FIFO ready */
-
-/* INTCTL and INTSTS */
-#define ICH6_INT_ALL_STREAM    0xff       /* all stream interrupts */
-#define ICH6_INT_CTRL_EN       0x40000000 /* controller interrupt enable bit */
-#define ICH6_INT_GLOBAL_EN     0x80000000 /* global interrupt enable bit */
-
-/* below are so far hardcoded - should read registers in future */
-#define ICH6_MAX_CORB_ENTRIES  256
-#define ICH6_MAX_RIRB_ENTRIES  256
-
-/* position fix mode */
-enum {
-       POS_FIX_AUTO,
-       POS_FIX_LPIB,
-       POS_FIX_POSBUF,
-       POS_FIX_VIACOMBO,
-       POS_FIX_COMBO,
-};
-
-/* Defines for ATI HD Audio support in SB450 south bridge */
-#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR   0x42
-#define ATI_SB450_HDAUDIO_ENABLE_SNOOP      0x02
-
-/* Defines for Nvidia HDA support */
-#define NVIDIA_HDA_TRANSREG_ADDR      0x4e
-#define NVIDIA_HDA_ENABLE_COHBITS     0x0f
-#define NVIDIA_HDA_ISTRM_COH          0x4d
-#define NVIDIA_HDA_OSTRM_COH          0x4c
-#define NVIDIA_HDA_ENABLE_COHBIT      0x01
-
-/* Defines for Intel SCH HDA snoop control */
-#define INTEL_SCH_HDA_DEVC      0x78
-#define INTEL_SCH_HDA_DEVC_NOSNOOP       (0x1<<11)
-
-/* Define IN stream 0 FIFO size offset in VIA controller */
-#define VIA_IN_STREAM0_FIFO_SIZE_OFFSET        0x90
-/* Define VIA HD Audio Device ID*/
-#define VIA_HDAC_DEVICE_ID             0x3288
-
-/* HD Audio class code */
-#define PCI_CLASS_MULTIMEDIA_HD_AUDIO  0x0403
-
 /*
  */
 
-struct azx_dev {
-       struct snd_dma_buffer bdl; /* BDL buffer */
-       u32 *posbuf;            /* position buffer pointer */
-
-       unsigned int bufsize;   /* size of the play buffer in bytes */
-       unsigned int period_bytes; /* size of the period in bytes */
-       unsigned int frags;     /* number for period in the play buffer */
-       unsigned int fifo_size; /* FIFO size */
-       unsigned long start_wallclk;    /* start + minimum wallclk */
-       unsigned long period_wallclk;   /* wallclk for period */
-
-       void __iomem *sd_addr;  /* stream descriptor pointer */
-
-       u32 sd_int_sta_mask;    /* stream int status mask */
-
-       /* pcm support */
-       struct snd_pcm_substream *substream;    /* assigned substream,
-                                                * set in PCM open
-                                                */
-       unsigned int format_val;        /* format value to be set in the
-                                        * controller and the codec
-                                        */
-       unsigned char stream_tag;       /* assigned stream */
-       unsigned char index;            /* stream index */
-       int assigned_key;               /* last device# key assigned to */
-
-       unsigned int opened :1;
-       unsigned int running :1;
-       unsigned int irq_pending :1;
-       unsigned int prepared:1;
-       unsigned int locked:1;
-       /*
-        * For VIA:
-        *  A flag to ensure DMA position is 0
-        *  when link position is not greater than FIFO size
-        */
-       unsigned int insufficient :1;
-       unsigned int wc_marked:1;
-       unsigned int no_period_wakeup:1;
-
-       struct timecounter  azx_tc;
-       struct cyclecounter azx_cc;
-
-       int delay_negative_threshold;
-
-#ifdef CONFIG_SND_HDA_DSP_LOADER
-       struct mutex dsp_mutex;
-#endif
-};
-
-/* DSP lock helpers */
-#ifdef CONFIG_SND_HDA_DSP_LOADER
-#define dsp_lock_init(dev)     mutex_init(&(dev)->dsp_mutex)
-#define dsp_lock(dev)          mutex_lock(&(dev)->dsp_mutex)
-#define dsp_unlock(dev)                mutex_unlock(&(dev)->dsp_mutex)
-#define dsp_is_locked(dev)     ((dev)->locked)
-#else
-#define dsp_lock_init(dev)     do {} while (0)
-#define dsp_lock(dev)          do {} while (0)
-#define dsp_unlock(dev)                do {} while (0)
-#define dsp_is_locked(dev)     0
-#endif
-
-/* CORB/RIRB */
-struct azx_rb {
-       u32 *buf;               /* CORB/RIRB buffer
-                                * Each CORB entry is 4byte, RIRB is 8byte
-                                */
-       dma_addr_t addr;        /* physical address of CORB/RIRB buffer */
-       /* for RIRB */
-       unsigned short rp, wp;  /* read/write pointers */
-       int cmds[AZX_MAX_CODECS];       /* number of pending requests */
-       u32 res[AZX_MAX_CODECS];        /* last read value */
-};
-
-struct azx_pcm {
-       struct azx *chip;
-       struct snd_pcm *pcm;
-       struct hda_codec *codec;
-       struct hda_pcm_stream *hinfo[2];
-       struct list_head list;
-};
-
-struct azx {
-       struct snd_card *card;
-       struct pci_dev *pci;
-       int dev_index;
-
-       /* chip type specific */
-       int driver_type;
-       unsigned int driver_caps;
-       int playback_streams;
-       int playback_index_offset;
-       int capture_streams;
-       int capture_index_offset;
-       int num_streams;
-
-       /* pci resources */
-       unsigned long addr;
-       void __iomem *remap_addr;
-       int irq;
-
-       /* locks */
-       spinlock_t reg_lock;
-       struct mutex open_mutex;
-       struct completion probe_wait;
-
-       /* streams (x num_streams) */
-       struct azx_dev *azx_dev;
-
-       /* PCM */
-       struct list_head pcm_list; /* azx_pcm list */
-
-       /* HD codec */
-       unsigned short codec_mask;
-       int  codec_probe_mask; /* copied from probe_mask option */
-       struct hda_bus *bus;
-       unsigned int beep_mode;
-
-       /* CORB/RIRB */
-       struct azx_rb corb;
-       struct azx_rb rirb;
-
-       /* CORB/RIRB and position buffers */
-       struct snd_dma_buffer rb;
-       struct snd_dma_buffer posbuf;
-
-#ifdef CONFIG_SND_HDA_PATCH_LOADER
-       const struct firmware *fw;
-#endif
-
-       /* flags */
-       int position_fix[2]; /* for both playback/capture streams */
-       int poll_count;
-       unsigned int running :1;
-       unsigned int initialized :1;
-       unsigned int single_cmd :1;
-       unsigned int polling_mode :1;
-       unsigned int msi :1;
-       unsigned int irq_pending_warned :1;
-       unsigned int probing :1; /* codec probing phase */
-       unsigned int snoop:1;
-       unsigned int align_buffer_size:1;
-       unsigned int region_requested:1;
-
-       /* VGA-switcheroo setup */
-       unsigned int use_vga_switcheroo:1;
-       unsigned int vga_switcheroo_registered:1;
-       unsigned int init_failed:1; /* delayed init failed */
-       unsigned int disabled:1; /* disabled by VGA-switcher */
-
-       /* for debugging */
-       unsigned int last_cmd[AZX_MAX_CODECS];
-
-       /* for pending irqs */
-       struct work_struct irq_pending_work;
-
-       struct work_struct probe_work;
-
-       /* reboot notifier (for mysterious hangup problem at power-down) */
-       struct notifier_block reboot_notifier;
-
-       /* card list (for power_save trigger) */
-       struct list_head list;
-
-#ifdef CONFIG_SND_HDA_DSP_LOADER
-       struct azx_dev saved_azx_dev;
-#endif
-
-       /* secondary power domain for hdmi audio under vga device */
-       struct dev_pm_domain hdmi_pm_domain;
-};
-
-#define CREATE_TRACE_POINTS
-#include "hda_intel_trace.h"
-
 /* driver types */
 enum {
        AZX_DRIVER_ICH,
@@ -584,28 +224,6 @@ enum {
        AZX_NUM_DRIVERS, /* keep this as last entry */
 };
 
-/* driver quirks (capabilities) */
-/* bits 0-7 are used for indicating driver type */
-#define AZX_DCAPS_NO_TCSEL     (1 << 8)        /* No Intel TCSEL bit */
-#define AZX_DCAPS_NO_MSI       (1 << 9)        /* No MSI support */
-#define AZX_DCAPS_ATI_SNOOP    (1 << 10)       /* ATI snoop enable */
-#define AZX_DCAPS_NVIDIA_SNOOP (1 << 11)       /* Nvidia snoop enable */
-#define AZX_DCAPS_SCH_SNOOP    (1 << 12)       /* SCH/PCH snoop enable */
-#define AZX_DCAPS_RIRB_DELAY   (1 << 13)       /* Long delay in read loop */
-#define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14)     /* Put a delay before read */
-#define AZX_DCAPS_CTX_WORKAROUND (1 << 15)     /* X-Fi workaround */
-#define AZX_DCAPS_POSFIX_LPIB  (1 << 16)       /* Use LPIB as default */
-#define AZX_DCAPS_POSFIX_VIA   (1 << 17)       /* Use VIACOMBO as default */
-#define AZX_DCAPS_NO_64BIT     (1 << 18)       /* No 64bit address */
-#define AZX_DCAPS_SYNC_WRITE   (1 << 19)       /* sync each cmd write */
-#define AZX_DCAPS_OLD_SSYNC    (1 << 20)       /* Old SSYNC reg for ICH */
-#define AZX_DCAPS_BUFSIZE      (1 << 21)       /* no buffer size alignment */
-#define AZX_DCAPS_ALIGN_BUFSIZE        (1 << 22)       /* buffer size alignment */
-#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23)   /* BDLE in 4k boundary */
-#define AZX_DCAPS_COUNT_LPIB_DELAY  (1 << 25)  /* Take LPIB as delay */
-#define AZX_DCAPS_PM_RUNTIME   (1 << 26)       /* runtime PM support */
-#define AZX_DCAPS_I915_POWERWELL (1 << 27)     /* HSW i915 power well support */
-
 /* quirks for Intel PCH */
 #define AZX_DCAPS_INTEL_PCH_NOPM \
        (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \
@@ -663,38 +281,6 @@ static char *driver_short_names[] = {
        [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
 };
 
-/*
- * macros for easy use
- */
-#define azx_writel(chip,reg,value) \
-       writel(value, (chip)->remap_addr + ICH6_REG_##reg)
-#define azx_readl(chip,reg) \
-       readl((chip)->remap_addr + ICH6_REG_##reg)
-#define azx_writew(chip,reg,value) \
-       writew(value, (chip)->remap_addr + ICH6_REG_##reg)
-#define azx_readw(chip,reg) \
-       readw((chip)->remap_addr + ICH6_REG_##reg)
-#define azx_writeb(chip,reg,value) \
-       writeb(value, (chip)->remap_addr + ICH6_REG_##reg)
-#define azx_readb(chip,reg) \
-       readb((chip)->remap_addr + ICH6_REG_##reg)
-
-#define azx_sd_writel(dev,reg,value) \
-       writel(value, (dev)->sd_addr + ICH6_REG_##reg)
-#define azx_sd_readl(dev,reg) \
-       readl((dev)->sd_addr + ICH6_REG_##reg)
-#define azx_sd_writew(dev,reg,value) \
-       writew(value, (dev)->sd_addr + ICH6_REG_##reg)
-#define azx_sd_readw(dev,reg) \
-       readw((dev)->sd_addr + ICH6_REG_##reg)
-#define azx_sd_writeb(dev,reg,value) \
-       writeb(value, (dev)->sd_addr + ICH6_REG_##reg)
-#define azx_sd_readb(dev,reg) \
-       readb((dev)->sd_addr + ICH6_REG_##reg)
-
-/* for pcm support */
-#define get_azx_dev(substream) (substream->runtime->private_data)
-
 #ifdef CONFIG_X86
 static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on)
 {
@@ -749,1750 +335,97 @@ static inline void mark_runtime_wc(struct azx *chip, struct azx_dev *azx_dev,
 #endif
 
 static int azx_acquire_irq(struct azx *chip, int do_disconnect);
-static int azx_send_cmd(struct hda_bus *bus, unsigned int val);
-/*
- * Interface for HD codec
- */
-
-/*
- * CORB / RIRB interface
- */
-static int azx_alloc_cmd_io(struct azx *chip)
-{
-       int err;
-
-       /* single page (at least 4096 bytes) must suffice for both ringbuffes */
-       err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
-                                 snd_dma_pci_data(chip->pci),
-                                 PAGE_SIZE, &chip->rb);
-       if (err < 0) {
-               snd_printk(KERN_ERR SFX "%s: cannot allocate CORB/RIRB\n", pci_name(chip->pci));
-               return err;
-       }
-       mark_pages_wc(chip, &chip->rb, true);
-       return 0;
-}
-
-static void azx_init_cmd_io(struct azx *chip)
-{
-       spin_lock_irq(&chip->reg_lock);
-       /* CORB set up */
-       chip->corb.addr = chip->rb.addr;
-       chip->corb.buf = (u32 *)chip->rb.area;
-       azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
-       azx_writel(chip, CORBUBASE, upper_32_bits(chip->corb.addr));
-
-       /* set the corb size to 256 entries (ULI requires explicitly) */
-       azx_writeb(chip, CORBSIZE, 0x02);
-       /* set the corb write pointer to 0 */
-       azx_writew(chip, CORBWP, 0);
-       /* reset the corb hw read pointer */
-       azx_writew(chip, CORBRP, ICH6_CORBRP_RST);
-       /* enable corb dma */
-       azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN);
-
-       /* RIRB set up */
-       chip->rirb.addr = chip->rb.addr + 2048;
-       chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
-       chip->rirb.wp = chip->rirb.rp = 0;
-       memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds));
-       azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
-       azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
-
-       /* set the rirb size to 256 entries (ULI requires explicitly) */
-       azx_writeb(chip, RIRBSIZE, 0x02);
-       /* reset the rirb hw write pointer */
-       azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST);
-       /* set N=1, get RIRB response interrupt for new entry */
-       if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
-               azx_writew(chip, RINTCNT, 0xc0);
-       else
-               azx_writew(chip, RINTCNT, 1);
-       /* enable rirb dma and response irq */
-       azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
-       spin_unlock_irq(&chip->reg_lock);
-}
-
-static void azx_free_cmd_io(struct azx *chip)
-{
-       spin_lock_irq(&chip->reg_lock);
-       /* disable ringbuffer DMAs */
-       azx_writeb(chip, RIRBCTL, 0);
-       azx_writeb(chip, CORBCTL, 0);
-       spin_unlock_irq(&chip->reg_lock);
-}
-
-static unsigned int azx_command_addr(u32 cmd)
-{
-       unsigned int addr = cmd >> 28;
-
-       if (addr >= AZX_MAX_CODECS) {
-               snd_BUG();
-               addr = 0;
-       }
-
-       return addr;
-}
-
-static unsigned int azx_response_addr(u32 res)
-{
-       unsigned int addr = res & 0xf;
-
-       if (addr >= AZX_MAX_CODECS) {
-               snd_BUG();
-               addr = 0;
-       }
-
-       return addr;
-}
-
-/* send a command */
-static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
-{
-       struct azx *chip = bus->private_data;
-       unsigned int addr = azx_command_addr(val);
-       unsigned int wp, rp;
-
-       spin_lock_irq(&chip->reg_lock);
-
-       /* add command to corb */
-       wp = azx_readw(chip, CORBWP);
-       if (wp == 0xffff) {
-               /* something wrong, controller likely turned to D3 */
-               spin_unlock_irq(&chip->reg_lock);
-               return -EIO;
-       }
-       wp++;
-       wp %= ICH6_MAX_CORB_ENTRIES;
-
-       rp = azx_readw(chip, CORBRP);
-       if (wp == rp) {
-               /* oops, it's full */
-               spin_unlock_irq(&chip->reg_lock);
-               return -EAGAIN;
-       }
-
-       chip->rirb.cmds[addr]++;
-       chip->corb.buf[wp] = cpu_to_le32(val);
-       azx_writel(chip, CORBWP, wp);
-
-       spin_unlock_irq(&chip->reg_lock);
-
-       return 0;
-}
-
-#define ICH6_RIRB_EX_UNSOL_EV  (1<<4)
-
-/* retrieve RIRB entry - called from interrupt handler */
-static void azx_update_rirb(struct azx *chip)
-{
-       unsigned int rp, wp;
-       unsigned int addr;
-       u32 res, res_ex;
-
-       wp = azx_readw(chip, RIRBWP);
-       if (wp == 0xffff) {
-               /* something wrong, controller likely turned to D3 */
-               return;
-       }
-
-       if (wp == chip->rirb.wp)
-               return;
-       chip->rirb.wp = wp;
-
-       while (chip->rirb.rp != wp) {
-               chip->rirb.rp++;
-               chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES;
-
-               rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */
-               res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]);
-               res = le32_to_cpu(chip->rirb.buf[rp]);
-               addr = azx_response_addr(res_ex);
-               if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
-                       snd_hda_queue_unsol_event(chip->bus, res, res_ex);
-               else if (chip->rirb.cmds[addr]) {
-                       chip->rirb.res[addr] = res;
-                       smp_wmb();
-                       chip->rirb.cmds[addr]--;
-               } else if (printk_ratelimit()) {
-                       snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, last cmd=%#08x\n",
-                                  pci_name(chip->pci),
-                                  res, res_ex,
-                                  chip->last_cmd[addr]);
-               }
-       }
-}
-
-/* receive a response */
-static unsigned int azx_rirb_get_response(struct hda_bus *bus,
-                                         unsigned int addr)
-{
-       struct azx *chip = bus->private_data;
-       unsigned long timeout;
-       unsigned long loopcounter;
-       int do_poll = 0;
-
- again:
-       timeout = jiffies + msecs_to_jiffies(1000);
-
-       for (loopcounter = 0;; loopcounter++) {
-               if (chip->polling_mode || do_poll) {
-                       spin_lock_irq(&chip->reg_lock);
-                       azx_update_rirb(chip);
-                       spin_unlock_irq(&chip->reg_lock);
-               }
-               if (!chip->rirb.cmds[addr]) {
-                       smp_rmb();
-                       bus->rirb_error = 0;
-
-                       if (!do_poll)
-                               chip->poll_count = 0;
-                       return chip->rirb.res[addr]; /* the last value */
-               }
-               if (time_after(jiffies, timeout))
-                       break;
-               if (bus->needs_damn_long_delay || loopcounter > 3000)
-                       msleep(2); /* temporary workaround */
-               else {
-                       udelay(10);
-                       cond_resched();
-               }
-       }
-
-       if (!bus->no_response_fallback)
-               return -1;
-
-       if (!chip->polling_mode && chip->poll_count < 2) {
-               snd_printdd(SFX "%s: azx_get_response timeout, "
-                          "polling the codec once: last cmd=0x%08x\n",
-                          pci_name(chip->pci), chip->last_cmd[addr]);
-               do_poll = 1;
-               chip->poll_count++;
-               goto again;
-       }
-
-
-       if (!chip->polling_mode) {
-               snd_printk(KERN_WARNING SFX "%s: azx_get_response timeout, "
-                          "switching to polling mode: last cmd=0x%08x\n",
-                          pci_name(chip->pci), chip->last_cmd[addr]);
-               chip->polling_mode = 1;
-               goto again;
-       }
-
-       if (chip->msi) {
-               snd_printk(KERN_WARNING SFX "%s: No response from codec, "
-                          "disabling MSI: last cmd=0x%08x\n",
-                          pci_name(chip->pci), chip->last_cmd[addr]);
-               free_irq(chip->irq, chip);
-               chip->irq = -1;
-               pci_disable_msi(chip->pci);
-               chip->msi = 0;
-               if (azx_acquire_irq(chip, 1) < 0) {
-                       bus->rirb_error = 1;
-                       return -1;
-               }
-               goto again;
-       }
-
-       if (chip->probing) {
-               /* If this critical timeout happens during the codec probing
-                * phase, this is likely an access to a non-existing codec
-                * slot.  Better to return an error and reset the system.
-                */
-               return -1;
-       }
-
-       /* a fatal communication error; need either to reset or to fallback
-        * to the single_cmd mode
-        */
-       bus->rirb_error = 1;
-       if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) {
-               bus->response_reset = 1;
-               return -1; /* give a chance to retry */
-       }
-
-       snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
-                  "switching to single_cmd mode: last cmd=0x%08x\n",
-                  chip->last_cmd[addr]);
-       chip->single_cmd = 1;
-       bus->response_reset = 0;
-       /* release CORB/RIRB */
-       azx_free_cmd_io(chip);
-       /* disable unsolicited responses */
-       azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_UNSOL);
-       return -1;
-}
-
-/*
- * Use the single immediate command instead of CORB/RIRB for simplicity
- *
- * Note: according to Intel, this is not preferred use.  The command was
- *       intended for the BIOS only, and may get confused with unsolicited
- *       responses.  So, we shouldn't use it for normal operation from the
- *       driver.
- *       I left the codes, however, for debugging/testing purposes.
- */
-
-/* receive a response */
-static int azx_single_wait_for_response(struct azx *chip, unsigned int addr)
-{
-       int timeout = 50;
-
-       while (timeout--) {
-               /* check IRV busy bit */
-               if (azx_readw(chip, IRS) & ICH6_IRS_VALID) {
-                       /* reuse rirb.res as the response return value */
-                       chip->rirb.res[addr] = azx_readl(chip, IR);
-                       return 0;
-               }
-               udelay(1);
-       }
-       if (printk_ratelimit())
-               snd_printd(SFX "%s: get_response timeout: IRS=0x%x\n",
-                          pci_name(chip->pci), azx_readw(chip, IRS));
-       chip->rirb.res[addr] = -1;
-       return -EIO;
-}
-
-/* send a command */
-static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
-{
-       struct azx *chip = bus->private_data;
-       unsigned int addr = azx_command_addr(val);
-       int timeout = 50;
-
-       bus->rirb_error = 0;
-       while (timeout--) {
-               /* check ICB busy bit */
-               if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
-                       /* Clear IRV valid bit */
-                       azx_writew(chip, IRS, azx_readw(chip, IRS) |
-                                  ICH6_IRS_VALID);
-                       azx_writel(chip, IC, val);
-                       azx_writew(chip, IRS, azx_readw(chip, IRS) |
-                                  ICH6_IRS_BUSY);
-                       return azx_single_wait_for_response(chip, addr);
-               }
-               udelay(1);
-       }
-       if (printk_ratelimit())
-               snd_printd(SFX "%s: send_cmd timeout: IRS=0x%x, val=0x%x\n",
-                          pci_name(chip->pci), azx_readw(chip, IRS), val);
-       return -EIO;
-}
-
-/* receive a response */
-static unsigned int azx_single_get_response(struct hda_bus *bus,
-                                           unsigned int addr)
-{
-       struct azx *chip = bus->private_data;
-       return chip->rirb.res[addr];
-}
 
 /*
- * The below are the main callbacks from hda_codec.
- *
- * They are just the skeleton to call sub-callbacks according to the
- * current setting of chip->single_cmd.
+ * initialize the PCI registers
  */
-
-/* send a command */
-static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
-{
-       struct azx *chip = bus->private_data;
-
-       if (chip->disabled)
-               return 0;
-       chip->last_cmd[azx_command_addr(val)] = val;
-       if (chip->single_cmd)
-               return azx_single_send_cmd(bus, val);
-       else
-               return azx_corb_send_cmd(bus, val);
-}
-
-/* get a response */
-static unsigned int azx_get_response(struct hda_bus *bus,
-                                    unsigned int addr)
-{
-       struct azx *chip = bus->private_data;
-       if (chip->disabled)
-               return 0;
-       if (chip->single_cmd)
-               return azx_single_get_response(bus, addr);
-       else
-               return azx_rirb_get_response(bus, addr);
-}
-
-#ifdef CONFIG_PM
-static void azx_power_notify(struct hda_bus *bus, bool power_up);
-#endif
-
-#ifdef CONFIG_SND_HDA_DSP_LOADER
-static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
-                               unsigned int byte_size,
-                               struct snd_dma_buffer *bufp);
-static void azx_load_dsp_trigger(struct hda_bus *bus, bool start);
-static void azx_load_dsp_cleanup(struct hda_bus *bus,
-                                struct snd_dma_buffer *dmab);
-#endif
-
-/* enter link reset */
-static void azx_enter_link_reset(struct azx *chip)
-{
-       unsigned long timeout;
-
-       /* reset controller */
-       azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET);
-
-       timeout = jiffies + msecs_to_jiffies(100);
-       while ((azx_readb(chip, GCTL) & ICH6_GCTL_RESET) &&
-                       time_before(jiffies, timeout))
-               usleep_range(500, 1000);
-}
-
-/* exit link reset */
-static void azx_exit_link_reset(struct azx *chip)
-{
-       unsigned long timeout;
-
-       azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET);
-
-       timeout = jiffies + msecs_to_jiffies(100);
-       while (!azx_readb(chip, GCTL) &&
-                       time_before(jiffies, timeout))
-               usleep_range(500, 1000);
-}
-
-/* reset codec link */
-static int azx_reset(struct azx *chip, int full_reset)
-{
-       if (!full_reset)
-               goto __skip;
-
-       /* clear STATESTS */
-       azx_writew(chip, STATESTS, STATESTS_INT_MASK);
-
-       /* reset controller */
-       azx_enter_link_reset(chip);
-
-       /* delay for >= 100us for codec PLL to settle per spec
-        * Rev 0.9 section 5.5.1
-        */
-       usleep_range(500, 1000);
-
-       /* Bring controller out of reset */
-       azx_exit_link_reset(chip);
-
-       /* Brent Chartrand said to wait >= 540us for codecs to initialize */
-       usleep_range(1000, 1200);
-
-      __skip:
-       /* check to see if controller is ready */
-       if (!azx_readb(chip, GCTL)) {
-               snd_printd(SFX "%s: azx_reset: controller not ready!\n", pci_name(chip->pci));
-               return -EBUSY;
-       }
-
-       /* Accept unsolicited responses */
-       if (!chip->single_cmd)
-               azx_writel(chip, GCTL, azx_readl(chip, GCTL) |
-                          ICH6_GCTL_UNSOL);
-
-       /* detect codecs */
-       if (!chip->codec_mask) {
-               chip->codec_mask = azx_readw(chip, STATESTS);
-               snd_printdd(SFX "%s: codec_mask = 0x%x\n", pci_name(chip->pci), chip->codec_mask);
-       }
-
-       return 0;
-}
-
-
-/*
- * Lowlevel interface
- */  
-
-/* enable interrupts */
-static void azx_int_enable(struct azx *chip)
-{
-       /* enable controller CIE and GIE */
-       azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) |
-                  ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN);
-}
-
-/* disable interrupts */
-static void azx_int_disable(struct azx *chip)
-{
-       int i;
-
-       /* disable interrupts in stream descriptor */
-       for (i = 0; i < chip->num_streams; i++) {
-               struct azx_dev *azx_dev = &chip->azx_dev[i];
-               azx_sd_writeb(azx_dev, SD_CTL,
-                             azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK);
-       }
-
-       /* disable SIE for all streams */
-       azx_writeb(chip, INTCTL, 0);
-
-       /* disable controller CIE and GIE */
-       azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) &
-                  ~(ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN));
-}
-
-/* clear interrupts */
-static void azx_int_clear(struct azx *chip)
-{
-       int i;
-
-       /* clear stream status */
-       for (i = 0; i < chip->num_streams; i++) {
-               struct azx_dev *azx_dev = &chip->azx_dev[i];
-               azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
-       }
-
-       /* clear STATESTS */
-       azx_writew(chip, STATESTS, STATESTS_INT_MASK);
-
-       /* clear rirb status */
-       azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
-
-       /* clear int status */
-       azx_writel(chip, INTSTS, ICH6_INT_CTRL_EN | ICH6_INT_ALL_STREAM);
-}
-
-/* start a stream */
-static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
-{
-       /*
-        * Before stream start, initialize parameter
-        */
-       azx_dev->insufficient = 1;
-
-       /* enable SIE */
-       azx_writel(chip, INTCTL,
-                  azx_readl(chip, INTCTL) | (1 << azx_dev->index));
-       /* set DMA start and interrupt mask */
-       azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
-                     SD_CTL_DMA_START | SD_INT_MASK);
-}
-
-/* stop DMA */
-static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
+/* update bits in a PCI register byte */
+static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
+                           unsigned char mask, unsigned char val)
 {
-       azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
-                     ~(SD_CTL_DMA_START | SD_INT_MASK));
-       azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
-}
+       unsigned char data;
 
-/* stop a stream */
-static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
-{
-       azx_stream_clear(chip, azx_dev);
-       /* disable SIE */
-       azx_writel(chip, INTCTL,
-                  azx_readl(chip, INTCTL) & ~(1 << azx_dev->index));
+       pci_read_config_byte(pci, reg, &data);
+       data &= ~mask;
+       data |= (val & mask);
+       pci_write_config_byte(pci, reg, data);
 }
 
+static void azx_init_pci(struct azx *chip)
+{
+       /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
+        * TCSEL == Traffic Class Select Register, which sets PCI express QOS
+        * Ensuring these bits are 0 clears playback static on some HD Audio
+        * codecs.
+        * The PCI register TCSEL is defined in the Intel manuals.
+        */
+       if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) {
+               dev_dbg(chip->card->dev, "Clearing TCSEL\n");
+               update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0);
+       }
 
-/*
- * reset and start the controller registers
- */
-static void azx_init_chip(struct azx *chip, int full_reset)
-{
-       if (chip->initialized)
-               return;
-
-       /* reset controller */
-       azx_reset(chip, full_reset);
-
-       /* initialize interrupts */
-       azx_int_clear(chip);
-       azx_int_enable(chip);
-
-       /* initialize the codec command I/O */
-       if (!chip->single_cmd)
-               azx_init_cmd_io(chip);
-
-       /* program the position buffer */
-       azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
-       azx_writel(chip, DPUBASE, upper_32_bits(chip->posbuf.addr));
-
-       chip->initialized = 1;
-}
-
-/*
- * initialize the PCI registers
- */
-/* update bits in a PCI register byte */
-static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
-                           unsigned char mask, unsigned char val)
-{
-       unsigned char data;
-
-       pci_read_config_byte(pci, reg, &data);
-       data &= ~mask;
-       data |= (val & mask);
-       pci_write_config_byte(pci, reg, data);
-}
-
-static void azx_init_pci(struct azx *chip)
-{
-       /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
-        * TCSEL == Traffic Class Select Register, which sets PCI express QOS
-        * Ensuring these bits are 0 clears playback static on some HD Audio
-        * codecs.
-        * The PCI register TCSEL is defined in the Intel manuals.
-        */
-       if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) {
-               snd_printdd(SFX "%s: Clearing TCSEL\n", pci_name(chip->pci));
-               update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0);
-       }
-
-       /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio,
-        * we need to enable snoop.
-        */
-       if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) {
-               snd_printdd(SFX "%s: Setting ATI snoop: %d\n", pci_name(chip->pci), azx_snoop(chip));
-               update_pci_byte(chip->pci,
-                               ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07,
-                               azx_snoop(chip) ? ATI_SB450_HDAUDIO_ENABLE_SNOOP : 0);
-       }
-
-       /* For NVIDIA HDA, enable snoop */
-       if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) {
-               snd_printdd(SFX "%s: Setting Nvidia snoop: %d\n", pci_name(chip->pci), azx_snoop(chip));
-               update_pci_byte(chip->pci,
-                               NVIDIA_HDA_TRANSREG_ADDR,
-                               0x0f, NVIDIA_HDA_ENABLE_COHBITS);
-               update_pci_byte(chip->pci,
-                               NVIDIA_HDA_ISTRM_COH,
-                               0x01, NVIDIA_HDA_ENABLE_COHBIT);
-               update_pci_byte(chip->pci,
-                               NVIDIA_HDA_OSTRM_COH,
-                               0x01, NVIDIA_HDA_ENABLE_COHBIT);
-       }
-
-       /* Enable SCH/PCH snoop if needed */
-       if (chip->driver_caps & AZX_DCAPS_SCH_SNOOP) {
-               unsigned short snoop;
-               pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
-               if ((!azx_snoop(chip) && !(snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)) ||
-                   (azx_snoop(chip) && (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP))) {
-                       snoop &= ~INTEL_SCH_HDA_DEVC_NOSNOOP;
-                       if (!azx_snoop(chip))
-                               snoop |= INTEL_SCH_HDA_DEVC_NOSNOOP;
-                       pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop);
-                       pci_read_config_word(chip->pci,
-                               INTEL_SCH_HDA_DEVC, &snoop);
-               }
-               snd_printdd(SFX "%s: SCH snoop: %s\n",
-                               pci_name(chip->pci), (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)
-                               ? "Disabled" : "Enabled");
-        }
-}
-
-
-static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev);
-
-/*
- * interrupt handler
- */
-static irqreturn_t azx_interrupt(int irq, void *dev_id)
-{
-       struct azx *chip = dev_id;
-       struct azx_dev *azx_dev;
-       u32 status;
-       u8 sd_status;
-       int i, ok;
-
-#ifdef CONFIG_PM_RUNTIME
-       if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME)
-               if (chip->pci->dev.power.runtime_status != RPM_ACTIVE)
-                       return IRQ_NONE;
-#endif
-
-       spin_lock(&chip->reg_lock);
-
-       if (chip->disabled) {
-               spin_unlock(&chip->reg_lock);
-               return IRQ_NONE;
-       }
-
-       status = azx_readl(chip, INTSTS);
-       if (status == 0 || status == 0xffffffff) {
-               spin_unlock(&chip->reg_lock);
-               return IRQ_NONE;
-       }
-       
-       for (i = 0; i < chip->num_streams; i++) {
-               azx_dev = &chip->azx_dev[i];
-               if (status & azx_dev->sd_int_sta_mask) {
-                       sd_status = azx_sd_readb(azx_dev, SD_STS);
-                       azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
-                       if (!azx_dev->substream || !azx_dev->running ||
-                           !(sd_status & SD_INT_COMPLETE))
-                               continue;
-                       /* check whether this IRQ is really acceptable */
-                       ok = azx_position_ok(chip, azx_dev);
-                       if (ok == 1) {
-                               azx_dev->irq_pending = 0;
-                               spin_unlock(&chip->reg_lock);
-                               snd_pcm_period_elapsed(azx_dev->substream);
-                               spin_lock(&chip->reg_lock);
-                       } else if (ok == 0 && chip->bus && chip->bus->workq) {
-                               /* bogus IRQ, process it later */
-                               azx_dev->irq_pending = 1;
-                               queue_work(chip->bus->workq,
-                                          &chip->irq_pending_work);
-                       }
-               }
-       }
-
-       /* clear rirb int */
-       status = azx_readb(chip, RIRBSTS);
-       if (status & RIRB_INT_MASK) {
-               if (status & RIRB_INT_RESPONSE) {
-                       if (chip->driver_caps & AZX_DCAPS_RIRB_PRE_DELAY)
-                               udelay(80);
-                       azx_update_rirb(chip);
-               }
-               azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
-       }
-
-#if 0
-       /* clear state status int */
-       if (azx_readw(chip, STATESTS) & 0x04)
-               azx_writew(chip, STATESTS, 0x04);
-#endif
-       spin_unlock(&chip->reg_lock);
-       
-       return IRQ_HANDLED;
-}
-
-
-/*
- * set up a BDL entry
- */
-static int setup_bdle(struct azx *chip,
-                     struct snd_dma_buffer *dmab,
-                     struct azx_dev *azx_dev, u32 **bdlp,
-                     int ofs, int size, int with_ioc)
-{
-       u32 *bdl = *bdlp;
-
-       while (size > 0) {
-               dma_addr_t addr;
-               int chunk;
-
-               if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
-                       return -EINVAL;
-
-               addr = snd_sgbuf_get_addr(dmab, ofs);
-               /* program the address field of the BDL entry */
-               bdl[0] = cpu_to_le32((u32)addr);
-               bdl[1] = cpu_to_le32(upper_32_bits(addr));
-               /* program the size field of the BDL entry */
-               chunk = snd_sgbuf_get_chunk_size(dmab, ofs, size);
-               /* one BDLE cannot cross 4K boundary on CTHDA chips */
-               if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY) {
-                       u32 remain = 0x1000 - (ofs & 0xfff);
-                       if (chunk > remain)
-                               chunk = remain;
-               }
-               bdl[2] = cpu_to_le32(chunk);
-               /* program the IOC to enable interrupt
-                * only when the whole fragment is processed
-                */
-               size -= chunk;
-               bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
-               bdl += 4;
-               azx_dev->frags++;
-               ofs += chunk;
-       }
-       *bdlp = bdl;
-       return ofs;
-}
-
-/*
- * set up BDL entries
- */
-static int azx_setup_periods(struct azx *chip,
-                            struct snd_pcm_substream *substream,
-                            struct azx_dev *azx_dev)
-{
-       u32 *bdl;
-       int i, ofs, periods, period_bytes;
-       int pos_adj;
-
-       /* reset BDL address */
-       azx_sd_writel(azx_dev, SD_BDLPL, 0);
-       azx_sd_writel(azx_dev, SD_BDLPU, 0);
-
-       period_bytes = azx_dev->period_bytes;
-       periods = azx_dev->bufsize / period_bytes;
-
-       /* program the initial BDL entries */
-       bdl = (u32 *)azx_dev->bdl.area;
-       ofs = 0;
-       azx_dev->frags = 0;
-       pos_adj = bdl_pos_adj[chip->dev_index];
-       if (!azx_dev->no_period_wakeup && pos_adj > 0) {
-               struct snd_pcm_runtime *runtime = substream->runtime;
-               int pos_align = pos_adj;
-               pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
-               if (!pos_adj)
-                       pos_adj = pos_align;
-               else
-                       pos_adj = ((pos_adj + pos_align - 1) / pos_align) *
-                               pos_align;
-               pos_adj = frames_to_bytes(runtime, pos_adj);
-               if (pos_adj >= period_bytes) {
-                       snd_printk(KERN_WARNING SFX "%s: Too big adjustment %d\n",
-                                  pci_name(chip->pci), bdl_pos_adj[chip->dev_index]);
-                       pos_adj = 0;
-               } else {
-                       ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
-                                        azx_dev,
-                                        &bdl, ofs, pos_adj, true);
-                       if (ofs < 0)
-                               goto error;
-               }
-       } else
-               pos_adj = 0;
-       for (i = 0; i < periods; i++) {
-               if (i == periods - 1 && pos_adj)
-                       ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
-                                        azx_dev, &bdl, ofs,
-                                        period_bytes - pos_adj, 0);
-               else
-                       ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
-                                        azx_dev, &bdl, ofs,
-                                        period_bytes,
-                                        !azx_dev->no_period_wakeup);
-               if (ofs < 0)
-                       goto error;
-       }
-       return 0;
-
- error:
-       snd_printk(KERN_ERR SFX "%s: Too many BDL entries: buffer=%d, period=%d\n",
-                  pci_name(chip->pci), azx_dev->bufsize, period_bytes);
-       return -EINVAL;
-}
-
-/* reset stream */
-static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
-{
-       unsigned char val;
-       int timeout;
-
-       azx_stream_clear(chip, azx_dev);
-
-       azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
-                     SD_CTL_STREAM_RESET);
-       udelay(3);
-       timeout = 300;
-       while (!((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
-              --timeout)
-               ;
-       val &= ~SD_CTL_STREAM_RESET;
-       azx_sd_writeb(azx_dev, SD_CTL, val);
-       udelay(3);
-
-       timeout = 300;
-       /* waiting for hardware to report that the stream is out of reset */
-       while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
-              --timeout)
-               ;
-
-       /* reset first position - may not be synced with hw at this time */
-       *azx_dev->posbuf = 0;
-}
-
-/*
- * set up the SD for streaming
- */
-static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
-{
-       unsigned int val;
-       /* make sure the run bit is zero for SD */
-       azx_stream_clear(chip, azx_dev);
-       /* program the stream_tag */
-       val = azx_sd_readl(azx_dev, SD_CTL);
-       val = (val & ~SD_CTL_STREAM_TAG_MASK) |
-               (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT);
-       if (!azx_snoop(chip))
-               val |= SD_CTL_TRAFFIC_PRIO;
-       azx_sd_writel(azx_dev, SD_CTL, val);
-
-       /* program the length of samples in cyclic buffer */
-       azx_sd_writel(azx_dev, SD_CBL, azx_dev->bufsize);
-
-       /* program the stream format */
-       /* this value needs to be the same as the one programmed */
-       azx_sd_writew(azx_dev, SD_FORMAT, azx_dev->format_val);
-
-       /* program the stream LVI (last valid index) of the BDL */
-       azx_sd_writew(azx_dev, SD_LVI, azx_dev->frags - 1);
-
-       /* program the BDL address */
-       /* lower BDL address */
-       azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
-       /* upper BDL address */
-       azx_sd_writel(azx_dev, SD_BDLPU, upper_32_bits(azx_dev->bdl.addr));
-
-       /* enable the position buffer */
-       if (chip->position_fix[0] != POS_FIX_LPIB ||
-           chip->position_fix[1] != POS_FIX_LPIB) {
-               if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
-                       azx_writel(chip, DPLBASE,
-                               (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
-       }
-
-       /* set the interrupt enable bits in the descriptor control register */
-       azx_sd_writel(azx_dev, SD_CTL,
-                     azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK);
-
-       return 0;
-}
-
-/*
- * Probe the given codec address
- */
-static int probe_codec(struct azx *chip, int addr)
-{
-       unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
-               (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
-       unsigned int res;
-
-       mutex_lock(&chip->bus->cmd_mutex);
-       chip->probing = 1;
-       azx_send_cmd(chip->bus, cmd);
-       res = azx_get_response(chip->bus, addr);
-       chip->probing = 0;
-       mutex_unlock(&chip->bus->cmd_mutex);
-       if (res == -1)
-               return -EIO;
-       snd_printdd(SFX "%s: codec #%d probed OK\n", pci_name(chip->pci), addr);
-       return 0;
-}
-
-static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
-                                struct hda_pcm *cpcm);
-static void azx_stop_chip(struct azx *chip);
-
-static void azx_bus_reset(struct hda_bus *bus)
-{
-       struct azx *chip = bus->private_data;
-
-       bus->in_reset = 1;
-       azx_stop_chip(chip);
-       azx_init_chip(chip, 1);
-#ifdef CONFIG_PM
-       if (chip->initialized) {
-               struct azx_pcm *p;
-               list_for_each_entry(p, &chip->pcm_list, list)
-                       snd_pcm_suspend_all(p->pcm);
-               snd_hda_suspend(chip->bus);
-               snd_hda_resume(chip->bus);
-       }
-#endif
-       bus->in_reset = 0;
-}
-
-static int get_jackpoll_interval(struct azx *chip)
-{
-       int i = jackpoll_ms[chip->dev_index];
-       unsigned int j;
-       if (i == 0)
-               return 0;
-       if (i < 50 || i > 60000)
-               j = 0;
-       else
-               j = msecs_to_jiffies(i);
-       if (j == 0)
-               snd_printk(KERN_WARNING SFX
-                          "jackpoll_ms value out of range: %d\n", i);
-       return j;
-}
-
-/*
- * Codec initialization
- */
-
-/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */
-static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = {
-       [AZX_DRIVER_NVIDIA] = 8,
-       [AZX_DRIVER_TERA] = 1,
-};
-
-static int azx_codec_create(struct azx *chip, const char *model)
-{
-       struct hda_bus_template bus_temp;
-       int c, codecs, err;
-       int max_slots;
-
-       memset(&bus_temp, 0, sizeof(bus_temp));
-       bus_temp.private_data = chip;
-       bus_temp.modelname = model;
-       bus_temp.pci = chip->pci;
-       bus_temp.ops.command = azx_send_cmd;
-       bus_temp.ops.get_response = azx_get_response;
-       bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
-       bus_temp.ops.bus_reset = azx_bus_reset;
-#ifdef CONFIG_PM
-       bus_temp.power_save = &power_save;
-       bus_temp.ops.pm_notify = azx_power_notify;
-#endif
-#ifdef CONFIG_SND_HDA_DSP_LOADER
-       bus_temp.ops.load_dsp_prepare = azx_load_dsp_prepare;
-       bus_temp.ops.load_dsp_trigger = azx_load_dsp_trigger;
-       bus_temp.ops.load_dsp_cleanup = azx_load_dsp_cleanup;
-#endif
-
-       err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
-       if (err < 0)
-               return err;
-
-       if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
-               snd_printd(SFX "%s: Enable delay in RIRB handling\n", pci_name(chip->pci));
-               chip->bus->needs_damn_long_delay = 1;
-       }
-
-       codecs = 0;
-       max_slots = azx_max_codecs[chip->driver_type];
-       if (!max_slots)
-               max_slots = AZX_DEFAULT_CODECS;
-
-       /* First try to probe all given codec slots */
-       for (c = 0; c < max_slots; c++) {
-               if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
-                       if (probe_codec(chip, c) < 0) {
-                               /* Some BIOSen give you wrong codec addresses
-                                * that don't exist
-                                */
-                               snd_printk(KERN_WARNING SFX
-                                          "%s: Codec #%d probe error; "
-                                          "disabling it...\n", pci_name(chip->pci), c);
-                               chip->codec_mask &= ~(1 << c);
-                               /* More badly, accessing to a non-existing
-                                * codec often screws up the controller chip,
-                                * and disturbs the further communications.
-                                * Thus if an error occurs during probing,
-                                * better to reset the controller chip to
-                                * get back to the sanity state.
-                                */
-                               azx_stop_chip(chip);
-                               azx_init_chip(chip, 1);
-                       }
-               }
-       }
-
-       /* AMD chipsets often cause the communication stalls upon certain
-        * sequence like the pin-detection.  It seems that forcing the synced
-        * access works around the stall.  Grrr...
-        */
-       if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
-               snd_printd(SFX "%s: Enable sync_write for stable communication\n",
-                       pci_name(chip->pci));
-               chip->bus->sync_write = 1;
-               chip->bus->allow_bus_reset = 1;
-       }
-
-       /* Then create codec instances */
-       for (c = 0; c < max_slots; c++) {
-               if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
-                       struct hda_codec *codec;
-                       err = snd_hda_codec_new(chip->bus, c, &codec);
-                       if (err < 0)
-                               continue;
-                       codec->jackpoll_interval = get_jackpoll_interval(chip);
-                       codec->beep_mode = chip->beep_mode;
-                       codecs++;
-               }
-       }
-       if (!codecs) {
-               snd_printk(KERN_ERR SFX "%s: no codecs initialized\n", pci_name(chip->pci));
-               return -ENXIO;
-       }
-       return 0;
-}
-
-/* configure each codec instance */
-static int azx_codec_configure(struct azx *chip)
-{
-       struct hda_codec *codec;
-       list_for_each_entry(codec, &chip->bus->codec_list, list) {
-               snd_hda_codec_configure(codec);
-       }
-       return 0;
-}
-
-
-/*
- * PCM support
- */
-
-/* assign a stream for the PCM */
-static inline struct azx_dev *
-azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
-{
-       int dev, i, nums;
-       struct azx_dev *res = NULL;
-       /* make a non-zero unique key for the substream */
-       int key = (substream->pcm->device << 16) | (substream->number << 2) |
-               (substream->stream + 1);
-
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               dev = chip->playback_index_offset;
-               nums = chip->playback_streams;
-       } else {
-               dev = chip->capture_index_offset;
-               nums = chip->capture_streams;
-       }
-       for (i = 0; i < nums; i++, dev++) {
-               struct azx_dev *azx_dev = &chip->azx_dev[dev];
-               dsp_lock(azx_dev);
-               if (!azx_dev->opened && !dsp_is_locked(azx_dev)) {
-                       res = azx_dev;
-                       if (res->assigned_key == key) {
-                               res->opened = 1;
-                               res->assigned_key = key;
-                               dsp_unlock(azx_dev);
-                               return azx_dev;
-                       }
-               }
-               dsp_unlock(azx_dev);
-       }
-       if (res) {
-               dsp_lock(res);
-               res->opened = 1;
-               res->assigned_key = key;
-               dsp_unlock(res);
-       }
-       return res;
-}
-
-/* release the assigned stream */
-static inline void azx_release_device(struct azx_dev *azx_dev)
-{
-       azx_dev->opened = 0;
-}
-
-static cycle_t azx_cc_read(const struct cyclecounter *cc)
-{
-       struct azx_dev *azx_dev = container_of(cc, struct azx_dev, azx_cc);
-       struct snd_pcm_substream *substream = azx_dev->substream;
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx *chip = apcm->chip;
-
-       return azx_readl(chip, WALLCLK);
-}
-
-static void azx_timecounter_init(struct snd_pcm_substream *substream,
-                               bool force, cycle_t last)
-{
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       struct timecounter *tc = &azx_dev->azx_tc;
-       struct cyclecounter *cc = &azx_dev->azx_cc;
-       u64 nsec;
-
-       cc->read = azx_cc_read;
-       cc->mask = CLOCKSOURCE_MASK(32);
-
-       /*
-        * Converting from 24 MHz to ns means applying a 125/3 factor.
-        * To avoid any saturation issues in intermediate operations,
-        * the 125 factor is applied first. The division is applied
-        * last after reading the timecounter value.
-        * Applying the 1/3 factor as part of the multiplication
-        * requires at least 20 bits for a decent precision, however
-        * overflows occur after about 4 hours or less, not a option.
-        */
-
-       cc->mult = 125; /* saturation after 195 years */
-       cc->shift = 0;
-
-       nsec = 0; /* audio time is elapsed time since trigger */
-       timecounter_init(tc, cc, nsec);
-       if (force)
-               /*
-                * force timecounter to use predefined value,
-                * used for synchronized starts
-                */
-               tc->cycle_last = last;
-}
-
-static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream,
-                               u64 nsec)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
-       u64 codec_frames, codec_nsecs;
-
-       if (!hinfo->ops.get_delay)
-               return nsec;
-
-       codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream);
-       codec_nsecs = div_u64(codec_frames * 1000000000LL,
-                             substream->runtime->rate);
-
-       if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-               return nsec + codec_nsecs;
-
-       return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
-}
-
-static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream,
-                               struct timespec *ts)
-{
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       u64 nsec;
-
-       nsec = timecounter_read(&azx_dev->azx_tc);
-       nsec = div_u64(nsec, 3); /* can be optimized */
-       nsec = azx_adjust_codec_delay(substream, nsec);
-
-       *ts = ns_to_timespec(nsec);
-
-       return 0;
-}
-
-static struct snd_pcm_hardware azx_pcm_hw = {
-       .info =                 (SNDRV_PCM_INFO_MMAP |
-                                SNDRV_PCM_INFO_INTERLEAVED |
-                                SNDRV_PCM_INFO_BLOCK_TRANSFER |
-                                SNDRV_PCM_INFO_MMAP_VALID |
-                                /* No full-resume yet implemented */
-                                /* SNDRV_PCM_INFO_RESUME |*/
-                                SNDRV_PCM_INFO_PAUSE |
-                                SNDRV_PCM_INFO_SYNC_START |
-                                SNDRV_PCM_INFO_HAS_WALL_CLOCK |
-                                SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
-       .formats =              SNDRV_PCM_FMTBIT_S16_LE,
-       .rates =                SNDRV_PCM_RATE_48000,
-       .rate_min =             48000,
-       .rate_max =             48000,
-       .channels_min =         2,
-       .channels_max =         2,
-       .buffer_bytes_max =     AZX_MAX_BUF_SIZE,
-       .period_bytes_min =     128,
-       .period_bytes_max =     AZX_MAX_BUF_SIZE / 2,
-       .periods_min =          2,
-       .periods_max =          AZX_MAX_FRAG,
-       .fifo_size =            0,
-};
-
-static int azx_pcm_open(struct snd_pcm_substream *substream)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
-       struct azx *chip = apcm->chip;
-       struct azx_dev *azx_dev;
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       unsigned long flags;
-       int err;
-       int buff_step;
-
-       mutex_lock(&chip->open_mutex);
-       azx_dev = azx_assign_device(chip, substream);
-       if (azx_dev == NULL) {
-               mutex_unlock(&chip->open_mutex);
-               return -EBUSY;
-       }
-       runtime->hw = azx_pcm_hw;
-       runtime->hw.channels_min = hinfo->channels_min;
-       runtime->hw.channels_max = hinfo->channels_max;
-       runtime->hw.formats = hinfo->formats;
-       runtime->hw.rates = hinfo->rates;
-       snd_pcm_limit_hw_rates(runtime);
-       snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
-
-       /* avoid wrap-around with wall-clock */
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
-                               20,
-                               178000000);
-
-       if (chip->align_buffer_size)
-               /* constrain buffer sizes to be multiple of 128
-                  bytes. This is more efficient in terms of memory
-                  access but isn't required by the HDA spec and
-                  prevents users from specifying exact period/buffer
-                  sizes. For example for 44.1kHz, a period size set
-                  to 20ms will be rounded to 19.59ms. */
-               buff_step = 128;
-       else
-               /* Don't enforce steps on buffer sizes, still need to
-                  be multiple of 4 bytes (HDA spec). Tested on Intel
-                  HDA controllers, may not work on all devices where
-                  option needs to be disabled */
-               buff_step = 4;
-
-       snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-                                  buff_step);
-       snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
-                                  buff_step);
-       snd_hda_power_up_d3wait(apcm->codec);
-       err = hinfo->ops.open(hinfo, apcm->codec, substream);
-       if (err < 0) {
-               azx_release_device(azx_dev);
-               snd_hda_power_down(apcm->codec);
-               mutex_unlock(&chip->open_mutex);
-               return err;
-       }
-       snd_pcm_limit_hw_rates(runtime);
-       /* sanity check */
-       if (snd_BUG_ON(!runtime->hw.channels_min) ||
-           snd_BUG_ON(!runtime->hw.channels_max) ||
-           snd_BUG_ON(!runtime->hw.formats) ||
-           snd_BUG_ON(!runtime->hw.rates)) {
-               azx_release_device(azx_dev);
-               hinfo->ops.close(hinfo, apcm->codec, substream);
-               snd_hda_power_down(apcm->codec);
-               mutex_unlock(&chip->open_mutex);
-               return -EINVAL;
-       }
-
-       /* disable WALLCLOCK timestamps for capture streams
-          until we figure out how to handle digital inputs */
-       if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-               runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK;
-
-       spin_lock_irqsave(&chip->reg_lock, flags);
-       azx_dev->substream = substream;
-       azx_dev->running = 0;
-       spin_unlock_irqrestore(&chip->reg_lock, flags);
-
-       runtime->private_data = azx_dev;
-       snd_pcm_set_sync(substream);
-       mutex_unlock(&chip->open_mutex);
-       return 0;
-}
-
-static int azx_pcm_close(struct snd_pcm_substream *substream)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
-       struct azx *chip = apcm->chip;
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       unsigned long flags;
-
-       mutex_lock(&chip->open_mutex);
-       spin_lock_irqsave(&chip->reg_lock, flags);
-       azx_dev->substream = NULL;
-       azx_dev->running = 0;
-       spin_unlock_irqrestore(&chip->reg_lock, flags);
-       azx_release_device(azx_dev);
-       hinfo->ops.close(hinfo, apcm->codec, substream);
-       snd_hda_power_down(apcm->codec);
-       mutex_unlock(&chip->open_mutex);
-       return 0;
-}
-
-static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
-                            struct snd_pcm_hw_params *hw_params)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx *chip = apcm->chip;
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       int ret;
-
-       dsp_lock(azx_dev);
-       if (dsp_is_locked(azx_dev)) {
-               ret = -EBUSY;
-               goto unlock;
-       }
-
-       mark_runtime_wc(chip, azx_dev, substream, false);
-       azx_dev->bufsize = 0;
-       azx_dev->period_bytes = 0;
-       azx_dev->format_val = 0;
-       ret = snd_pcm_lib_malloc_pages(substream,
-                                       params_buffer_bytes(hw_params));
-       if (ret < 0)
-               goto unlock;
-       mark_runtime_wc(chip, azx_dev, substream, true);
- unlock:
-       dsp_unlock(azx_dev);
-       return ret;
-}
-
-static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       struct azx *chip = apcm->chip;
-       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
-
-       /* reset BDL address */
-       dsp_lock(azx_dev);
-       if (!dsp_is_locked(azx_dev)) {
-               azx_sd_writel(azx_dev, SD_BDLPL, 0);
-               azx_sd_writel(azx_dev, SD_BDLPU, 0);
-               azx_sd_writel(azx_dev, SD_CTL, 0);
-               azx_dev->bufsize = 0;
-               azx_dev->period_bytes = 0;
-               azx_dev->format_val = 0;
-       }
-
-       snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
-
-       mark_runtime_wc(chip, azx_dev, substream, false);
-       azx_dev->prepared = 0;
-       dsp_unlock(azx_dev);
-       return snd_pcm_lib_free_pages(substream);
-}
-
-static int azx_pcm_prepare(struct snd_pcm_substream *substream)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx *chip = apcm->chip;
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       unsigned int bufsize, period_bytes, format_val, stream_tag;
-       int err;
-       struct hda_spdif_out *spdif =
-               snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
-       unsigned short ctls = spdif ? spdif->ctls : 0;
-
-       dsp_lock(azx_dev);
-       if (dsp_is_locked(azx_dev)) {
-               err = -EBUSY;
-               goto unlock;
-       }
-
-       azx_stream_reset(chip, azx_dev);
-       format_val = snd_hda_calc_stream_format(runtime->rate,
-                                               runtime->channels,
-                                               runtime->format,
-                                               hinfo->maxbps,
-                                               ctls);
-       if (!format_val) {
-               snd_printk(KERN_ERR SFX
-                          "%s: invalid format_val, rate=%d, ch=%d, format=%d\n",
-                          pci_name(chip->pci), runtime->rate, runtime->channels, runtime->format);
-               err = -EINVAL;
-               goto unlock;
-       }
-
-       bufsize = snd_pcm_lib_buffer_bytes(substream);
-       period_bytes = snd_pcm_lib_period_bytes(substream);
-
-       snd_printdd(SFX "%s: azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
-                   pci_name(chip->pci), bufsize, format_val);
-
-       if (bufsize != azx_dev->bufsize ||
-           period_bytes != azx_dev->period_bytes ||
-           format_val != azx_dev->format_val ||
-           runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
-               azx_dev->bufsize = bufsize;
-               azx_dev->period_bytes = period_bytes;
-               azx_dev->format_val = format_val;
-               azx_dev->no_period_wakeup = runtime->no_period_wakeup;
-               err = azx_setup_periods(chip, substream, azx_dev);
-               if (err < 0)
-                       goto unlock;
-       }
-
-       /* when LPIB delay correction gives a small negative value,
-        * we ignore it; currently set the threshold statically to
-        * 64 frames
-        */
-       if (runtime->period_size > 64)
-               azx_dev->delay_negative_threshold = -frames_to_bytes(runtime, 64);
-       else
-               azx_dev->delay_negative_threshold = 0;
-
-       /* wallclk has 24Mhz clock source */
-       azx_dev->period_wallclk = (((runtime->period_size * 24000) /
-                                               runtime->rate) * 1000);
-       azx_setup_controller(chip, azx_dev);
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
-       else
-               azx_dev->fifo_size = 0;
-
-       stream_tag = azx_dev->stream_tag;
-       /* CA-IBG chips need the playback stream starting from 1 */
-       if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) &&
-           stream_tag > chip->capture_streams)
-               stream_tag -= chip->capture_streams;
-       err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag,
-                                    azx_dev->format_val, substream);
-
- unlock:
-       if (!err)
-               azx_dev->prepared = 1;
-       dsp_unlock(azx_dev);
-       return err;
-}
-
-static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx *chip = apcm->chip;
-       struct azx_dev *azx_dev;
-       struct snd_pcm_substream *s;
-       int rstart = 0, start, nsync = 0, sbits = 0;
-       int nwait, timeout;
-
-       azx_dev = get_azx_dev(substream);
-       trace_azx_pcm_trigger(chip, azx_dev, cmd);
-
-       if (dsp_is_locked(azx_dev) || !azx_dev->prepared)
-               return -EPIPE;
-
-       switch (cmd) {
-       case SNDRV_PCM_TRIGGER_START:
-               rstart = 1;
-       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-       case SNDRV_PCM_TRIGGER_RESUME:
-               start = 1;
-               break;
-       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-       case SNDRV_PCM_TRIGGER_SUSPEND:
-       case SNDRV_PCM_TRIGGER_STOP:
-               start = 0;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       snd_pcm_group_for_each_entry(s, substream) {
-               if (s->pcm->card != substream->pcm->card)
-                       continue;
-               azx_dev = get_azx_dev(s);
-               sbits |= 1 << azx_dev->index;
-               nsync++;
-               snd_pcm_trigger_done(s, substream);
-       }
-
-       spin_lock(&chip->reg_lock);
-
-       /* first, set SYNC bits of corresponding streams */
-       if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
-               azx_writel(chip, OLD_SSYNC,
-                       azx_readl(chip, OLD_SSYNC) | sbits);
-       else
-               azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) | sbits);
-
-       snd_pcm_group_for_each_entry(s, substream) {
-               if (s->pcm->card != substream->pcm->card)
-                       continue;
-               azx_dev = get_azx_dev(s);
-               if (start) {
-                       azx_dev->start_wallclk = azx_readl(chip, WALLCLK);
-                       if (!rstart)
-                               azx_dev->start_wallclk -=
-                                               azx_dev->period_wallclk;
-                       azx_stream_start(chip, azx_dev);
-               } else {
-                       azx_stream_stop(chip, azx_dev);
-               }
-               azx_dev->running = start;
-       }
-       spin_unlock(&chip->reg_lock);
-       if (start) {
-               /* wait until all FIFOs get ready */
-               for (timeout = 5000; timeout; timeout--) {
-                       nwait = 0;
-                       snd_pcm_group_for_each_entry(s, substream) {
-                               if (s->pcm->card != substream->pcm->card)
-                                       continue;
-                               azx_dev = get_azx_dev(s);
-                               if (!(azx_sd_readb(azx_dev, SD_STS) &
-                                     SD_STS_FIFO_READY))
-                                       nwait++;
-                       }
-                       if (!nwait)
-                               break;
-                       cpu_relax();
-               }
-       } else {
-               /* wait until all RUN bits are cleared */
-               for (timeout = 5000; timeout; timeout--) {
-                       nwait = 0;
-                       snd_pcm_group_for_each_entry(s, substream) {
-                               if (s->pcm->card != substream->pcm->card)
-                                       continue;
-                               azx_dev = get_azx_dev(s);
-                               if (azx_sd_readb(azx_dev, SD_CTL) &
-                                   SD_CTL_DMA_START)
-                                       nwait++;
-                       }
-                       if (!nwait)
-                               break;
-                       cpu_relax();
-               }
-       }
-       spin_lock(&chip->reg_lock);
-       /* reset SYNC bits */
-       if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
-               azx_writel(chip, OLD_SSYNC,
-                       azx_readl(chip, OLD_SSYNC) & ~sbits);
-       else
-               azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits);
-       if (start) {
-               azx_timecounter_init(substream, 0, 0);
-               if (nsync > 1) {
-                       cycle_t cycle_last;
-
-                       /* same start cycle for master and group */
-                       azx_dev = get_azx_dev(substream);
-                       cycle_last = azx_dev->azx_tc.cycle_last;
-
-                       snd_pcm_group_for_each_entry(s, substream) {
-                               if (s->pcm->card != substream->pcm->card)
-                                       continue;
-                               azx_timecounter_init(s, 1, cycle_last);
-                       }
-               }
-       }
-       spin_unlock(&chip->reg_lock);
-       return 0;
-}
-
-/* get the current DMA position with correction on VIA chips */
-static unsigned int azx_via_get_position(struct azx *chip,
-                                        struct azx_dev *azx_dev)
-{
-       unsigned int link_pos, mini_pos, bound_pos;
-       unsigned int mod_link_pos, mod_dma_pos, mod_mini_pos;
-       unsigned int fifo_size;
-
-       link_pos = azx_sd_readl(azx_dev, SD_LPIB);
-       if (azx_dev->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               /* Playback, no problem using link position */
-               return link_pos;
-       }
-
-       /* Capture */
-       /* For new chipset,
-        * use mod to get the DMA position just like old chipset
-        */
-       mod_dma_pos = le32_to_cpu(*azx_dev->posbuf);
-       mod_dma_pos %= azx_dev->period_bytes;
-
-       /* azx_dev->fifo_size can't get FIFO size of in stream.
-        * Get from base address + offset.
-        */
-       fifo_size = readw(chip->remap_addr + VIA_IN_STREAM0_FIFO_SIZE_OFFSET);
-
-       if (azx_dev->insufficient) {
-               /* Link position never gather than FIFO size */
-               if (link_pos <= fifo_size)
-                       return 0;
-
-               azx_dev->insufficient = 0;
-       }
-
-       if (link_pos <= fifo_size)
-               mini_pos = azx_dev->bufsize + link_pos - fifo_size;
-       else
-               mini_pos = link_pos - fifo_size;
-
-       /* Find nearest previous boudary */
-       mod_mini_pos = mini_pos % azx_dev->period_bytes;
-       mod_link_pos = link_pos % azx_dev->period_bytes;
-       if (mod_link_pos >= fifo_size)
-               bound_pos = link_pos - mod_link_pos;
-       else if (mod_dma_pos >= mod_mini_pos)
-               bound_pos = mini_pos - mod_mini_pos;
-       else {
-               bound_pos = mini_pos - mod_mini_pos + azx_dev->period_bytes;
-               if (bound_pos >= azx_dev->bufsize)
-                       bound_pos = 0;
-       }
-
-       /* Calculate real DMA position we want */
-       return bound_pos + mod_dma_pos;
-}
-
-static unsigned int azx_get_position(struct azx *chip,
-                                    struct azx_dev *azx_dev,
-                                    bool with_check)
-{
-       struct snd_pcm_substream *substream = azx_dev->substream;
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       unsigned int pos;
-       int stream = substream->stream;
-       struct hda_pcm_stream *hinfo = apcm->hinfo[stream];
-       int delay = 0;
-
-       switch (chip->position_fix[stream]) {
-       case POS_FIX_LPIB:
-               /* read LPIB */
-               pos = azx_sd_readl(azx_dev, SD_LPIB);
-               break;
-       case POS_FIX_VIACOMBO:
-               pos = azx_via_get_position(chip, azx_dev);
-               break;
-       default:
-               /* use the position buffer */
-               pos = le32_to_cpu(*azx_dev->posbuf);
-               if (with_check && chip->position_fix[stream] == POS_FIX_AUTO) {
-                       if (!pos || pos == (u32)-1) {
-                               printk(KERN_WARNING
-                                      "hda-intel: Invalid position buffer, "
-                                      "using LPIB read method instead.\n");
-                               chip->position_fix[stream] = POS_FIX_LPIB;
-                               pos = azx_sd_readl(azx_dev, SD_LPIB);
-                       } else
-                               chip->position_fix[stream] = POS_FIX_POSBUF;
-               }
-               break;
-       }
-
-       if (pos >= azx_dev->bufsize)
-               pos = 0;
-
-       /* calculate runtime delay from LPIB */
-       if (substream->runtime &&
-           chip->position_fix[stream] == POS_FIX_POSBUF &&
-           (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
-               unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB);
-               if (stream == SNDRV_PCM_STREAM_PLAYBACK)
-                       delay = pos - lpib_pos;
-               else
-                       delay = lpib_pos - pos;
-               if (delay < 0) {
-                       if (delay >= azx_dev->delay_negative_threshold)
-                               delay = 0;
-                       else
-                               delay += azx_dev->bufsize;
-               }
-               if (delay >= azx_dev->period_bytes) {
-                       snd_printk(KERN_WARNING SFX
-                                  "%s: Unstable LPIB (%d >= %d); "
-                                  "disabling LPIB delay counting\n",
-                                  pci_name(chip->pci), delay, azx_dev->period_bytes);
-                       delay = 0;
-                       chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
-               }
-               delay = bytes_to_frames(substream->runtime, delay);
+       /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio,
+        * we need to enable snoop.
+        */
+       if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) {
+               dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n",
+                       azx_snoop(chip));
+               update_pci_byte(chip->pci,
+                               ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07,
+                               azx_snoop(chip) ? ATI_SB450_HDAUDIO_ENABLE_SNOOP : 0);
        }
 
-       if (substream->runtime) {
-               if (hinfo->ops.get_delay)
-                       delay += hinfo->ops.get_delay(hinfo, apcm->codec,
-                                                     substream);
-               substream->runtime->delay = delay;
+       /* For NVIDIA HDA, enable snoop */
+       if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) {
+               dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n",
+                       azx_snoop(chip));
+               update_pci_byte(chip->pci,
+                               NVIDIA_HDA_TRANSREG_ADDR,
+                               0x0f, NVIDIA_HDA_ENABLE_COHBITS);
+               update_pci_byte(chip->pci,
+                               NVIDIA_HDA_ISTRM_COH,
+                               0x01, NVIDIA_HDA_ENABLE_COHBIT);
+               update_pci_byte(chip->pci,
+                               NVIDIA_HDA_OSTRM_COH,
+                               0x01, NVIDIA_HDA_ENABLE_COHBIT);
        }
 
-       trace_azx_get_position(chip, azx_dev, pos, delay);
-       return pos;
+       /* Enable SCH/PCH snoop if needed */
+       if (chip->driver_caps & AZX_DCAPS_SCH_SNOOP) {
+               unsigned short snoop;
+               pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
+               if ((!azx_snoop(chip) && !(snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)) ||
+                   (azx_snoop(chip) && (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP))) {
+                       snoop &= ~INTEL_SCH_HDA_DEVC_NOSNOOP;
+                       if (!azx_snoop(chip))
+                               snoop |= INTEL_SCH_HDA_DEVC_NOSNOOP;
+                       pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop);
+                       pci_read_config_word(chip->pci,
+                               INTEL_SCH_HDA_DEVC, &snoop);
+               }
+               dev_dbg(chip->card->dev, "SCH snoop: %s\n",
+                       (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) ?
+                       "Disabled" : "Enabled");
+        }
 }
 
-static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
+static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev);
+
+/* called from IRQ */
+static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev)
 {
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx *chip = apcm->chip;
-       struct azx_dev *azx_dev = get_azx_dev(substream);
-       return bytes_to_frames(substream->runtime,
-                              azx_get_position(chip, azx_dev, false));
+       int ok;
+
+       ok = azx_position_ok(chip, azx_dev);
+       if (ok == 1) {
+               azx_dev->irq_pending = 0;
+               return ok;
+       } else if (ok == 0 && chip->bus && chip->bus->workq) {
+               /* bogus IRQ, process it later */
+               azx_dev->irq_pending = 1;
+               queue_work(chip->bus->workq, &chip->irq_pending_work);
+       }
+       return 0;
 }
 
 /*
@@ -2521,7 +454,7 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
        if (wallclk < (azx_dev->period_wallclk * 5) / 4 &&
            pos % azx_dev->period_bytes > azx_dev->period_bytes / 2)
                /* NG - it's below the first next period boundary */
-               return bdl_pos_adj[chip->dev_index] ? 0 : -1;
+               return chip->bdl_pos_adj[chip->dev_index] ? 0 : -1;
        azx_dev->start_wallclk += wallclk;
        return 1; /* OK, it's fine */
 }
@@ -2535,10 +468,9 @@ static void azx_irq_pending_work(struct work_struct *work)
        int i, pending, ok;
 
        if (!chip->irq_pending_warned) {
-               printk(KERN_WARNING
-                      "hda-intel: IRQ timing workaround is activated "
-                      "for card #%d. Suggest a bigger bdl_pos_adj.\n",
-                      chip->card->number);
+               dev_info(chip->card->dev,
+                        "IRQ timing workaround is activated for card #%d. Suggest a bigger bdl_pos_adj.\n",
+                        chip->card->number);
                chip->irq_pending_warned = 1;
        }
 
@@ -2580,139 +512,14 @@ static void azx_clear_irq_pending(struct azx *chip)
        spin_unlock_irq(&chip->reg_lock);
 }
 
-#ifdef CONFIG_X86
-static int azx_pcm_mmap(struct snd_pcm_substream *substream,
-                       struct vm_area_struct *area)
-{
-       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
-       struct azx *chip = apcm->chip;
-       if (!azx_snoop(chip))
-               area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
-       return snd_pcm_lib_default_mmap(substream, area);
-}
-#else
-#define azx_pcm_mmap   NULL
-#endif
-
-static struct snd_pcm_ops azx_pcm_ops = {
-       .open = azx_pcm_open,
-       .close = azx_pcm_close,
-       .ioctl = snd_pcm_lib_ioctl,
-       .hw_params = azx_pcm_hw_params,
-       .hw_free = azx_pcm_hw_free,
-       .prepare = azx_pcm_prepare,
-       .trigger = azx_pcm_trigger,
-       .pointer = azx_pcm_pointer,
-       .wall_clock =  azx_get_wallclock_tstamp,
-       .mmap = azx_pcm_mmap,
-       .page = snd_pcm_sgbuf_ops_page,
-};
-
-static void azx_pcm_free(struct snd_pcm *pcm)
-{
-       struct azx_pcm *apcm = pcm->private_data;
-       if (apcm) {
-               list_del(&apcm->list);
-               kfree(apcm);
-       }
-}
-
-#define MAX_PREALLOC_SIZE      (32 * 1024 * 1024)
-
-static int
-azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
-                     struct hda_pcm *cpcm)
-{
-       struct azx *chip = bus->private_data;
-       struct snd_pcm *pcm;
-       struct azx_pcm *apcm;
-       int pcm_dev = cpcm->device;
-       unsigned int size;
-       int s, err;
-
-       list_for_each_entry(apcm, &chip->pcm_list, list) {
-               if (apcm->pcm->device == pcm_dev) {
-                       snd_printk(KERN_ERR SFX "%s: PCM %d already exists\n",
-                                  pci_name(chip->pci), pcm_dev);
-                       return -EBUSY;
-               }
-       }
-       err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
-                         cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
-                         cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
-                         &pcm);
-       if (err < 0)
-               return err;
-       strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
-       apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
-       if (apcm == NULL)
-               return -ENOMEM;
-       apcm->chip = chip;
-       apcm->pcm = pcm;
-       apcm->codec = codec;
-       pcm->private_data = apcm;
-       pcm->private_free = azx_pcm_free;
-       if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
-               pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
-       list_add_tail(&apcm->list, &chip->pcm_list);
-       cpcm->pcm = pcm;
-       for (s = 0; s < 2; s++) {
-               apcm->hinfo[s] = &cpcm->stream[s];
-               if (cpcm->stream[s].substreams)
-                       snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
-       }
-       /* buffer pre-allocation */
-       size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
-       if (size > MAX_PREALLOC_SIZE)
-               size = MAX_PREALLOC_SIZE;
-       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
-                                             snd_dma_pci_data(chip->pci),
-                                             size, MAX_PREALLOC_SIZE);
-       return 0;
-}
-
-/*
- * mixer creation - all stuff is implemented in hda module
- */
-static int azx_mixer_create(struct azx *chip)
-{
-       return snd_hda_build_controls(chip->bus);
-}
-
-
-/*
- * initialize SD streams
- */
-static int azx_init_stream(struct azx *chip)
-{
-       int i;
-
-       /* initialize each stream (aka device)
-        * assign the starting bdl address to each stream (device)
-        * and initialize
-        */
-       for (i = 0; i < chip->num_streams; i++) {
-               struct azx_dev *azx_dev = &chip->azx_dev[i];
-               azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
-               /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
-               azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
-               /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
-               azx_dev->sd_int_sta_mask = 1 << i;
-               /* stream tag: must be non-zero and unique */
-               azx_dev->index = i;
-               azx_dev->stream_tag = i + 1;
-       }
-
-       return 0;
-}
-
 static int azx_acquire_irq(struct azx *chip, int do_disconnect)
 {
        if (request_irq(chip->pci->irq, azx_interrupt,
                        chip->msi ? 0 : IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
-                      "disabling device\n", chip->pci->irq);
+               dev_err(chip->card->dev,
+                       "unable to grab IRQ %d, disabling device\n",
+                       chip->pci->irq);
                if (do_disconnect)
                        snd_card_disconnect(chip->card);
                return -1;
@@ -2722,160 +529,7 @@ static int azx_acquire_irq(struct azx *chip, int do_disconnect)
        return 0;
 }
 
-
-static void azx_stop_chip(struct azx *chip)
-{
-       if (!chip->initialized)
-               return;
-
-       /* disable interrupts */
-       azx_int_disable(chip);
-       azx_int_clear(chip);
-
-       /* disable CORB/RIRB */
-       azx_free_cmd_io(chip);
-
-       /* disable position buffer */
-       azx_writel(chip, DPLBASE, 0);
-       azx_writel(chip, DPUBASE, 0);
-
-       chip->initialized = 0;
-}
-
-#ifdef CONFIG_SND_HDA_DSP_LOADER
-/*
- * DSP loading code (e.g. for CA0132)
- */
-
-/* use the first stream for loading DSP */
-static struct azx_dev *
-azx_get_dsp_loader_dev(struct azx *chip)
-{
-       return &chip->azx_dev[chip->playback_index_offset];
-}
-
-static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
-                               unsigned int byte_size,
-                               struct snd_dma_buffer *bufp)
-{
-       u32 *bdl;
-       struct azx *chip = bus->private_data;
-       struct azx_dev *azx_dev;
-       int err;
-
-       azx_dev = azx_get_dsp_loader_dev(chip);
-
-       dsp_lock(azx_dev);
-       spin_lock_irq(&chip->reg_lock);
-       if (azx_dev->running || azx_dev->locked) {
-               spin_unlock_irq(&chip->reg_lock);
-               err = -EBUSY;
-               goto unlock;
-       }
-       azx_dev->prepared = 0;
-       chip->saved_azx_dev = *azx_dev;
-       azx_dev->locked = 1;
-       spin_unlock_irq(&chip->reg_lock);
-
-       err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG,
-                                 snd_dma_pci_data(chip->pci),
-                                 byte_size, bufp);
-       if (err < 0)
-               goto err_alloc;
-
-       mark_pages_wc(chip, bufp, true);
-       azx_dev->bufsize = byte_size;
-       azx_dev->period_bytes = byte_size;
-       azx_dev->format_val = format;
-
-       azx_stream_reset(chip, azx_dev);
-
-       /* reset BDL address */
-       azx_sd_writel(azx_dev, SD_BDLPL, 0);
-       azx_sd_writel(azx_dev, SD_BDLPU, 0);
-
-       azx_dev->frags = 0;
-       bdl = (u32 *)azx_dev->bdl.area;
-       err = setup_bdle(chip, bufp, azx_dev, &bdl, 0, byte_size, 0);
-       if (err < 0)
-               goto error;
-
-       azx_setup_controller(chip, azx_dev);
-       dsp_unlock(azx_dev);
-       return azx_dev->stream_tag;
-
- error:
-       mark_pages_wc(chip, bufp, false);
-       snd_dma_free_pages(bufp);
- err_alloc:
-       spin_lock_irq(&chip->reg_lock);
-       if (azx_dev->opened)
-               *azx_dev = chip->saved_azx_dev;
-       azx_dev->locked = 0;
-       spin_unlock_irq(&chip->reg_lock);
- unlock:
-       dsp_unlock(azx_dev);
-       return err;
-}
-
-static void azx_load_dsp_trigger(struct hda_bus *bus, bool start)
-{
-       struct azx *chip = bus->private_data;
-       struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
-
-       if (start)
-               azx_stream_start(chip, azx_dev);
-       else
-               azx_stream_stop(chip, azx_dev);
-       azx_dev->running = start;
-}
-
-static void azx_load_dsp_cleanup(struct hda_bus *bus,
-                                struct snd_dma_buffer *dmab)
-{
-       struct azx *chip = bus->private_data;
-       struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
-
-       if (!dmab->area || !azx_dev->locked)
-               return;
-
-       dsp_lock(azx_dev);
-       /* reset BDL address */
-       azx_sd_writel(azx_dev, SD_BDLPL, 0);
-       azx_sd_writel(azx_dev, SD_BDLPU, 0);
-       azx_sd_writel(azx_dev, SD_CTL, 0);
-       azx_dev->bufsize = 0;
-       azx_dev->period_bytes = 0;
-       azx_dev->format_val = 0;
-
-       mark_pages_wc(chip, dmab, false);
-       snd_dma_free_pages(dmab);
-       dmab->area = NULL;
-
-       spin_lock_irq(&chip->reg_lock);
-       if (azx_dev->opened)
-               *azx_dev = chip->saved_azx_dev;
-       azx_dev->locked = 0;
-       spin_unlock_irq(&chip->reg_lock);
-       dsp_unlock(azx_dev);
-}
-#endif /* CONFIG_SND_HDA_DSP_LOADER */
-
 #ifdef CONFIG_PM
-/* power-up/down the controller */
-static void azx_power_notify(struct hda_bus *bus, bool power_up)
-{
-       struct azx *chip = bus->private_data;
-
-       if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
-               return;
-
-       if (power_up)
-               pm_runtime_get_sync(&chip->pci->dev);
-       else
-               pm_runtime_put_sync(&chip->pci->dev);
-}
-
 static DEFINE_MUTEX(card_list_lock);
 static LIST_HEAD(card_list);
 
@@ -2969,8 +623,8 @@ static int azx_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "hda-intel: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(chip->card->dev,
+                       "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -3127,36 +781,32 @@ static void azx_vs_set_state(struct pci_dev *pci,
        if (!chip->bus) {
                chip->disabled = disabled;
                if (!disabled) {
-                       snd_printk(KERN_INFO SFX
-                                  "%s: Start delayed initialization\n",
-                                  pci_name(chip->pci));
+                       dev_info(chip->card->dev,
+                                "Start delayed initialization\n");
                        if (azx_probe_continue(chip) < 0) {
-                               snd_printk(KERN_ERR SFX
-                                          "%s: initialization error\n",
-                                          pci_name(chip->pci));
+                               dev_err(chip->card->dev, "initialization error\n");
                                chip->init_failed = true;
                        }
                }
        } else {
-               snd_printk(KERN_INFO SFX
-                          "%s: %s via VGA-switcheroo\n", pci_name(chip->pci),
-                          disabled ? "Disabling" : "Enabling");
+               dev_info(chip->card->dev, "%s via VGA-switcheroo\n",
+                        disabled ? "Disabling" : "Enabling");
                if (disabled) {
-                       pm_runtime_put_sync_suspend(&pci->dev);
-                       azx_suspend(&pci->dev);
+                       pm_runtime_put_sync_suspend(card->dev);
+                       azx_suspend(card->dev);
                        /* when we get suspended by vga switcheroo we end up in D3cold,
                         * however we have no ACPI handle, so pci/acpi can't put us there,
                         * put ourselves there */
                        pci->current_state = PCI_D3cold;
                        chip->disabled = true;
                        if (snd_hda_lock_devices(chip->bus))
-                               snd_printk(KERN_WARNING SFX "%s: Cannot lock devices!\n",
-                                          pci_name(chip->pci));
+                               dev_warn(chip->card->dev,
+                                        "Cannot lock devices!\n");
                } else {
                        snd_hda_unlock_devices(chip->bus);
-                       pm_runtime_get_noresume(&pci->dev);
+                       pm_runtime_get_noresume(card->dev);
                        chip->disabled = false;
-                       azx_resume(&pci->dev);
+                       azx_resume(card->dev);
                }
        }
 }
@@ -3181,9 +831,8 @@ static void init_vga_switcheroo(struct azx *chip)
 {
        struct pci_dev *p = get_bound_vga(chip->pci);
        if (p) {
-               snd_printk(KERN_INFO SFX
-                          "%s: Handle VGA-switcheroo audio client\n",
-                          pci_name(chip->pci));
+               dev_info(chip->card->dev,
+                        "Handle VGA-switcheroo audio client\n");
                chip->use_vga_switcheroo = 1;
                pci_dev_put(p);
        }
@@ -3211,7 +860,8 @@ static int register_vga_switcheroo(struct azx *chip)
        chip->vga_switcheroo_registered = 1;
 
        /* register as an optimus hdmi audio power domain */
-       vga_switcheroo_init_domain_pm_optimus_hdmi_audio(&chip->pci->dev, &chip->hdmi_pm_domain);
+       vga_switcheroo_init_domain_pm_optimus_hdmi_audio(chip->card->dev,
+                                                        &chip->hdmi_pm_domain);
        return 0;
 }
 #else
@@ -3260,21 +910,7 @@ static int azx_free(struct azx *chip)
        if (chip->remap_addr)
                iounmap(chip->remap_addr);
 
-       if (chip->azx_dev) {
-               for (i = 0; i < chip->num_streams; i++)
-                       if (chip->azx_dev[i].bdl.area) {
-                               mark_pages_wc(chip, &chip->azx_dev[i].bdl, false);
-                               snd_dma_free_pages(&chip->azx_dev[i].bdl);
-                       }
-       }
-       if (chip->rb.area) {
-               mark_pages_wc(chip, &chip->rb, false);
-               snd_dma_free_pages(&chip->rb);
-       }
-       if (chip->posbuf.area) {
-               mark_pages_wc(chip, &chip->posbuf, false);
-               snd_dma_free_pages(&chip->posbuf);
-       }
+       azx_free_stream_pages(chip);
        if (chip->region_requested)
                pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
@@ -3374,20 +1010,19 @@ static int check_position_fix(struct azx *chip, int fix)
 
        q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
        if (q) {
-               printk(KERN_INFO
-                      "hda_intel: position_fix set to %d "
-                      "for device %04x:%04x\n",
-                      q->value, q->subvendor, q->subdevice);
+               dev_info(chip->card->dev,
+                        "position_fix set to %d for device %04x:%04x\n",
+                        q->value, q->subvendor, q->subdevice);
                return q->value;
        }
 
        /* Check VIA/ATI HD Audio Controller exist */
        if (chip->driver_caps & AZX_DCAPS_POSFIX_VIA) {
-               snd_printd(SFX "%s: Using VIACOMBO position fix\n", pci_name(chip->pci));
+               dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n");
                return POS_FIX_VIACOMBO;
        }
        if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) {
-               snd_printd(SFX "%s: Using LPIB position fix\n", pci_name(chip->pci));
+               dev_dbg(chip->card->dev, "Using LPIB position fix\n");
                return POS_FIX_LPIB;
        }
        return POS_FIX_AUTO;
@@ -3425,10 +1060,9 @@ static void check_probe_mask(struct azx *chip, int dev)
        if (chip->codec_probe_mask == -1) {
                q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
                if (q) {
-                       printk(KERN_INFO
-                              "hda_intel: probe_mask set to 0x%x "
-                              "for device %04x:%04x\n",
-                              q->value, q->subvendor, q->subdevice);
+                       dev_info(chip->card->dev,
+                                "probe_mask set to 0x%x for device %04x:%04x\n",
+                                q->value, q->subvendor, q->subdevice);
                        chip->codec_probe_mask = q->value;
                }
        }
@@ -3437,8 +1071,8 @@ static void check_probe_mask(struct azx *chip, int dev)
        if (chip->codec_probe_mask != -1 &&
            (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
                chip->codec_mask = chip->codec_probe_mask & 0xff;
-               printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n",
-                      chip->codec_mask);
+               dev_info(chip->card->dev, "codec_mask forced to 0x%x\n",
+                        chip->codec_mask);
        }
 }
 
@@ -3470,16 +1104,16 @@ static void check_msi(struct azx *chip)
        chip->msi = 1;  /* enable MSI as default */
        q = snd_pci_quirk_lookup(chip->pci, msi_black_list);
        if (q) {
-               printk(KERN_INFO
-                      "hda_intel: msi for device %04x:%04x set to %d\n",
-                      q->subvendor, q->subdevice, q->value);
+               dev_info(chip->card->dev,
+                        "msi for device %04x:%04x set to %d\n",
+                        q->subvendor, q->subdevice, q->value);
                chip->msi = q->value;
                return;
        }
 
        /* NVidia chipsets seem to cause troubles with MSI */
        if (chip->driver_caps & AZX_DCAPS_NO_MSI) {
-               printk(KERN_INFO "hda_intel: Disabling MSI\n");
+               dev_info(chip->card->dev, "Disabling MSI\n");
                chip->msi = 0;
        }
 }
@@ -3511,8 +1145,8 @@ static void azx_check_snoop_available(struct azx *chip)
        }
 
        if (snoop != chip->snoop) {
-               snd_printk(KERN_INFO SFX "%s: Force to %s mode\n",
-                          pci_name(chip->pci), snoop ? "snoop" : "non-snoop");
+               dev_info(chip->card->dev, "Force to %s mode\n",
+                        snoop ? "snoop" : "non-snoop");
                chip->snoop = snoop;
        }
 }
@@ -3527,6 +1161,7 @@ static void azx_probe_work(struct work_struct *work)
  */
 static int azx_create(struct snd_card *card, struct pci_dev *pci,
                      int dev, unsigned int driver_caps,
+                     const struct hda_controller_ops *hda_ops,
                      struct azx **rchip)
 {
        static struct snd_device_ops ops = {
@@ -3543,7 +1178,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
 
        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (!chip) {
-               snd_printk(KERN_ERR SFX "%s: Cannot allocate chip\n", pci_name(pci));
+               dev_err(card->dev, "Cannot allocate chip\n");
                pci_disable_device(pci);
                return -ENOMEM;
        }
@@ -3552,11 +1187,13 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
        mutex_init(&chip->open_mutex);
        chip->card = card;
        chip->pci = pci;
+       chip->ops = hda_ops;
        chip->irq = -1;
        chip->driver_caps = driver_caps;
        chip->driver_type = driver_caps & 0xff;
        check_msi(chip);
        chip->dev_index = dev;
+       chip->jackpoll_ms = jackpoll_ms;
        INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work);
        INIT_LIST_HEAD(&chip->pcm_list);
        INIT_LIST_HEAD(&chip->list);
@@ -3588,11 +1225,11 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
                        break;
                }
        }
+       chip->bdl_pos_adj = bdl_pos_adj;
 
        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
        if (err < 0) {
-               snd_printk(KERN_ERR SFX "%s: Error creating device [card]!\n",
-                  pci_name(chip->pci));
+               dev_err(card->dev, "Error creating device [card]!\n");
                azx_free(chip);
                return err;
        }
@@ -3610,7 +1247,7 @@ static int azx_first_init(struct azx *chip)
        int dev = chip->dev_index;
        struct pci_dev *pci = chip->pci;
        struct snd_card *card = chip->card;
-       int i, err;
+       int err;
        unsigned short gcap;
 
 #if BITS_PER_LONG != 64
@@ -3631,7 +1268,7 @@ static int azx_first_init(struct azx *chip)
        chip->addr = pci_resource_start(pci, 0);
        chip->remap_addr = pci_ioremap_bar(pci, 0);
        if (chip->remap_addr == NULL) {
-               snd_printk(KERN_ERR SFX "%s: ioremap error\n", pci_name(chip->pci));
+               dev_err(card->dev, "ioremap error\n");
                return -ENXIO;
        }
 
@@ -3646,7 +1283,7 @@ static int azx_first_init(struct azx *chip)
        synchronize_irq(chip->irq);
 
        gcap = azx_readw(chip, GCAP);
-       snd_printdd(SFX "%s: chipset global capabilities = 0x%x\n", pci_name(chip->pci), gcap);
+       dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap);
 
        /* disable SB600 64bit support for safety */
        if (chip->pci->vendor == PCI_VENDOR_ID_ATI) {
@@ -3663,7 +1300,7 @@ static int azx_first_init(struct azx *chip)
 
        /* disable 64bit DMA address on some devices */
        if (chip->driver_caps & AZX_DCAPS_NO_64BIT) {
-               snd_printd(SFX "%s: Disabling 64bit DMA\n", pci_name(chip->pci));
+               dev_dbg(card->dev, "Disabling 64bit DMA\n");
                gcap &= ~ICH6_GCAP_64OK;
        }
 
@@ -3718,33 +1355,11 @@ static int azx_first_init(struct azx *chip)
        chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
                                GFP_KERNEL);
        if (!chip->azx_dev) {
-               snd_printk(KERN_ERR SFX "%s: cannot malloc azx_dev\n", pci_name(chip->pci));
+               dev_err(card->dev, "cannot malloc azx_dev\n");
                return -ENOMEM;
        }
 
-       for (i = 0; i < chip->num_streams; i++) {
-               dsp_lock_init(&chip->azx_dev[i]);
-               /* allocate memory for the BDL for each stream */
-               err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
-                                         snd_dma_pci_data(chip->pci),
-                                         BDL_SIZE, &chip->azx_dev[i].bdl);
-               if (err < 0) {
-                       snd_printk(KERN_ERR SFX "%s: cannot allocate BDL\n", pci_name(chip->pci));
-                       return -ENOMEM;
-               }
-               mark_pages_wc(chip, &chip->azx_dev[i].bdl, true);
-       }
-       /* allocate memory for the position buffer */
-       err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
-                                 snd_dma_pci_data(chip->pci),
-                                 chip->num_streams * 8, &chip->posbuf);
-       if (err < 0) {
-               snd_printk(KERN_ERR SFX "%s: cannot allocate posbuf\n", pci_name(chip->pci));
-               return -ENOMEM;
-       }
-       mark_pages_wc(chip, &chip->posbuf, true);
-       /* allocate CORB/RIRB */
-       err = azx_alloc_cmd_io(chip);
+       err = azx_alloc_stream_pages(chip);
        if (err < 0)
                return err;
 
@@ -3757,7 +1372,7 @@ static int azx_first_init(struct azx *chip)
 
        /* codec detection */
        if (!chip->codec_mask) {
-               snd_printk(KERN_ERR SFX "%s: no codecs found!\n", pci_name(chip->pci));
+               dev_err(card->dev, "no codecs found!\n");
                return -ENODEV;
        }
 
@@ -3793,8 +1408,7 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
        struct pci_dev *pci = chip->pci;
 
        if (!fw) {
-               snd_printk(KERN_ERR SFX "%s: Cannot load firmware, aborting\n",
-                          pci_name(chip->pci));
+               dev_err(card->dev, "Cannot load firmware, aborting\n");
                goto error;
        }
 
@@ -3812,6 +1426,132 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
 }
 #endif
 
+/*
+ * HDA controller ops.
+ */
+
+/* PCI register access. */
+static void pci_azx_writel(u32 value, u32 __iomem *addr)
+{
+       writel(value, addr);
+}
+
+static u32 pci_azx_readl(u32 __iomem *addr)
+{
+       return readl(addr);
+}
+
+static void pci_azx_writew(u16 value, u16 __iomem *addr)
+{
+       writew(value, addr);
+}
+
+static u16 pci_azx_readw(u16 __iomem *addr)
+{
+       return readw(addr);
+}
+
+static void pci_azx_writeb(u8 value, u8 __iomem *addr)
+{
+       writeb(value, addr);
+}
+
+static u8 pci_azx_readb(u8 __iomem *addr)
+{
+       return readb(addr);
+}
+
+static int disable_msi_reset_irq(struct azx *chip)
+{
+       int err;
+
+       free_irq(chip->irq, chip);
+       chip->irq = -1;
+       pci_disable_msi(chip->pci);
+       chip->msi = 0;
+       err = azx_acquire_irq(chip, 1);
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
+/* DMA page allocation helpers.  */
+static int dma_alloc_pages(struct azx *chip,
+                          int type,
+                          size_t size,
+                          struct snd_dma_buffer *buf)
+{
+       int err;
+
+       err = snd_dma_alloc_pages(type,
+                                 chip->card->dev,
+                                 size, buf);
+       if (err < 0)
+               return err;
+       mark_pages_wc(chip, buf, true);
+       return 0;
+}
+
+static void dma_free_pages(struct azx *chip, struct snd_dma_buffer *buf)
+{
+       mark_pages_wc(chip, buf, false);
+       snd_dma_free_pages(buf);
+}
+
+static int substream_alloc_pages(struct azx *chip,
+                                struct snd_pcm_substream *substream,
+                                size_t size)
+{
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       int ret;
+
+       mark_runtime_wc(chip, azx_dev, substream, false);
+       azx_dev->bufsize = 0;
+       azx_dev->period_bytes = 0;
+       azx_dev->format_val = 0;
+       ret = snd_pcm_lib_malloc_pages(substream, size);
+       if (ret < 0)
+               return ret;
+       mark_runtime_wc(chip, azx_dev, substream, true);
+       return 0;
+}
+
+static int substream_free_pages(struct azx *chip,
+                               struct snd_pcm_substream *substream)
+{
+       struct azx_dev *azx_dev = get_azx_dev(substream);
+       mark_runtime_wc(chip, azx_dev, substream, false);
+       return snd_pcm_lib_free_pages(substream);
+}
+
+static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
+                            struct vm_area_struct *area)
+{
+#ifdef CONFIG_X86
+       struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
+       struct azx *chip = apcm->chip;
+       if (!azx_snoop(chip))
+               area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
+#endif
+}
+
+static const struct hda_controller_ops pci_hda_ops = {
+       .reg_writel = pci_azx_writel,
+       .reg_readl = pci_azx_readl,
+       .reg_writew = pci_azx_writew,
+       .reg_readw = pci_azx_readw,
+       .reg_writeb = pci_azx_writeb,
+       .reg_readb = pci_azx_readb,
+       .disable_msi_reset_irq = disable_msi_reset_irq,
+       .dma_alloc_pages = dma_alloc_pages,
+       .dma_free_pages = dma_free_pages,
+       .substream_alloc_pages = substream_alloc_pages,
+       .substream_free_pages = substream_free_pages,
+       .pcm_mmap_prepare = pcm_mmap_prepare,
+       .position_check = azx_position_check,
+};
+
 static int azx_probe(struct pci_dev *pci,
                     const struct pci_device_id *pci_id)
 {
@@ -3828,15 +1568,15 @@ static int azx_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
-               snd_printk(KERN_ERR "hda-intel: Error creating card!\n");
+               dev_err(&pci->dev, "Error creating card!\n");
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
-       err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
+       err = azx_create(card, pci, dev, pci_id->driver_data,
+                        &pci_hda_ops, &chip);
        if (err < 0)
                goto out_free;
        card->private_data = chip;
@@ -3845,15 +1585,13 @@ static int azx_probe(struct pci_dev *pci,
 
        err = register_vga_switcheroo(chip);
        if (err < 0) {
-               snd_printk(KERN_ERR SFX
-                          "%s: Error registering VGA-switcheroo client\n", pci_name(pci));
+               dev_err(card->dev, "Error registering VGA-switcheroo client\n");
                goto out_free;
        }
 
        if (check_hdmi_disabled(pci)) {
-               snd_printk(KERN_INFO SFX "%s: VGA controller is disabled\n",
-                          pci_name(pci));
-               snd_printk(KERN_INFO SFX "%s: Delaying initialization\n", pci_name(pci));
+               dev_info(card->dev, "VGA controller is disabled\n");
+               dev_info(card->dev, "Delaying initialization\n");
                chip->disabled = true;
        }
 
@@ -3861,8 +1599,8 @@ static int azx_probe(struct pci_dev *pci,
 
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
        if (patch[dev] && *patch[dev]) {
-               snd_printk(KERN_ERR SFX "%s: Applying patch firmware '%s'\n",
-                          pci_name(pci), patch[dev]);
+               dev_info(card->dev, "Applying patch firmware '%s'\n",
+                        patch[dev]);
                err = request_firmware_nowait(THIS_MODULE, true, patch[dev],
                                              &pci->dev, GFP_KERNEL, card,
                                              azx_firmware_cb);
@@ -3874,7 +1612,7 @@ static int azx_probe(struct pci_dev *pci,
 
 #ifndef CONFIG_SND_HDA_I915
        if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
-               snd_printk(KERN_ERR SFX "Haswell must build in CONFIG_SND_HDA_I915\n");
+               dev_err(card->dev, "Haswell must build in CONFIG_SND_HDA_I915\n");
 #endif
 
        if (schedule_probe)
@@ -3890,6 +1628,12 @@ out_free:
        return err;
 }
 
+/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */
+static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = {
+       [AZX_DRIVER_NVIDIA] = 8,
+       [AZX_DRIVER_TERA] = 1,
+};
+
 static int azx_probe_continue(struct azx *chip)
 {
        struct pci_dev *pci = chip->pci;
@@ -3901,7 +1645,8 @@ static int azx_probe_continue(struct azx *chip)
 #ifdef CONFIG_SND_HDA_I915
                err = hda_i915_init();
                if (err < 0) {
-                       snd_printk(KERN_ERR SFX "Error request power-well from i915\n");
+                       dev_err(chip->card->dev,
+                               "Error request power-well from i915\n");
                        goto out_free;
                }
 #endif
@@ -3917,7 +1662,10 @@ static int azx_probe_continue(struct azx *chip)
 #endif
 
        /* create codec instances */
-       err = azx_codec_create(chip, model[dev]);
+       err = azx_codec_create(chip, model[dev],
+                              azx_max_codecs[chip->driver_type],
+                              power_save_addr);
+
        if (err < 0)
                goto out_free;
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
@@ -4142,7 +1890,7 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
          .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA },
        { PCI_DEVICE(0x1102, 0x0012),
          .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA },
-#if !defined(CONFIG_SND_CTXFI) && !defined(CONFIG_SND_CTXFI_MODULE)
+#if !IS_ENABLED(CONFIG_SND_CTXFI)
        /* the following entry conflicts with snd-ctxfi driver,
         * as ctxfi driver mutates from HD-audio to native mode with
         * a special command sequence.
index da80c5bd7fd42ecacaa99e17befd8bef5c40099f..e51d155292155b522df246ee612e156a3d8a0a88 100644 (file)
@@ -597,23 +597,10 @@ int snd_hda_create_hwdep(struct hda_codec *codec);
 static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
 #endif
 
-#if defined(CONFIG_PM) && defined(CONFIG_SND_HDA_HWDEP)
-int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec);
-#else
-static inline int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec)
-{
-       return 0;
-}
-#endif
+void snd_hda_sysfs_init(struct hda_codec *codec);
+void snd_hda_sysfs_clear(struct hda_codec *codec);
 
-#ifdef CONFIG_SND_HDA_RECONFIG
-int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
-#else
-static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
-{
-       return 0;
-}
-#endif
+extern const struct attribute_group *snd_hda_dev_attr_groups[];
 
 #ifdef CONFIG_SND_HDA_RECONFIG
 const 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,
 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
 void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
 
+/*
+ */
+#define codec_err(codec, fmt, args...) dev_err(&(codec)->dev, fmt, ##args)
+#define codec_warn(codec, fmt, args...) dev_warn(&(codec)->dev, fmt, ##args)
+#define codec_info(codec, fmt, args...) dev_info(&(codec)->dev, fmt, ##args)
+#define codec_dbg(codec, fmt, args...) dev_dbg(&(codec)->dev, fmt, ##args)
+
 #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 (file)
index 0000000..ba38b81
--- /dev/null
@@ -0,0 +1,463 @@
+/*
+ *  Common defines for the alsa driver code base for HD Audio.
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ */
+
+#ifndef __SOUND_HDA_PRIV_H
+#define __SOUND_HDA_PRIV_H
+
+#include <linux/clocksource.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+
+/*
+ * registers
+ */
+#define ICH6_REG_GCAP                  0x00
+#define   ICH6_GCAP_64OK       (1 << 0)   /* 64bit address support */
+#define   ICH6_GCAP_NSDO       (3 << 1)   /* # of serial data out signals */
+#define   ICH6_GCAP_BSS                (31 << 3)  /* # of bidirectional streams */
+#define   ICH6_GCAP_ISS                (15 << 8)  /* # of input streams */
+#define   ICH6_GCAP_OSS                (15 << 12) /* # of output streams */
+#define ICH6_REG_VMIN                  0x02
+#define ICH6_REG_VMAJ                  0x03
+#define ICH6_REG_OUTPAY                        0x04
+#define ICH6_REG_INPAY                 0x06
+#define ICH6_REG_GCTL                  0x08
+#define   ICH6_GCTL_RESET      (1 << 0)   /* controller reset */
+#define   ICH6_GCTL_FCNTRL     (1 << 1)   /* flush control */
+#define   ICH6_GCTL_UNSOL      (1 << 8)   /* accept unsol. response enable */
+#define ICH6_REG_WAKEEN                        0x0c
+#define ICH6_REG_STATESTS              0x0e
+#define ICH6_REG_GSTS                  0x10
+#define   ICH6_GSTS_FSTS       (1 << 1)   /* flush status */
+#define ICH6_REG_INTCTL                        0x20
+#define ICH6_REG_INTSTS                        0x24
+#define ICH6_REG_WALLCLK               0x30    /* 24Mhz source */
+#define ICH6_REG_OLD_SSYNC             0x34    /* SSYNC for old ICH */
+#define ICH6_REG_SSYNC                 0x38
+#define ICH6_REG_CORBLBASE             0x40
+#define ICH6_REG_CORBUBASE             0x44
+#define ICH6_REG_CORBWP                        0x48
+#define ICH6_REG_CORBRP                        0x4a
+#define   ICH6_CORBRP_RST      (1 << 15)  /* read pointer reset */
+#define ICH6_REG_CORBCTL               0x4c
+#define   ICH6_CORBCTL_RUN     (1 << 1)   /* enable DMA */
+#define   ICH6_CORBCTL_CMEIE   (1 << 0)   /* enable memory error irq */
+#define ICH6_REG_CORBSTS               0x4d
+#define   ICH6_CORBSTS_CMEI    (1 << 0)   /* memory error indication */
+#define ICH6_REG_CORBSIZE              0x4e
+
+#define ICH6_REG_RIRBLBASE             0x50
+#define ICH6_REG_RIRBUBASE             0x54
+#define ICH6_REG_RIRBWP                        0x58
+#define   ICH6_RIRBWP_RST      (1 << 15)  /* write pointer reset */
+#define ICH6_REG_RINTCNT               0x5a
+#define ICH6_REG_RIRBCTL               0x5c
+#define   ICH6_RBCTL_IRQ_EN    (1 << 0)   /* enable IRQ */
+#define   ICH6_RBCTL_DMA_EN    (1 << 1)   /* enable DMA */
+#define   ICH6_RBCTL_OVERRUN_EN        (1 << 2)   /* enable overrun irq */
+#define ICH6_REG_RIRBSTS               0x5d
+#define   ICH6_RBSTS_IRQ       (1 << 0)   /* response irq */
+#define   ICH6_RBSTS_OVERRUN   (1 << 2)   /* overrun irq */
+#define ICH6_REG_RIRBSIZE              0x5e
+
+#define ICH6_REG_IC                    0x60
+#define ICH6_REG_IR                    0x64
+#define ICH6_REG_IRS                   0x68
+#define   ICH6_IRS_VALID       (1<<1)
+#define   ICH6_IRS_BUSY                (1<<0)
+
+#define ICH6_REG_DPLBASE               0x70
+#define ICH6_REG_DPUBASE               0x74
+#define   ICH6_DPLBASE_ENABLE  0x1     /* Enable position buffer */
+
+/* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
+enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
+
+/* stream register offsets from stream base */
+#define ICH6_REG_SD_CTL                        0x00
+#define ICH6_REG_SD_STS                        0x03
+#define ICH6_REG_SD_LPIB               0x04
+#define ICH6_REG_SD_CBL                        0x08
+#define ICH6_REG_SD_LVI                        0x0c
+#define ICH6_REG_SD_FIFOW              0x0e
+#define ICH6_REG_SD_FIFOSIZE           0x10
+#define ICH6_REG_SD_FORMAT             0x12
+#define ICH6_REG_SD_BDLPL              0x18
+#define ICH6_REG_SD_BDLPU              0x1c
+
+/* PCI space */
+#define ICH6_PCIREG_TCSEL      0x44
+
+/*
+ * other constants
+ */
+
+/* max number of SDs */
+/* ICH, ATI and VIA have 4 playback and 4 capture */
+#define ICH6_NUM_CAPTURE       4
+#define ICH6_NUM_PLAYBACK      4
+
+/* ULI has 6 playback and 5 capture */
+#define ULI_NUM_CAPTURE                5
+#define ULI_NUM_PLAYBACK       6
+
+/* ATI HDMI may have up to 8 playbacks and 0 capture */
+#define ATIHDMI_NUM_CAPTURE    0
+#define ATIHDMI_NUM_PLAYBACK   8
+
+/* TERA has 4 playback and 3 capture */
+#define TERA_NUM_CAPTURE       3
+#define TERA_NUM_PLAYBACK      4
+
+/* this number is statically defined for simplicity */
+#define MAX_AZX_DEV            16
+
+/* max number of fragments - we may use more if allocating more pages for BDL */
+#define BDL_SIZE               4096
+#define AZX_MAX_BDL_ENTRIES    (BDL_SIZE / 16)
+#define AZX_MAX_FRAG           32
+/* max buffer size - no h/w limit, you can increase as you like */
+#define AZX_MAX_BUF_SIZE       (1024*1024*1024)
+
+/* RIRB int mask: overrun[2], response[0] */
+#define RIRB_INT_RESPONSE      0x01
+#define RIRB_INT_OVERRUN       0x04
+#define RIRB_INT_MASK          0x05
+
+/* STATESTS int mask: S3,SD2,SD1,SD0 */
+#define AZX_MAX_CODECS         8
+#define AZX_DEFAULT_CODECS     4
+#define STATESTS_INT_MASK      ((1 << AZX_MAX_CODECS) - 1)
+
+/* SD_CTL bits */
+#define SD_CTL_STREAM_RESET    0x01    /* stream reset bit */
+#define SD_CTL_DMA_START       0x02    /* stream DMA start bit */
+#define SD_CTL_STRIPE          (3 << 16)       /* stripe control */
+#define SD_CTL_TRAFFIC_PRIO    (1 << 18)       /* traffic priority */
+#define SD_CTL_DIR             (1 << 19)       /* bi-directional stream */
+#define SD_CTL_STREAM_TAG_MASK (0xf << 20)
+#define SD_CTL_STREAM_TAG_SHIFT        20
+
+/* SD_CTL and SD_STS */
+#define SD_INT_DESC_ERR                0x10    /* descriptor error interrupt */
+#define SD_INT_FIFO_ERR                0x08    /* FIFO error interrupt */
+#define SD_INT_COMPLETE                0x04    /* completion interrupt */
+#define SD_INT_MASK            (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
+                                SD_INT_COMPLETE)
+
+/* SD_STS */
+#define SD_STS_FIFO_READY      0x20    /* FIFO ready */
+
+/* INTCTL and INTSTS */
+#define ICH6_INT_ALL_STREAM    0xff       /* all stream interrupts */
+#define ICH6_INT_CTRL_EN       0x40000000 /* controller interrupt enable bit */
+#define ICH6_INT_GLOBAL_EN     0x80000000 /* global interrupt enable bit */
+
+/* below are so far hardcoded - should read registers in future */
+#define ICH6_MAX_CORB_ENTRIES  256
+#define ICH6_MAX_RIRB_ENTRIES  256
+
+/* driver quirks (capabilities) */
+/* bits 0-7 are used for indicating driver type */
+#define AZX_DCAPS_NO_TCSEL     (1 << 8)        /* No Intel TCSEL bit */
+#define AZX_DCAPS_NO_MSI       (1 << 9)        /* No MSI support */
+#define AZX_DCAPS_ATI_SNOOP    (1 << 10)       /* ATI snoop enable */
+#define AZX_DCAPS_NVIDIA_SNOOP (1 << 11)       /* Nvidia snoop enable */
+#define AZX_DCAPS_SCH_SNOOP    (1 << 12)       /* SCH/PCH snoop enable */
+#define AZX_DCAPS_RIRB_DELAY   (1 << 13)       /* Long delay in read loop */
+#define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14)     /* Put a delay before read */
+#define AZX_DCAPS_CTX_WORKAROUND (1 << 15)     /* X-Fi workaround */
+#define AZX_DCAPS_POSFIX_LPIB  (1 << 16)       /* Use LPIB as default */
+#define AZX_DCAPS_POSFIX_VIA   (1 << 17)       /* Use VIACOMBO as default */
+#define AZX_DCAPS_NO_64BIT     (1 << 18)       /* No 64bit address */
+#define AZX_DCAPS_SYNC_WRITE   (1 << 19)       /* sync each cmd write */
+#define AZX_DCAPS_OLD_SSYNC    (1 << 20)       /* Old SSYNC reg for ICH */
+#define AZX_DCAPS_BUFSIZE      (1 << 21)       /* no buffer size alignment */
+#define AZX_DCAPS_ALIGN_BUFSIZE        (1 << 22)       /* buffer size alignment */
+#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23)   /* BDLE in 4k boundary */
+#define AZX_DCAPS_COUNT_LPIB_DELAY  (1 << 25)  /* Take LPIB as delay */
+#define AZX_DCAPS_PM_RUNTIME   (1 << 26)       /* runtime PM support */
+#define AZX_DCAPS_I915_POWERWELL (1 << 27)     /* HSW i915 powerwell support */
+
+/* position fix mode */
+enum {
+       POS_FIX_AUTO,
+       POS_FIX_LPIB,
+       POS_FIX_POSBUF,
+       POS_FIX_VIACOMBO,
+       POS_FIX_COMBO,
+};
+
+/* Defines for ATI HD Audio support in SB450 south bridge */
+#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR   0x42
+#define ATI_SB450_HDAUDIO_ENABLE_SNOOP      0x02
+
+/* Defines for Nvidia HDA support */
+#define NVIDIA_HDA_TRANSREG_ADDR      0x4e
+#define NVIDIA_HDA_ENABLE_COHBITS     0x0f
+#define NVIDIA_HDA_ISTRM_COH          0x4d
+#define NVIDIA_HDA_OSTRM_COH          0x4c
+#define NVIDIA_HDA_ENABLE_COHBIT      0x01
+
+/* Defines for Intel SCH HDA snoop control */
+#define INTEL_SCH_HDA_DEVC      0x78
+#define INTEL_SCH_HDA_DEVC_NOSNOOP       (0x1<<11)
+
+/* Define IN stream 0 FIFO size offset in VIA controller */
+#define VIA_IN_STREAM0_FIFO_SIZE_OFFSET        0x90
+/* Define VIA HD Audio Device ID*/
+#define VIA_HDAC_DEVICE_ID             0x3288
+
+/* HD Audio class code */
+#define PCI_CLASS_MULTIMEDIA_HD_AUDIO  0x0403
+
+struct azx_dev {
+       struct snd_dma_buffer bdl; /* BDL buffer */
+       u32 *posbuf;            /* position buffer pointer */
+
+       unsigned int bufsize;   /* size of the play buffer in bytes */
+       unsigned int period_bytes; /* size of the period in bytes */
+       unsigned int frags;     /* number for period in the play buffer */
+       unsigned int fifo_size; /* FIFO size */
+       unsigned long start_wallclk;    /* start + minimum wallclk */
+       unsigned long period_wallclk;   /* wallclk for period */
+
+       void __iomem *sd_addr;  /* stream descriptor pointer */
+
+       u32 sd_int_sta_mask;    /* stream int status mask */
+
+       /* pcm support */
+       struct snd_pcm_substream *substream;    /* assigned substream,
+                                                * set in PCM open
+                                                */
+       unsigned int format_val;        /* format value to be set in the
+                                        * controller and the codec
+                                        */
+       unsigned char stream_tag;       /* assigned stream */
+       unsigned char index;            /* stream index */
+       int assigned_key;               /* last device# key assigned to */
+
+       unsigned int opened:1;
+       unsigned int running:1;
+       unsigned int irq_pending:1;
+       unsigned int prepared:1;
+       unsigned int locked:1;
+       /*
+        * For VIA:
+        *  A flag to ensure DMA position is 0
+        *  when link position is not greater than FIFO size
+        */
+       unsigned int insufficient:1;
+       unsigned int wc_marked:1;
+       unsigned int no_period_wakeup:1;
+
+       struct timecounter  azx_tc;
+       struct cyclecounter azx_cc;
+
+       int delay_negative_threshold;
+
+#ifdef CONFIG_SND_HDA_DSP_LOADER
+       /* Allows dsp load to have sole access to the playback stream. */
+       struct mutex dsp_mutex;
+#endif
+};
+
+/* CORB/RIRB */
+struct azx_rb {
+       u32 *buf;               /* CORB/RIRB buffer
+                                * Each CORB entry is 4byte, RIRB is 8byte
+                                */
+       dma_addr_t addr;        /* physical address of CORB/RIRB buffer */
+       /* for RIRB */
+       unsigned short rp, wp;  /* read/write pointers */
+       int cmds[AZX_MAX_CODECS];       /* number of pending requests */
+       u32 res[AZX_MAX_CODECS];        /* last read value */
+};
+
+struct azx;
+
+/* Functions to read/write to hda registers. */
+struct hda_controller_ops {
+       /* Register Access */
+       void (*reg_writel)(u32 value, u32 __iomem *addr);
+       u32 (*reg_readl)(u32 __iomem *addr);
+       void (*reg_writew)(u16 value, u16 __iomem *addr);
+       u16 (*reg_readw)(u16 __iomem *addr);
+       void (*reg_writeb)(u8 value, u8 __iomem *addr);
+       u8 (*reg_readb)(u8 __iomem *addr);
+       /* Disable msi if supported, PCI only */
+       int (*disable_msi_reset_irq)(struct azx *);
+       /* Allocation ops */
+       int (*dma_alloc_pages)(struct azx *chip,
+                              int type,
+                              size_t size,
+                              struct snd_dma_buffer *buf);
+       void (*dma_free_pages)(struct azx *chip, struct snd_dma_buffer *buf);
+       int (*substream_alloc_pages)(struct azx *chip,
+                                    struct snd_pcm_substream *substream,
+                                    size_t size);
+       int (*substream_free_pages)(struct azx *chip,
+                                   struct snd_pcm_substream *substream);
+       void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream,
+                                struct vm_area_struct *area);
+       /* Check if current position is acceptable */
+       int (*position_check)(struct azx *chip, struct azx_dev *azx_dev);
+};
+
+struct azx_pcm {
+       struct azx *chip;
+       struct snd_pcm *pcm;
+       struct hda_codec *codec;
+       struct hda_pcm_stream *hinfo[2];
+       struct list_head list;
+};
+
+struct azx {
+       struct snd_card *card;
+       struct pci_dev *pci;
+       int dev_index;
+
+       /* chip type specific */
+       int driver_type;
+       unsigned int driver_caps;
+       int playback_streams;
+       int playback_index_offset;
+       int capture_streams;
+       int capture_index_offset;
+       int num_streams;
+       const int *jackpoll_ms; /* per-card jack poll interval */
+
+       /* Register interaction. */
+       const struct hda_controller_ops *ops;
+
+       /* pci resources */
+       unsigned long addr;
+       void __iomem *remap_addr;
+       int irq;
+
+       /* locks */
+       spinlock_t reg_lock;
+       struct mutex open_mutex; /* Prevents concurrent open/close operations */
+       struct completion probe_wait;
+
+       /* streams (x num_streams) */
+       struct azx_dev *azx_dev;
+
+       /* PCM */
+       struct list_head pcm_list; /* azx_pcm list */
+
+       /* HD codec */
+       unsigned short codec_mask;
+       int  codec_probe_mask; /* copied from probe_mask option */
+       struct hda_bus *bus;
+       unsigned int beep_mode;
+
+       /* CORB/RIRB */
+       struct azx_rb corb;
+       struct azx_rb rirb;
+
+       /* CORB/RIRB and position buffers */
+       struct snd_dma_buffer rb;
+       struct snd_dma_buffer posbuf;
+
+#ifdef CONFIG_SND_HDA_PATCH_LOADER
+       const struct firmware *fw;
+#endif
+
+       /* flags */
+       int position_fix[2]; /* for both playback/capture streams */
+       const int *bdl_pos_adj;
+       int poll_count;
+       unsigned int running:1;
+       unsigned int initialized:1;
+       unsigned int single_cmd:1;
+       unsigned int polling_mode:1;
+       unsigned int msi:1;
+       unsigned int irq_pending_warned:1;
+       unsigned int probing:1; /* codec probing phase */
+       unsigned int snoop:1;
+       unsigned int align_buffer_size:1;
+       unsigned int region_requested:1;
+
+       /* VGA-switcheroo setup */
+       unsigned int use_vga_switcheroo:1;
+       unsigned int vga_switcheroo_registered:1;
+       unsigned int init_failed:1; /* delayed init failed */
+       unsigned int disabled:1; /* disabled by VGA-switcher */
+
+       /* for debugging */
+       unsigned int last_cmd[AZX_MAX_CODECS];
+
+       /* for pending irqs */
+       struct work_struct irq_pending_work;
+
+       struct work_struct probe_work;
+
+       /* reboot notifier (for mysterious hangup problem at power-down) */
+       struct notifier_block reboot_notifier;
+
+       /* card list (for power_save trigger) */
+       struct list_head list;
+
+#ifdef CONFIG_SND_HDA_DSP_LOADER
+       struct azx_dev saved_azx_dev;
+#endif
+
+       /* secondary power domain for hdmi audio under vga device */
+       struct dev_pm_domain hdmi_pm_domain;
+};
+
+#ifdef CONFIG_SND_VERBOSE_PRINTK
+#define SFX    /* nop */
+#else
+#define SFX    "hda-intel "
+#endif
+
+#ifdef CONFIG_X86
+#define azx_snoop(chip)                ((chip)->snoop)
+#else
+#define azx_snoop(chip)                true
+#endif
+
+/*
+ * macros for easy use
+ */
+
+#define azx_writel(chip, reg, value) \
+       ((chip)->ops->reg_writel(value, (chip)->remap_addr + ICH6_REG_##reg))
+#define azx_readl(chip, reg) \
+       ((chip)->ops->reg_readl((chip)->remap_addr + ICH6_REG_##reg))
+#define azx_writew(chip, reg, value) \
+       ((chip)->ops->reg_writew(value, (chip)->remap_addr + ICH6_REG_##reg))
+#define azx_readw(chip, reg) \
+       ((chip)->ops->reg_readw((chip)->remap_addr + ICH6_REG_##reg))
+#define azx_writeb(chip, reg, value) \
+       ((chip)->ops->reg_writeb(value, (chip)->remap_addr + ICH6_REG_##reg))
+#define azx_readb(chip, reg) \
+       ((chip)->ops->reg_readb((chip)->remap_addr + ICH6_REG_##reg))
+
+#define azx_sd_writel(chip, dev, reg, value) \
+       ((chip)->ops->reg_writel(value, (dev)->sd_addr + ICH6_REG_##reg))
+#define azx_sd_readl(chip, dev, reg) \
+       ((chip)->ops->reg_readl((dev)->sd_addr + ICH6_REG_##reg))
+#define azx_sd_writew(chip, dev, reg, value) \
+       ((chip)->ops->reg_writew(value, (dev)->sd_addr + ICH6_REG_##reg))
+#define azx_sd_readw(chip, dev, reg) \
+       ((chip)->ops->reg_readw((dev)->sd_addr + ICH6_REG_##reg))
+#define azx_sd_writeb(chip, dev, reg, value) \
+       ((chip)->ops->reg_writeb(value, (dev)->sd_addr + ICH6_REG_##reg))
+#define azx_sd_readb(chip, dev, reg) \
+       ((chip)->ops->reg_readb((dev)->sd_addr + ICH6_REG_##reg))
+
+#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 (file)
index 0000000..e207909
--- /dev/null
@@ -0,0 +1,780 @@
+/*
+ * sysfs interface for HD-audio codec
+ *
+ * Copyright (c) 2014 Takashi Iwai <tiwai@suse.de>
+ *
+ * split from hda_hwdep.c
+ */
+
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/compat.h>
+#include <linux/mutex.h>
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/export.h>
+#include <sound/core.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+#include <sound/hda_hwdep.h>
+#include <sound/minors.h>
+
+/* hint string pair */
+struct hda_hint {
+       const char *key;
+       const char *val;        /* contained in the same alloc as key */
+};
+
+#ifdef CONFIG_PM
+static ssize_t power_on_acct_show(struct device *dev,
+                                 struct device_attribute *attr,
+                                 char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       snd_hda_update_power_acct(codec);
+       return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
+}
+
+static ssize_t power_off_acct_show(struct device *dev,
+                                  struct device_attribute *attr,
+                                  char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       snd_hda_update_power_acct(codec);
+       return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
+}
+
+static DEVICE_ATTR_RO(power_on_acct);
+static DEVICE_ATTR_RO(power_off_acct);
+#endif /* CONFIG_PM */
+
+#define CODEC_INFO_SHOW(type)                                  \
+static ssize_t type##_show(struct device *dev,                 \
+                          struct device_attribute *attr,       \
+                          char *buf)                           \
+{                                                              \
+       struct hda_codec *codec = dev_get_drvdata(dev);         \
+       return sprintf(buf, "0x%x\n", codec->type);             \
+}
+
+#define CODEC_INFO_STR_SHOW(type)                              \
+static ssize_t type##_show(struct device *dev,                 \
+                            struct device_attribute *attr,     \
+                                       char *buf)              \
+{                                                              \
+       struct hda_codec *codec = dev_get_drvdata(dev);         \
+       return sprintf(buf, "%s\n",                             \
+                      codec->type ? codec->type : "");         \
+}
+
+CODEC_INFO_SHOW(vendor_id);
+CODEC_INFO_SHOW(subsystem_id);
+CODEC_INFO_SHOW(revision_id);
+CODEC_INFO_SHOW(afg);
+CODEC_INFO_SHOW(mfg);
+CODEC_INFO_STR_SHOW(vendor_name);
+CODEC_INFO_STR_SHOW(chip_name);
+CODEC_INFO_STR_SHOW(modelname);
+
+static ssize_t pin_configs_show(struct hda_codec *codec,
+                               struct snd_array *list,
+                               char *buf)
+{
+       int i, len = 0;
+       mutex_lock(&codec->user_mutex);
+       for (i = 0; i < list->used; i++) {
+               struct hda_pincfg *pin = snd_array_elem(list, i);
+               len += sprintf(buf + len, "0x%02x 0x%08x\n",
+                              pin->nid, pin->cfg);
+       }
+       mutex_unlock(&codec->user_mutex);
+       return len;
+}
+
+static ssize_t init_pin_configs_show(struct device *dev,
+                                    struct device_attribute *attr,
+                                    char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       return pin_configs_show(codec, &codec->init_pins, buf);
+}
+
+static ssize_t driver_pin_configs_show(struct device *dev,
+                                      struct device_attribute *attr,
+                                      char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       return pin_configs_show(codec, &codec->driver_pins, buf);
+}
+
+#ifdef CONFIG_SND_HDA_RECONFIG
+
+/*
+ * sysfs interface
+ */
+
+static int clear_codec(struct hda_codec *codec)
+{
+       int err;
+
+       err = snd_hda_codec_reset(codec);
+       if (err < 0) {
+               codec_err(codec, "The codec is being used, can't free.\n");
+               return err;
+       }
+       snd_hda_sysfs_clear(codec);
+       return 0;
+}
+
+static int reconfig_codec(struct hda_codec *codec)
+{
+       int err;
+
+       snd_hda_power_up(codec);
+       codec_info(codec, "hda-codec: reconfiguring\n");
+       err = snd_hda_codec_reset(codec);
+       if (err < 0) {
+               codec_err(codec,
+                          "The codec is being used, can't reconfigure.\n");
+               goto error;
+       }
+       err = snd_hda_codec_configure(codec);
+       if (err < 0)
+               goto error;
+       /* rebuild PCMs */
+       err = snd_hda_codec_build_pcms(codec);
+       if (err < 0)
+               goto error;
+       /* rebuild mixers */
+       err = snd_hda_codec_build_controls(codec);
+       if (err < 0)
+               goto error;
+       err = snd_card_register(codec->bus->card);
+ error:
+       snd_hda_power_down(codec);
+       return err;
+}
+
+/*
+ * allocate a string at most len chars, and remove the trailing EOL
+ */
+static char *kstrndup_noeol(const char *src, size_t len)
+{
+       char *s = kstrndup(src, len, GFP_KERNEL);
+       char *p;
+       if (!s)
+               return NULL;
+       p = strchr(s, '\n');
+       if (p)
+               *p = 0;
+       return s;
+}
+
+#define CODEC_INFO_STORE(type)                                 \
+static ssize_t type##_store(struct device *dev,                        \
+                           struct device_attribute *attr,      \
+                           const char *buf, size_t count)      \
+{                                                              \
+       struct hda_codec *codec = dev_get_drvdata(dev);         \
+       unsigned long val;                                      \
+       int err = kstrtoul(buf, 0, &val);                       \
+       if (err < 0)                                            \
+               return err;                                     \
+       codec->type = val;                                      \
+       return count;                                           \
+}
+
+#define CODEC_INFO_STR_STORE(type)                             \
+static ssize_t type##_store(struct device *dev,                        \
+                           struct device_attribute *attr,      \
+                           const char *buf, size_t count)      \
+{                                                              \
+       struct hda_codec *codec = dev_get_drvdata(dev);         \
+       char *s = kstrndup_noeol(buf, 64);                      \
+       if (!s)                                                 \
+               return -ENOMEM;                                 \
+       kfree(codec->type);                                     \
+       codec->type = s;                                        \
+       return count;                                           \
+}
+
+CODEC_INFO_STORE(vendor_id);
+CODEC_INFO_STORE(subsystem_id);
+CODEC_INFO_STORE(revision_id);
+CODEC_INFO_STR_STORE(vendor_name);
+CODEC_INFO_STR_STORE(chip_name);
+CODEC_INFO_STR_STORE(modelname);
+
+#define CODEC_ACTION_STORE(type)                               \
+static ssize_t type##_store(struct device *dev,                        \
+                           struct device_attribute *attr,      \
+                           const char *buf, size_t count)      \
+{                                                              \
+       struct hda_codec *codec = dev_get_drvdata(dev);         \
+       int err = 0;                                            \
+       if (*buf)                                               \
+               err = type##_codec(codec);                      \
+       return err < 0 ? err : count;                           \
+}
+
+CODEC_ACTION_STORE(reconfig);
+CODEC_ACTION_STORE(clear);
+
+static ssize_t init_verbs_show(struct device *dev,
+                              struct device_attribute *attr,
+                              char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       int i, len = 0;
+       mutex_lock(&codec->user_mutex);
+       for (i = 0; i < codec->init_verbs.used; i++) {
+               struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
+               len += snprintf(buf + len, PAGE_SIZE - len,
+                               "0x%02x 0x%03x 0x%04x\n",
+                               v->nid, v->verb, v->param);
+       }
+       mutex_unlock(&codec->user_mutex);
+       return len;
+}
+
+static int parse_init_verbs(struct hda_codec *codec, const char *buf)
+{
+       struct hda_verb *v;
+       int nid, verb, param;
+
+       if (sscanf(buf, "%i %i %i", &nid, &verb, &param) != 3)
+               return -EINVAL;
+       if (!nid || !verb)
+               return -EINVAL;
+       mutex_lock(&codec->user_mutex);
+       v = snd_array_new(&codec->init_verbs);
+       if (!v) {
+               mutex_unlock(&codec->user_mutex);
+               return -ENOMEM;
+       }
+       v->nid = nid;
+       v->verb = verb;
+       v->param = param;
+       mutex_unlock(&codec->user_mutex);
+       return 0;
+}
+
+static ssize_t init_verbs_store(struct device *dev,
+                               struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       int err = parse_init_verbs(codec, buf);
+       if (err < 0)
+               return err;
+       return count;
+}
+
+static ssize_t hints_show(struct device *dev,
+                         struct device_attribute *attr,
+                         char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       int i, len = 0;
+       mutex_lock(&codec->user_mutex);
+       for (i = 0; i < codec->hints.used; i++) {
+               struct hda_hint *hint = snd_array_elem(&codec->hints, i);
+               len += snprintf(buf + len, PAGE_SIZE - len,
+                               "%s = %s\n", hint->key, hint->val);
+       }
+       mutex_unlock(&codec->user_mutex);
+       return len;
+}
+
+static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
+{
+       int i;
+
+       for (i = 0; i < codec->hints.used; i++) {
+               struct hda_hint *hint = snd_array_elem(&codec->hints, i);
+               if (!strcmp(hint->key, key))
+                       return hint;
+       }
+       return NULL;
+}
+
+static void remove_trail_spaces(char *str)
+{
+       char *p;
+       if (!*str)
+               return;
+       p = str + strlen(str) - 1;
+       for (; isspace(*p); p--) {
+               *p = 0;
+               if (p == str)
+                       return;
+       }
+}
+
+#define MAX_HINTS      1024
+
+static int parse_hints(struct hda_codec *codec, const char *buf)
+{
+       char *key, *val;
+       struct hda_hint *hint;
+       int err = 0;
+
+       buf = skip_spaces(buf);
+       if (!*buf || *buf == '#' || *buf == '\n')
+               return 0;
+       if (*buf == '=')
+               return -EINVAL;
+       key = kstrndup_noeol(buf, 1024);
+       if (!key)
+               return -ENOMEM;
+       /* extract key and val */
+       val = strchr(key, '=');
+       if (!val) {
+               kfree(key);
+               return -EINVAL;
+       }
+       *val++ = 0;
+       val = skip_spaces(val);
+       remove_trail_spaces(key);
+       remove_trail_spaces(val);
+       mutex_lock(&codec->user_mutex);
+       hint = get_hint(codec, key);
+       if (hint) {
+               /* replace */
+               kfree(hint->key);
+               hint->key = key;
+               hint->val = val;
+               goto unlock;
+       }
+       /* allocate a new hint entry */
+       if (codec->hints.used >= MAX_HINTS)
+               hint = NULL;
+       else
+               hint = snd_array_new(&codec->hints);
+       if (hint) {
+               hint->key = key;
+               hint->val = val;
+       } else {
+               err = -ENOMEM;
+       }
+ unlock:
+       mutex_unlock(&codec->user_mutex);
+       if (err)
+               kfree(key);
+       return err;
+}
+
+static ssize_t hints_store(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       int err = parse_hints(codec, buf);
+       if (err < 0)
+               return err;
+       return count;
+}
+
+static ssize_t user_pin_configs_show(struct device *dev,
+                                    struct device_attribute *attr,
+                                    char *buf)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       return pin_configs_show(codec, &codec->user_pins, buf);
+}
+
+#define MAX_PIN_CONFIGS                32
+
+static int parse_user_pin_configs(struct hda_codec *codec, const char *buf)
+{
+       int nid, cfg, err;
+
+       if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
+               return -EINVAL;
+       if (!nid)
+               return -EINVAL;
+       mutex_lock(&codec->user_mutex);
+       err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
+       mutex_unlock(&codec->user_mutex);
+       return err;
+}
+
+static ssize_t user_pin_configs_store(struct device *dev,
+                                     struct device_attribute *attr,
+                                     const char *buf, size_t count)
+{
+       struct hda_codec *codec = dev_get_drvdata(dev);
+       int err = parse_user_pin_configs(codec, buf);
+       if (err < 0)
+               return err;
+       return count;
+}
+
+/* sysfs attributes exposed only when CONFIG_SND_HDA_RECONFIG=y */
+static DEVICE_ATTR_RW(init_verbs);
+static DEVICE_ATTR_RW(hints);
+static DEVICE_ATTR_RW(user_pin_configs);
+static DEVICE_ATTR_WO(reconfig);
+static DEVICE_ATTR_WO(clear);
+
+/*
+ * Look for hint string
+ */
+const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
+{
+       struct hda_hint *hint = get_hint(codec, key);
+       return hint ? hint->val : NULL;
+}
+EXPORT_SYMBOL_GPL(snd_hda_get_hint);
+
+int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
+{
+       const char *p;
+       int ret;
+
+       mutex_lock(&codec->user_mutex);
+       p = snd_hda_get_hint(codec, key);
+       if (!p || !*p)
+               ret = -ENOENT;
+       else {
+               switch (toupper(*p)) {
+               case 'T': /* true */
+               case 'Y': /* yes */
+               case '1':
+                       ret = 1;
+                       break;
+               default:
+                       ret = 0;
+                       break;
+               }
+       }
+       mutex_unlock(&codec->user_mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_hda_get_bool_hint);
+
+int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
+{
+       const char *p;
+       unsigned long val;
+       int ret;
+
+       mutex_lock(&codec->user_mutex);
+       p = snd_hda_get_hint(codec, key);
+       if (!p)
+               ret = -ENOENT;
+       else if (kstrtoul(p, 0, &val))
+               ret = -EINVAL;
+       else {
+               *valp = val;
+               ret = 0;
+       }
+       mutex_unlock(&codec->user_mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_hda_get_int_hint);
+#endif /* CONFIG_SND_HDA_RECONFIG */
+
+/*
+ * common sysfs attributes
+ */
+#ifdef CONFIG_SND_HDA_RECONFIG
+#define RECONFIG_DEVICE_ATTR(name)     DEVICE_ATTR_RW(name)
+#else
+#define RECONFIG_DEVICE_ATTR(name)     DEVICE_ATTR_RO(name)
+#endif
+static RECONFIG_DEVICE_ATTR(vendor_id);
+static RECONFIG_DEVICE_ATTR(subsystem_id);
+static RECONFIG_DEVICE_ATTR(revision_id);
+static DEVICE_ATTR_RO(afg);
+static DEVICE_ATTR_RO(mfg);
+static RECONFIG_DEVICE_ATTR(vendor_name);
+static RECONFIG_DEVICE_ATTR(chip_name);
+static RECONFIG_DEVICE_ATTR(modelname);
+static DEVICE_ATTR_RO(init_pin_configs);
+static DEVICE_ATTR_RO(driver_pin_configs);
+
+
+#ifdef CONFIG_SND_HDA_PATCH_LOADER
+
+/* parser mode */
+enum {
+       LINE_MODE_NONE,
+       LINE_MODE_CODEC,
+       LINE_MODE_MODEL,
+       LINE_MODE_PINCFG,
+       LINE_MODE_VERB,
+       LINE_MODE_HINT,
+       LINE_MODE_VENDOR_ID,
+       LINE_MODE_SUBSYSTEM_ID,
+       LINE_MODE_REVISION_ID,
+       LINE_MODE_CHIP_NAME,
+       NUM_LINE_MODES,
+};
+
+static inline int strmatch(const char *a, const char *b)
+{
+       return strnicmp(a, b, strlen(b)) == 0;
+}
+
+/* parse the contents after the line "[codec]"
+ * accept only the line with three numbers, and assign the current codec
+ */
+static void parse_codec_mode(char *buf, struct hda_bus *bus,
+                            struct hda_codec **codecp)
+{
+       int vendorid, subid, caddr;
+       struct hda_codec *codec;
+
+       *codecp = NULL;
+       if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
+               list_for_each_entry(codec, &bus->codec_list, list) {
+                       if ((vendorid <= 0 || codec->vendor_id == vendorid) &&
+                           (subid <= 0 || codec->subsystem_id == subid) &&
+                           codec->addr == caddr) {
+                               *codecp = codec;
+                               break;
+                       }
+               }
+       }
+}
+
+/* parse the contents after the other command tags, [pincfg], [verb],
+ * [vendor_id], [subsystem_id], [revision_id], [chip_name], [hint] and [model]
+ * just pass to the sysfs helper (only when any codec was specified)
+ */
+static void parse_pincfg_mode(char *buf, struct hda_bus *bus,
+                             struct hda_codec **codecp)
+{
+       parse_user_pin_configs(*codecp, buf);
+}
+
+static void parse_verb_mode(char *buf, struct hda_bus *bus,
+                           struct hda_codec **codecp)
+{
+       parse_init_verbs(*codecp, buf);
+}
+
+static void parse_hint_mode(char *buf, struct hda_bus *bus,
+                           struct hda_codec **codecp)
+{
+       parse_hints(*codecp, buf);
+}
+
+static void parse_model_mode(char *buf, struct hda_bus *bus,
+                            struct hda_codec **codecp)
+{
+       kfree((*codecp)->modelname);
+       (*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
+}
+
+static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
+                                struct hda_codec **codecp)
+{
+       kfree((*codecp)->chip_name);
+       (*codecp)->chip_name = kstrdup(buf, GFP_KERNEL);
+}
+
+#define DEFINE_PARSE_ID_MODE(name) \
+static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
+                                struct hda_codec **codecp) \
+{ \
+       unsigned long val; \
+       if (!kstrtoul(buf, 0, &val)) \
+               (*codecp)->name = val; \
+}
+
+DEFINE_PARSE_ID_MODE(vendor_id);
+DEFINE_PARSE_ID_MODE(subsystem_id);
+DEFINE_PARSE_ID_MODE(revision_id);
+
+
+struct hda_patch_item {
+       const char *tag;
+       const char *alias;
+       void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc);
+};
+
+static struct hda_patch_item patch_items[NUM_LINE_MODES] = {
+       [LINE_MODE_CODEC] = {
+               .tag = "[codec]",
+               .parser = parse_codec_mode,
+       },
+       [LINE_MODE_MODEL] = {
+               .tag = "[model]",
+               .parser = parse_model_mode,
+       },
+       [LINE_MODE_VERB] = {
+               .tag = "[verb]",
+               .alias = "[init_verbs]",
+               .parser = parse_verb_mode,
+       },
+       [LINE_MODE_PINCFG] = {
+               .tag = "[pincfg]",
+               .alias = "[user_pin_configs]",
+               .parser = parse_pincfg_mode,
+       },
+       [LINE_MODE_HINT] = {
+               .tag = "[hint]",
+               .alias = "[hints]",
+               .parser = parse_hint_mode
+       },
+       [LINE_MODE_VENDOR_ID] = {
+               .tag = "[vendor_id]",
+               .parser = parse_vendor_id_mode,
+       },
+       [LINE_MODE_SUBSYSTEM_ID] = {
+               .tag = "[subsystem_id]",
+               .parser = parse_subsystem_id_mode,
+       },
+       [LINE_MODE_REVISION_ID] = {
+               .tag = "[revision_id]",
+               .parser = parse_revision_id_mode,
+       },
+       [LINE_MODE_CHIP_NAME] = {
+               .tag = "[chip_name]",
+               .parser = parse_chip_name_mode,
+       },
+};
+
+/* check the line starting with '[' -- change the parser mode accodingly */
+static int parse_line_mode(char *buf, struct hda_bus *bus)
+{
+       int i;
+       for (i = 0; i < ARRAY_SIZE(patch_items); i++) {
+               if (!patch_items[i].tag)
+                       continue;
+               if (strmatch(buf, patch_items[i].tag))
+                       return i;
+               if (patch_items[i].alias && strmatch(buf, patch_items[i].alias))
+                       return i;
+       }
+       return LINE_MODE_NONE;
+}
+
+/* copy one line from the buffer in fw, and update the fields in fw
+ * return zero if it reaches to the end of the buffer, or non-zero
+ * if successfully copied a line
+ *
+ * the spaces at the beginning and the end of the line are stripped
+ */
+static int get_line_from_fw(char *buf, int size, size_t *fw_size_p,
+                           const void **fw_data_p)
+{
+       int len;
+       size_t fw_size = *fw_size_p;
+       const char *p = *fw_data_p;
+
+       while (isspace(*p) && fw_size) {
+               p++;
+               fw_size--;
+       }
+       if (!fw_size)
+               return 0;
+
+       for (len = 0; len < fw_size; len++) {
+               if (!*p)
+                       break;
+               if (*p == '\n') {
+                       p++;
+                       len++;
+                       break;
+               }
+               if (len < size)
+                       *buf++ = *p++;
+       }
+       *buf = 0;
+       *fw_size_p = fw_size - len;
+       *fw_data_p = p;
+       remove_trail_spaces(buf);
+       return 1;
+}
+
+/*
+ * load a "patch" firmware file and parse it
+ */
+int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf)
+{
+       char buf[128];
+       struct hda_codec *codec;
+       int line_mode;
+
+       line_mode = LINE_MODE_NONE;
+       codec = NULL;
+       while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) {
+               if (!*buf || *buf == '#' || *buf == '\n')
+                       continue;
+               if (*buf == '[')
+                       line_mode = parse_line_mode(buf, bus);
+               else if (patch_items[line_mode].parser &&
+                        (codec || line_mode <= LINE_MODE_CODEC))
+                       patch_items[line_mode].parser(buf, bus, &codec);
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_hda_load_patch);
+#endif /* CONFIG_SND_HDA_PATCH_LOADER */
+
+/*
+ * sysfs entries
+ */
+static struct attribute *hda_dev_attrs[] = {
+       &dev_attr_vendor_id.attr,
+       &dev_attr_subsystem_id.attr,
+       &dev_attr_revision_id.attr,
+       &dev_attr_afg.attr,
+       &dev_attr_mfg.attr,
+       &dev_attr_vendor_name.attr,
+       &dev_attr_chip_name.attr,
+       &dev_attr_modelname.attr,
+       &dev_attr_init_pin_configs.attr,
+       &dev_attr_driver_pin_configs.attr,
+#ifdef CONFIG_PM
+       &dev_attr_power_on_acct.attr,
+       &dev_attr_power_off_acct.attr,
+#endif
+#ifdef CONFIG_SND_HDA_RECONFIG
+       &dev_attr_init_verbs.attr,
+       &dev_attr_hints.attr,
+       &dev_attr_user_pin_configs.attr,
+       &dev_attr_reconfig.attr,
+       &dev_attr_clear.attr,
+#endif
+       NULL
+};
+
+static struct attribute_group hda_dev_attr_group = {
+       .attrs  = hda_dev_attrs,
+};
+
+const struct attribute_group *snd_hda_dev_attr_groups[] = {
+       &hda_dev_attr_group,
+       NULL
+};
+
+void snd_hda_sysfs_init(struct hda_codec *codec)
+{
+       mutex_init(&codec->user_mutex);
+#ifdef CONFIG_SND_HDA_RECONFIG
+       snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
+       snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
+       snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
+#endif
+}
+
+void snd_hda_sysfs_clear(struct hda_codec *codec)
+{
+#ifdef CONFIG_SND_HDA_RECONFIG
+       int i;
+
+       /* clear init verbs */
+       snd_array_free(&codec->init_verbs);
+       /* clear hints */
+       for (i = 0; i < codec->hints.used; i++) {
+               struct hda_hint *hint = snd_array_elem(&codec->hints, i);
+               kfree(hint->key); /* we don't need to free hint->val */
+       }
+       snd_array_free(&codec->hints);
+       snd_array_free(&codec->user_pins);
+#endif
+}
index 8ed0bcc0138637e69e19ff7056b99a86fac09fa6..40ba06eb44af47651b510c8f7dbad6cd214ce165 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/module.h>
 
 #include <sound/core.h>
index 30b3a4bc06eef1739c64d85e8e3d67c2a6154c38..5e65999e0d8e6a410061fe87fd287bd695b7305e 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/module.h>
 #include <sound/core.h>
 #include "hda_codec.h"
index 46ecdbb9053f337ee6f1b199d9babdeb043d72d5..092f2bd030bdc51cf93265dab1e7dc93fb6908df 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/firmware.h>
@@ -868,7 +867,7 @@ static int chipio_write_data_multiple(struct hda_codec *codec,
        int status = 0;
 
        if (data == NULL) {
-               snd_printdd(KERN_ERR "chipio_write_data null ptr\n");
+               codec_dbg(codec, "chipio_write_data null ptr\n");
                return -EINVAL;
        }
 
@@ -1407,12 +1406,12 @@ static int dspio_scp(struct hda_codec *codec,
                return -EINVAL;
 
        if (dir == SCP_GET && reply == NULL) {
-               snd_printdd(KERN_ERR "dspio_scp get but has no buffer\n");
+               codec_dbg(codec, "dspio_scp get but has no buffer\n");
                return -EINVAL;
        }
 
        if (reply != NULL && (reply_len == NULL || (*reply_len == 0))) {
-               snd_printdd(KERN_ERR "dspio_scp bad resp buf len parms\n");
+               codec_dbg(codec, "dspio_scp bad resp buf len parms\n");
                return -EINVAL;
        }
 
@@ -1430,7 +1429,7 @@ static int dspio_scp(struct hda_codec *codec,
                                        sizeof(scp_reply), &ret_bytes);
 
        if (status < 0) {
-               snd_printdd(KERN_ERR "dspio_scp: send scp msg failed\n");
+               codec_dbg(codec, "dspio_scp: send scp msg failed\n");
                return status;
        }
 
@@ -1449,17 +1448,17 @@ static int dspio_scp(struct hda_codec *codec,
                                        / sizeof(unsigned int);
 
                if (*reply_len < ret_size*sizeof(unsigned int)) {
-                       snd_printdd(KERN_ERR "reply too long for buf\n");
+                       codec_dbg(codec, "reply too long for buf\n");
                        return -EINVAL;
                } else if (ret_size != reply_data_size) {
-                       snd_printdd(KERN_ERR "RetLen and HdrLen .NE.\n");
+                       codec_dbg(codec, "RetLen and HdrLen .NE.\n");
                        return -EINVAL;
                } else {
                        *reply_len = ret_size*sizeof(unsigned int);
                        memcpy(reply, scp_reply.data, *reply_len);
                }
        } else {
-               snd_printdd(KERN_ERR "reply ill-formed or errflag set\n");
+               codec_dbg(codec, "reply ill-formed or errflag set\n");
                return -EIO;
        }
 
@@ -1489,22 +1488,22 @@ static int dspio_alloc_dma_chan(struct hda_codec *codec, unsigned int *dma_chan)
        int status = 0;
        unsigned int size = sizeof(dma_chan);
 
-       snd_printdd(KERN_INFO "     dspio_alloc_dma_chan() -- begin\n");
+       codec_dbg(codec, "     dspio_alloc_dma_chan() -- begin\n");
        status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN,
                        SCP_GET, NULL, 0, dma_chan, &size);
 
        if (status < 0) {
-               snd_printdd(KERN_INFO "dspio_alloc_dma_chan: SCP Failed\n");
+               codec_dbg(codec, "dspio_alloc_dma_chan: SCP Failed\n");
                return status;
        }
 
        if ((*dma_chan + 1) == 0) {
-               snd_printdd(KERN_INFO "no free dma channels to allocate\n");
+               codec_dbg(codec, "no free dma channels to allocate\n");
                return -EBUSY;
        }
 
-       snd_printdd("dspio_alloc_dma_chan: chan=%d\n", *dma_chan);
-       snd_printdd(KERN_INFO "     dspio_alloc_dma_chan() -- complete\n");
+       codec_dbg(codec, "dspio_alloc_dma_chan: chan=%d\n", *dma_chan);
+       codec_dbg(codec, "     dspio_alloc_dma_chan() -- complete\n");
 
        return status;
 }
@@ -1517,18 +1516,18 @@ static int dspio_free_dma_chan(struct hda_codec *codec, unsigned int dma_chan)
        int status = 0;
        unsigned int dummy = 0;
 
-       snd_printdd(KERN_INFO "     dspio_free_dma_chan() -- begin\n");
-       snd_printdd("dspio_free_dma_chan: chan=%d\n", dma_chan);
+       codec_dbg(codec, "     dspio_free_dma_chan() -- begin\n");
+       codec_dbg(codec, "dspio_free_dma_chan: chan=%d\n", dma_chan);
 
        status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN,
                           SCP_SET, &dma_chan, sizeof(dma_chan), NULL, &dummy);
 
        if (status < 0) {
-               snd_printdd(KERN_INFO "dspio_free_dma_chan: SCP Failed\n");
+               codec_dbg(codec, "dspio_free_dma_chan: SCP Failed\n");
                return status;
        }
 
-       snd_printdd(KERN_INFO "     dspio_free_dma_chan() -- complete\n");
+       codec_dbg(codec, "     dspio_free_dma_chan() -- complete\n");
 
        return status;
 }
@@ -1576,14 +1575,14 @@ static int dsp_reset(struct hda_codec *codec)
        unsigned int res;
        int retry = 20;
 
-       snd_printdd("dsp_reset\n");
+       codec_dbg(codec, "dsp_reset\n");
        do {
                res = dspio_send(codec, VENDOR_DSPIO_DSP_INIT, 0);
                retry--;
        } while (res == -EIO && retry);
 
        if (!retry) {
-               snd_printdd("dsp_reset timeout\n");
+               codec_dbg(codec, "dsp_reset timeout\n");
                return -EIO;
        }
 
@@ -1636,39 +1635,39 @@ static int dsp_dma_setup_common(struct hda_codec *codec,
        unsigned int active;
        bool code, yram;
 
-       snd_printdd(KERN_INFO "-- dsp_dma_setup_common() -- Begin ---------\n");
+       codec_dbg(codec, "-- dsp_dma_setup_common() -- Begin ---------\n");
 
        if (dma_chan >= DSPDMAC_DMA_CFG_CHANNEL_COUNT) {
-               snd_printdd(KERN_ERR "dma chan num invalid\n");
+               codec_dbg(codec, "dma chan num invalid\n");
                return -EINVAL;
        }
 
        if (dsp_is_dma_active(codec, dma_chan)) {
-               snd_printdd(KERN_ERR "dma already active\n");
+               codec_dbg(codec, "dma already active\n");
                return -EBUSY;
        }
 
        dsp_addx = dsp_chip_to_dsp_addx(chip_addx, &code, &yram);
 
        if (dsp_addx == INVALID_CHIP_ADDRESS) {
-               snd_printdd(KERN_ERR "invalid chip addr\n");
+               codec_dbg(codec, "invalid chip addr\n");
                return -ENXIO;
        }
 
        chnl_prop = DSPDMAC_CHNLPROP_AC_MASK;
        active = 0;
 
-       snd_printdd(KERN_INFO "   dsp_dma_setup_common()    start reg pgm\n");
+       codec_dbg(codec, "   dsp_dma_setup_common()    start reg pgm\n");
 
        if (ovly) {
                status = chipio_read(codec, DSPDMAC_CHNLPROP_INST_OFFSET,
                                     &chnl_prop);
 
                if (status < 0) {
-                       snd_printdd(KERN_ERR "read CHNLPROP Reg fail\n");
+                       codec_dbg(codec, "read CHNLPROP Reg fail\n");
                        return status;
                }
-               snd_printdd(KERN_INFO "dsp_dma_setup_common() Read CHNLPROP\n");
+               codec_dbg(codec, "dsp_dma_setup_common() Read CHNLPROP\n");
        }
 
        if (!code)
@@ -1680,20 +1679,20 @@ static int dsp_dma_setup_common(struct hda_codec *codec,
 
        status = chipio_write(codec, DSPDMAC_CHNLPROP_INST_OFFSET, chnl_prop);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write CHNLPROP Reg fail\n");
+               codec_dbg(codec, "write CHNLPROP Reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "   dsp_dma_setup_common()    Write CHNLPROP\n");
+       codec_dbg(codec, "   dsp_dma_setup_common()    Write CHNLPROP\n");
 
        if (ovly) {
                status = chipio_read(codec, DSPDMAC_ACTIVE_INST_OFFSET,
                                     &active);
 
                if (status < 0) {
-                       snd_printdd(KERN_ERR "read ACTIVE Reg fail\n");
+                       codec_dbg(codec, "read ACTIVE Reg fail\n");
                        return status;
                }
-               snd_printdd(KERN_INFO "dsp_dma_setup_common() Read ACTIVE\n");
+               codec_dbg(codec, "dsp_dma_setup_common() Read ACTIVE\n");
        }
 
        active &= (~(1 << (DSPDMAC_ACTIVE_AAR_LOBIT + dma_chan))) &
@@ -1701,35 +1700,35 @@ static int dsp_dma_setup_common(struct hda_codec *codec,
 
        status = chipio_write(codec, DSPDMAC_ACTIVE_INST_OFFSET, active);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write ACTIVE Reg fail\n");
+               codec_dbg(codec, "write ACTIVE Reg fail\n");
                return status;
        }
 
-       snd_printdd(KERN_INFO "   dsp_dma_setup_common()    Write ACTIVE\n");
+       codec_dbg(codec, "   dsp_dma_setup_common()    Write ACTIVE\n");
 
        status = chipio_write(codec, DSPDMAC_AUDCHSEL_INST_OFFSET(dma_chan),
                              port_map_mask);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write AUDCHSEL Reg fail\n");
+               codec_dbg(codec, "write AUDCHSEL Reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "   dsp_dma_setup_common()    Write AUDCHSEL\n");
+       codec_dbg(codec, "   dsp_dma_setup_common()    Write AUDCHSEL\n");
 
        status = chipio_write(codec, DSPDMAC_IRQCNT_INST_OFFSET(dma_chan),
                        DSPDMAC_IRQCNT_BICNT_MASK | DSPDMAC_IRQCNT_CICNT_MASK);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write IRQCNT Reg fail\n");
+               codec_dbg(codec, "write IRQCNT Reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "   dsp_dma_setup_common()    Write IRQCNT\n");
+       codec_dbg(codec, "   dsp_dma_setup_common()    Write IRQCNT\n");
 
-       snd_printdd(
+       codec_dbg(codec,
                   "ChipA=0x%x,DspA=0x%x,dmaCh=%u, "
                   "CHSEL=0x%x,CHPROP=0x%x,Active=0x%x\n",
                   chip_addx, dsp_addx, dma_chan,
                   port_map_mask, chnl_prop, active);
 
-       snd_printdd(KERN_INFO "-- dsp_dma_setup_common() -- Complete ------\n");
+       codec_dbg(codec, "-- dsp_dma_setup_common() -- Complete ------\n");
 
        return 0;
 }
@@ -1755,20 +1754,20 @@ static int dsp_dma_setup(struct hda_codec *codec,
        const unsigned int max_dma_count = 1 << (DSPDMAC_XFRCNT_BCNT_HIBIT -
                                                DSPDMAC_XFRCNT_BCNT_LOBIT + 1);
 
-       snd_printdd(KERN_INFO "-- dsp_dma_setup() -- Begin ---------\n");
+       codec_dbg(codec, "-- dsp_dma_setup() -- Begin ---------\n");
 
        if (count > max_dma_count) {
-               snd_printdd(KERN_ERR "count too big\n");
+               codec_dbg(codec, "count too big\n");
                return -EINVAL;
        }
 
        dsp_addx = dsp_chip_to_dsp_addx(chip_addx, &code, &yram);
        if (dsp_addx == INVALID_CHIP_ADDRESS) {
-               snd_printdd(KERN_ERR "invalid chip addr\n");
+               codec_dbg(codec, "invalid chip addr\n");
                return -ENXIO;
        }
 
-       snd_printdd(KERN_INFO "   dsp_dma_setup()    start reg pgm\n");
+       codec_dbg(codec, "   dsp_dma_setup()    start reg pgm\n");
 
        addr_field = dsp_addx << DSPDMAC_DMACFG_DBADR_LOBIT;
        incr_field   = 0;
@@ -1785,10 +1784,10 @@ static int dsp_dma_setup(struct hda_codec *codec,
        status = chipio_write(codec, DSPDMAC_DMACFG_INST_OFFSET(dma_chan),
                                dma_cfg);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write DMACFG Reg fail\n");
+               codec_dbg(codec, "write DMACFG Reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "   dsp_dma_setup()    Write DMACFG\n");
+       codec_dbg(codec, "   dsp_dma_setup()    Write DMACFG\n");
 
        adr_ofs = (count - 1) << (DSPDMAC_DSPADROFS_BOFS_LOBIT +
                                                        (code ? 0 : 1));
@@ -1796,10 +1795,10 @@ static int dsp_dma_setup(struct hda_codec *codec,
        status = chipio_write(codec, DSPDMAC_DSPADROFS_INST_OFFSET(dma_chan),
                                adr_ofs);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write DSPADROFS Reg fail\n");
+               codec_dbg(codec, "write DSPADROFS Reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "   dsp_dma_setup()    Write DSPADROFS\n");
+       codec_dbg(codec, "   dsp_dma_setup()    Write DSPADROFS\n");
 
        base_cnt = (count - 1) << DSPDMAC_XFRCNT_BCNT_LOBIT;
 
@@ -1810,17 +1809,17 @@ static int dsp_dma_setup(struct hda_codec *codec,
        status = chipio_write(codec,
                                DSPDMAC_XFRCNT_INST_OFFSET(dma_chan), xfr_cnt);
        if (status < 0) {
-               snd_printdd(KERN_ERR "write XFRCNT Reg fail\n");
+               codec_dbg(codec, "write XFRCNT Reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "   dsp_dma_setup()    Write XFRCNT\n");
+       codec_dbg(codec, "   dsp_dma_setup()    Write XFRCNT\n");
 
-       snd_printdd(
+       codec_dbg(codec,
                   "ChipA=0x%x, cnt=0x%x, DMACFG=0x%x, "
                   "ADROFS=0x%x, XFRCNT=0x%x\n",
                   chip_addx, count, dma_cfg, adr_ofs, xfr_cnt);
 
-       snd_printdd(KERN_INFO "-- dsp_dma_setup() -- Complete ---------\n");
+       codec_dbg(codec, "-- dsp_dma_setup() -- Complete ---------\n");
 
        return 0;
 }
@@ -1834,17 +1833,17 @@ static int dsp_dma_start(struct hda_codec *codec,
        unsigned int reg = 0;
        int status = 0;
 
-       snd_printdd(KERN_INFO "-- dsp_dma_start() -- Begin ---------\n");
+       codec_dbg(codec, "-- dsp_dma_start() -- Begin ---------\n");
 
        if (ovly) {
                status = chipio_read(codec,
                                     DSPDMAC_CHNLSTART_INST_OFFSET, &reg);
 
                if (status < 0) {
-                       snd_printdd(KERN_ERR "read CHNLSTART reg fail\n");
+                       codec_dbg(codec, "read CHNLSTART reg fail\n");
                        return status;
                }
-               snd_printdd(KERN_INFO "-- dsp_dma_start()    Read CHNLSTART\n");
+               codec_dbg(codec, "-- dsp_dma_start()    Read CHNLSTART\n");
 
                reg &= ~(DSPDMAC_CHNLSTART_EN_MASK |
                                DSPDMAC_CHNLSTART_DIS_MASK);
@@ -1853,10 +1852,10 @@ static int dsp_dma_start(struct hda_codec *codec,
        status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET,
                        reg | (1 << (dma_chan + DSPDMAC_CHNLSTART_EN_LOBIT)));
        if (status < 0) {
-               snd_printdd(KERN_ERR "write CHNLSTART reg fail\n");
+               codec_dbg(codec, "write CHNLSTART reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "-- dsp_dma_start() -- Complete ---------\n");
+       codec_dbg(codec, "-- dsp_dma_start() -- Complete ---------\n");
 
        return status;
 }
@@ -1870,17 +1869,17 @@ static int dsp_dma_stop(struct hda_codec *codec,
        unsigned int reg = 0;
        int status = 0;
 
-       snd_printdd(KERN_INFO "-- dsp_dma_stop() -- Begin ---------\n");
+       codec_dbg(codec, "-- dsp_dma_stop() -- Begin ---------\n");
 
        if (ovly) {
                status = chipio_read(codec,
                                     DSPDMAC_CHNLSTART_INST_OFFSET, &reg);
 
                if (status < 0) {
-                       snd_printdd(KERN_ERR "read CHNLSTART reg fail\n");
+                       codec_dbg(codec, "read CHNLSTART reg fail\n");
                        return status;
                }
-               snd_printdd(KERN_INFO "-- dsp_dma_stop()    Read CHNLSTART\n");
+               codec_dbg(codec, "-- dsp_dma_stop()    Read CHNLSTART\n");
                reg &= ~(DSPDMAC_CHNLSTART_EN_MASK |
                                DSPDMAC_CHNLSTART_DIS_MASK);
        }
@@ -1888,10 +1887,10 @@ static int dsp_dma_stop(struct hda_codec *codec,
        status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET,
                        reg | (1 << (dma_chan + DSPDMAC_CHNLSTART_DIS_LOBIT)));
        if (status < 0) {
-               snd_printdd(KERN_ERR "write CHNLSTART reg fail\n");
+               codec_dbg(codec, "write CHNLSTART reg fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "-- dsp_dma_stop() -- Complete ---------\n");
+       codec_dbg(codec, "-- dsp_dma_stop() -- Complete ---------\n");
 
        return status;
 }
@@ -1974,17 +1973,17 @@ static int dsp_allocate_ports(struct hda_codec *codec,
 {
        int status;
 
-       snd_printdd(KERN_INFO "     dsp_allocate_ports() -- begin\n");
+       codec_dbg(codec, "     dsp_allocate_ports() -- begin\n");
 
        if ((rate_multi != 1) && (rate_multi != 2) && (rate_multi != 4)) {
-               snd_printdd(KERN_ERR "bad rate multiple\n");
+               codec_dbg(codec, "bad rate multiple\n");
                return -EINVAL;
        }
 
        status = dsp_allocate_router_ports(codec, num_chans,
                                           rate_multi, 0, port_map);
 
-       snd_printdd(KERN_INFO "     dsp_allocate_ports() -- complete\n");
+       codec_dbg(codec, "     dsp_allocate_ports() -- complete\n");
 
        return status;
 }
@@ -2001,7 +2000,7 @@ static int dsp_allocate_ports_format(struct hda_codec *codec,
        unsigned int rate_multi = sample_rate_mul / sample_rate_div;
 
        if ((rate_multi != 1) && (rate_multi != 2) && (rate_multi != 4)) {
-               snd_printdd(KERN_ERR "bad rate multiple\n");
+               codec_dbg(codec, "bad rate multiple\n");
                return -EINVAL;
        }
 
@@ -2019,14 +2018,14 @@ static int dsp_free_ports(struct hda_codec *codec)
 {
        int status;
 
-       snd_printdd(KERN_INFO "     dsp_free_ports() -- begin\n");
+       codec_dbg(codec, "     dsp_free_ports() -- begin\n");
 
        status = dsp_free_router_ports(codec);
        if (status < 0) {
-               snd_printdd(KERN_ERR "free router ports fail\n");
+               codec_dbg(codec, "free router ports fail\n");
                return status;
        }
-       snd_printdd(KERN_INFO "     dsp_free_ports() -- complete\n");
+       codec_dbg(codec, "     dsp_free_ports() -- complete\n");
 
        return status;
 }
@@ -2092,8 +2091,6 @@ static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 {
        bool cmd;
 
-       snd_printdd("dma_set_state state=%d\n", state);
-
        switch (state) {
        case DMA_STATE_STOP:
                cmd = false;
@@ -2196,7 +2193,7 @@ static int dspxfr_hci_write(struct hda_codec *codec,
        unsigned int count;
 
        if (fls == NULL || fls->chip_addr != g_chip_addr_magic_value) {
-               snd_printdd(KERN_ERR "hci_write invalid params\n");
+               codec_dbg(codec, "hci_write invalid params\n");
                return -EINVAL;
        }
 
@@ -2205,7 +2202,7 @@ static int dspxfr_hci_write(struct hda_codec *codec,
        while (count >= 2) {
                status = chipio_write(codec, data[0], data[1]);
                if (status < 0) {
-                       snd_printdd(KERN_ERR "hci_write chipio failed\n");
+                       codec_dbg(codec, "hci_write chipio failed\n");
                        return status;
                }
                count -= 2;
@@ -2265,12 +2262,12 @@ static int dspxfr_one_seg(struct hda_codec *codec,
        }
 
        if (hci_write && (!fls || is_last(fls))) {
-               snd_printdd("hci_write\n");
+               codec_dbg(codec, "hci_write\n");
                return dspxfr_hci_write(codec, hci_write);
        }
 
        if (fls == NULL || dma_engine == NULL || port_map_mask == 0) {
-               snd_printdd("Invalid Params\n");
+               codec_dbg(codec, "Invalid Params\n");
                return -EINVAL;
        }
 
@@ -2286,7 +2283,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
        if (!UC_RANGE(chip_addx, words_to_write) &&
            !X_RANGE_ALL(chip_addx, words_to_write) &&
            !Y_RANGE_ALL(chip_addx, words_to_write)) {
-               snd_printdd("Invalid chip_addx Params\n");
+               codec_dbg(codec, "Invalid chip_addx Params\n");
                return -EINVAL;
        }
 
@@ -2296,7 +2293,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
        buffer_addx = dma_get_buffer_addr(dma_engine);
 
        if (buffer_addx == NULL) {
-               snd_printdd(KERN_ERR "dma_engine buffer NULL\n");
+               codec_dbg(codec, "dma_engine buffer NULL\n");
                return -EINVAL;
        }
 
@@ -2309,7 +2306,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
                        (num_chans * sample_rate_mul / sample_rate_div));
 
        if (hda_frame_size_words == 0) {
-               snd_printdd(KERN_ERR "frmsz zero\n");
+               codec_dbg(codec, "frmsz zero\n");
                return -EINVAL;
        }
 
@@ -2317,14 +2314,14 @@ static int dspxfr_one_seg(struct hda_codec *codec,
                                (unsigned int)(UC_RANGE(chip_addx, 1) ?
                                65536 : 32768));
        buffer_size_words -= buffer_size_words % hda_frame_size_words;
-       snd_printdd(
+       codec_dbg(codec,
                   "chpadr=0x%08x frmsz=%u nchan=%u "
                   "rate_mul=%u div=%u bufsz=%u\n",
                   chip_addx, hda_frame_size_words, num_chans,
                   sample_rate_mul, sample_rate_div, buffer_size_words);
 
        if (buffer_size_words < hda_frame_size_words) {
-               snd_printdd(KERN_ERR "dspxfr_one_seg:failed\n");
+               codec_dbg(codec, "dspxfr_one_seg:failed\n");
                return -EINVAL;
        }
 
@@ -2338,7 +2335,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
 
        while (words_to_write != 0) {
                run_size_words = min(buffer_size_words, words_to_write);
-               snd_printdd("dspxfr (seg loop)cnt=%u rs=%u remainder=%u\n",
+               codec_dbg(codec, "dspxfr (seg loop)cnt=%u rs=%u remainder=%u\n",
                            words_to_write, run_size_words, remainder_words);
                dma_xfer(dma_engine, data, run_size_words*sizeof(u32));
                if (!comm_dma_setup_done) {
@@ -2360,7 +2357,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
                if (status < 0)
                        return status;
                if (!dsp_is_dma_active(codec, dma_chan)) {
-                       snd_printdd(KERN_ERR "dspxfr:DMA did not start\n");
+                       codec_dbg(codec, "dspxfr:DMA did not start\n");
                        return -EIO;
                }
                status = dma_set_state(dma_engine, DMA_STATE_RUN);
@@ -2392,7 +2389,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
                if (dma_active)
                        break;
 
-               snd_printdd(KERN_INFO "+++++ DMA complete\n");
+               codec_dbg(codec, "+++++ DMA complete\n");
                dma_set_state(dma_engine, DMA_STATE_STOP);
                status = dma_reset(dma_engine);
 
@@ -2466,7 +2463,7 @@ static int dspxfr_image(struct hda_codec *codec,
                                        hda_format, &response);
 
        if (status < 0) {
-               snd_printdd(KERN_ERR "set converter format fail\n");
+               codec_dbg(codec, "set converter format fail\n");
                goto exit;
        }
 
@@ -2481,7 +2478,7 @@ static int dspxfr_image(struct hda_codec *codec,
        if (ovly) {
                status = dspio_alloc_dma_chan(codec, &dma_chan);
                if (status < 0) {
-                       snd_printdd(KERN_ERR "alloc dmachan fail\n");
+                       codec_dbg(codec, "alloc dmachan fail\n");
                        dma_chan = INVALID_DMA_CHANNEL;
                        goto exit;
                }
@@ -2491,7 +2488,7 @@ static int dspxfr_image(struct hda_codec *codec,
        status = dsp_allocate_ports_format(codec, hda_format,
                                        &port_map_mask);
        if (status < 0) {
-               snd_printdd(KERN_ERR "alloc ports fail\n");
+               codec_dbg(codec, "alloc ports fail\n");
                goto exit;
        }
 
@@ -2499,13 +2496,13 @@ static int dspxfr_image(struct hda_codec *codec,
        status = codec_set_converter_stream_channel(codec,
                        WIDGET_CHIP_CTRL, stream_id, 0, &response);
        if (status < 0) {
-               snd_printdd(KERN_ERR "set stream chan fail\n");
+               codec_dbg(codec, "set stream chan fail\n");
                goto exit;
        }
 
        while ((fls_data != NULL) && !is_last(fls_data)) {
                if (!is_valid(fls_data)) {
-                       snd_printdd(KERN_ERR "FLS check fail\n");
+                       codec_dbg(codec, "FLS check fail\n");
                        status = -EINVAL;
                        goto exit;
                }
@@ -2548,7 +2545,7 @@ exit:
  */
 static void dspload_post_setup(struct hda_codec *codec)
 {
-       snd_printdd(KERN_INFO "---- dspload_post_setup ------\n");
+       codec_dbg(codec, "---- dspload_post_setup ------\n");
 
        /*set DSP speaker to 2.0 configuration*/
        chipio_write(codec, XRAM_XRAM_INST_OFFSET(0x18), 0x08080080);
@@ -2586,7 +2583,7 @@ static int dspload_image(struct hda_codec *codec,
        unsigned int sample_rate;
        unsigned short channels;
 
-       snd_printdd(KERN_INFO "---- dspload_image begin ------\n");
+       codec_dbg(codec, "---- dspload_image begin ------\n");
        if (router_chans == 0) {
                if (!ovly)
                        router_chans = DMA_TRANSFER_FRAME_SIZE_NWORDS;
@@ -2603,27 +2600,27 @@ static int dspload_image(struct hda_codec *codec,
        }
 
        do {
-               snd_printdd(KERN_INFO "Ready to program DMA\n");
+               codec_dbg(codec, "Ready to program DMA\n");
                if (!ovly)
                        status = dsp_reset(codec);
 
                if (status < 0)
                        break;
 
-               snd_printdd(KERN_INFO "dsp_reset() complete\n");
+               codec_dbg(codec, "dsp_reset() complete\n");
                status = dspxfr_image(codec, fls, reloc, sample_rate, channels,
                                      ovly);
 
                if (status < 0)
                        break;
 
-               snd_printdd(KERN_INFO "dspxfr_image() complete\n");
+               codec_dbg(codec, "dspxfr_image() complete\n");
                if (autostart && !ovly) {
                        dspload_post_setup(codec);
                        status = dsp_set_run_state(codec);
                }
 
-               snd_printdd(KERN_INFO "LOAD FINISHED\n");
+               codec_dbg(codec, "LOAD FINISHED\n");
        } while (0);
 
        return status;
@@ -3132,7 +3129,7 @@ static int ca0132_select_out(struct hda_codec *codec)
        unsigned int tmp;
        int err;
 
-       snd_printdd(KERN_INFO "ca0132_select_out\n");
+       codec_dbg(codec, "ca0132_select_out\n");
 
        snd_hda_power_up(codec);
 
@@ -3150,7 +3147,7 @@ static int ca0132_select_out(struct hda_codec *codec)
                spec->cur_out_type = SPEAKER_OUT;
 
        if (spec->cur_out_type == SPEAKER_OUT) {
-               snd_printdd(KERN_INFO "ca0132_select_out speaker\n");
+               codec_dbg(codec, "ca0132_select_out speaker\n");
                /*speaker out config*/
                tmp = FLOAT_ONE;
                err = dspio_set_uint_param(codec, 0x80, 0x04, tmp);
@@ -3183,7 +3180,7 @@ static int ca0132_select_out(struct hda_codec *codec)
                snd_hda_set_pin_ctl(codec, spec->out_pins[0],
                                    pin_ctl | PIN_OUT);
        } else {
-               snd_printdd(KERN_INFO "ca0132_select_out hp\n");
+               codec_dbg(codec, "ca0132_select_out hp\n");
                /*headphone out config*/
                tmp = FLOAT_ZERO;
                err = dspio_set_uint_param(codec, 0x80, 0x04, tmp);
@@ -3288,7 +3285,7 @@ static int ca0132_select_mic(struct hda_codec *codec)
        int jack_present;
        int auto_jack;
 
-       snd_printdd(KERN_INFO "ca0132_select_mic\n");
+       codec_dbg(codec, "ca0132_select_mic\n");
 
        snd_hda_power_up(codec);
 
@@ -3410,7 +3407,7 @@ static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val)
                        val = 0;
        }
 
-       snd_printdd(KERN_INFO "ca0132_effect_set: nid=0x%x, val=%ld\n",
+       codec_dbg(codec, "ca0132_effect_set: nid=0x%x, val=%ld\n",
                    nid, val);
 
        on = (val == 0) ? FLOAT_ZERO : FLOAT_ONE;
@@ -3432,7 +3429,7 @@ static int ca0132_pe_switch_set(struct hda_codec *codec)
        hda_nid_t nid;
        int i, ret = 0;
 
-       snd_printdd(KERN_INFO "ca0132_pe_switch_set: val=%ld\n",
+       codec_dbg(codec, "ca0132_pe_switch_set: val=%ld\n",
                    spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]);
 
        i = OUT_EFFECT_START_NID - EFFECT_START_NID;
@@ -3478,7 +3475,7 @@ static int ca0132_cvoice_switch_set(struct hda_codec *codec)
        int i, ret = 0;
        unsigned int oldval;
 
-       snd_printdd(KERN_INFO "ca0132_cvoice_switch_set: val=%ld\n",
+       codec_dbg(codec, "ca0132_cvoice_switch_set: val=%ld\n",
                    spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]);
 
        i = IN_EFFECT_START_NID - EFFECT_START_NID;
@@ -3608,7 +3605,7 @@ static int ca0132_voicefx_put(struct snd_kcontrol *kcontrol,
        if (sel >= items)
                return 0;
 
-       snd_printdd(KERN_INFO "ca0132_voicefx_put: sel=%d, preset=%s\n",
+       codec_dbg(codec, "ca0132_voicefx_put: sel=%d, preset=%s\n",
                    sel, ca0132_voicefx_presets[sel].name);
 
        /*
@@ -3679,7 +3676,7 @@ static int ca0132_switch_put(struct snd_kcontrol *kcontrol,
        long *valp = ucontrol->value.integer.value;
        int changed = 1;
 
-       snd_printdd(KERN_INFO "ca0132_switch_put: nid=0x%x, val=%ld\n",
+       codec_dbg(codec, "ca0132_switch_put: nid=0x%x, val=%ld\n",
                    nid, *valp);
 
        snd_hda_power_up(codec);
@@ -4142,7 +4139,7 @@ static void ca0132_set_dmic(struct hda_codec *codec, int enable)
        u8 val;
        unsigned int oldval;
 
-       snd_printdd(KERN_INFO "ca0132_set_dmic: enable=%d\n", enable);
+       codec_dbg(codec, "ca0132_set_dmic: enable=%d\n", enable);
 
        oldval = stop_mic1(codec);
        ca0132_set_vipsource(codec, 0);
@@ -4250,7 +4247,7 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec)
        int i;
        hda_nid_t nid;
 
-       snd_printdd(KERN_INFO "ca0132_refresh_widget_caps.\n");
+       codec_dbg(codec, "ca0132_refresh_widget_caps.\n");
        nid = codec->start_nid;
        for (i = 0; i < codec->num_nodes; i++, nid++)
                codec->wcaps[i] = snd_hda_param_read(codec, nid,
@@ -4394,7 +4391,7 @@ static void ca0132_process_dsp_response(struct hda_codec *codec)
 {
        struct ca0132_spec *spec = codec->spec;
 
-       snd_printdd(KERN_INFO "ca0132_process_dsp_response\n");
+       codec_dbg(codec, "ca0132_process_dsp_response\n");
        if (spec->wait_scp) {
                if (dspio_get_response_data(codec) >= 0)
                        spec->wait_scp = 0;
@@ -4413,7 +4410,7 @@ static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res)
                res = snd_hda_jack_get_action(codec,
                                (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f);
 
-               snd_printdd(KERN_INFO "snd_hda_jack_get_action: 0x%x\n", res);
+               codec_dbg(codec, "snd_hda_jack_get_action: 0x%x\n", res);
 
                switch (res) {
                case UNSOL_TAG_HP:
@@ -4658,7 +4655,7 @@ static int patch_ca0132(struct hda_codec *codec)
        struct ca0132_spec *spec;
        int err;
 
-       snd_printdd("patch_ca0132\n");
+       codec_dbg(codec, "patch_ca0132\n");
 
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (!spec)
index fc492ac24caa917c9d3670a37f83cb1d3e0bca95..387f0b55188914d3081444d1b573ea15ad1bab2c 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/module.h>
 #include <sound/core.h>
 #include <sound/tlv.h>
index 9c6ce73b03c5585994ee4099106a70dbe7cca51c..061ea5965dd5dc17b6af0fa32f69c658831e335c 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/module.h>
 #include <sound/core.h>
 #include "hda_codec.h"
@@ -32,6 +31,9 @@
 #include "hda_jack.h"
 #include "hda_generic.h"
 
+#undef ENABLE_CMI_STATIC_QUIRKS
+
+#ifdef ENABLE_CMI_STATIC_QUIRKS
 #define NUM_PINS       11
 
 
@@ -45,10 +47,12 @@ enum {
        CMI_AUTO,       /* let driver guess it */
        CMI_MODELS
 };
+#endif /* ENABLE_CMI_STATIC_QUIRKS */
 
 struct cmi_spec {
        struct hda_gen_spec gen;
 
+#ifdef ENABLE_CMI_STATIC_QUIRKS
        /* below are only for static models */
 
        int board_config;
@@ -81,8 +85,10 @@ struct cmi_spec {
 
        /* multichannel pins */
        struct hda_verb multi_init[9];  /* 2 verbs for each pin + terminator */
+#endif /* ENABLE_CMI_STATIC_QUIRKS */
 };
 
+#ifdef ENABLE_CMI_STATIC_QUIRKS
 /*
  * input MUX
  */
@@ -566,6 +572,7 @@ static const struct hda_codec_ops cmi9880_patch_ops = {
        .init = cmi9880_init,
        .free = cmi9880_free,
 };
+#endif /* ENABLE_CMI_STATIC_QUIRKS */
 
 /*
  * stuff for auto-parser
@@ -588,15 +595,20 @@ static int cmi_parse_auto_config(struct hda_codec *codec)
 
        err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
        if (err < 0)
-               return err;
+               goto error;
        err = snd_hda_gen_parse_auto_config(codec, cfg);
        if (err < 0)
-               return err;
+               goto error;
 
        codec->patch_ops = cmi_auto_patch_ops;
        return 0;
+
+ error:
+       snd_hda_gen_free(codec);
+       return err;
 }
 
+
 static int patch_cmi9880(struct hda_codec *codec)
 {
        struct cmi_spec *spec;
@@ -606,23 +618,18 @@ static int patch_cmi9880(struct hda_codec *codec)
                return -ENOMEM;
 
        codec->spec = spec;
+#ifdef ENABLE_CMI_STATIC_QUIRKS
        spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS,
                                                        cmi9880_models,
                                                        cmi9880_cfg_tbl);
        if (spec->board_config < 0) {
-               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+               codec_dbg(codec, "%s: BIOS auto-probing.\n",
                            codec->chip_name);
                spec->board_config = CMI_AUTO; /* try everything */
        }
 
-       if (spec->board_config == CMI_AUTO) {
-               int err = cmi_parse_auto_config(codec);
-               if (err < 0) {
-                       snd_hda_gen_free(codec);
-                       return err;
-               }
-               return 0;
-       }
+       if (spec->board_config == CMI_AUTO)
+               return cmi_parse_auto_config(codec);
 
        /* copy default DAC NIDs */
        memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids));
@@ -669,6 +676,9 @@ static int patch_cmi9880(struct hda_codec *codec)
        codec->patch_ops = cmi9880_patch_ops;
 
        return 0;
+#else
+       return cmi_parse_auto_config(codec);
+#endif
 }
 
 /*
index bcf91bea33179ce50b9485fd1db59caf1349b64c..1dc7e974f3b1cd554988eb2d2be26ca889aafab8 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-#include <linux/pci.h>
 #include <linux/module.h>
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -35,7 +34,7 @@
 #include "hda_jack.h"
 #include "hda_generic.h"
 
-#define ENABLE_CXT_STATIC_QUIRKS
+#undef ENABLE_CXT_STATIC_QUIRKS
 
 #define CXT_PIN_DIR_IN              0x00
 #define CXT_PIN_DIR_OUT             0x01
@@ -68,6 +67,12 @@ struct conexant_spec {
 
        unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
 
+       /* OPLC XO specific */
+       bool recording;
+       bool dc_enable;
+       unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */
+       struct nid_path *dc_mode_path;
+
 #ifdef ENABLE_CXT_STATIC_QUIRKS
        const struct snd_kcontrol_new *mixers[5];
        int num_mixers;
@@ -123,19 +128,6 @@ struct conexant_spec {
        unsigned int hp_laptop:1;
        unsigned int asus:1;
 
-       unsigned int ext_mic_present;
-       unsigned int recording;
-       void (*capture_prepare)(struct hda_codec *codec);
-       void (*capture_cleanup)(struct hda_codec *codec);
-
-       /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
-        * through the microphone jack.
-        * When the user enables this through a mixer switch, both internal and
-        * external microphones are disabled. Gain is fixed at 0dB. In this mode,
-        * we also allow the bias to be configured through a separate mixer
-        * control. */
-       unsigned int dc_enable;
-       unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */
        unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */
 #endif /* ENABLE_CXT_STATIC_QUIRKS */
 };
@@ -253,8 +245,6 @@ static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
                                      struct snd_pcm_substream *substream)
 {
        struct conexant_spec *spec = codec->spec;
-       if (spec->capture_prepare)
-               spec->capture_prepare(codec);
        snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
                                   stream_tag, 0, format);
        return 0;
@@ -266,8 +256,6 @@ static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
 {
        struct conexant_spec *spec = codec->spec;
        snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
-       if (spec->capture_cleanup)
-               spec->capture_cleanup(codec);
        return 0;
 }
 
@@ -457,9 +445,7 @@ static int conexant_init(struct hda_codec *codec)
 
 static void conexant_free(struct hda_codec *codec)
 {
-       struct conexant_spec *spec = codec->spec;
-       snd_hda_detach_beep_device(codec);
-       kfree(spec);
+       kfree(codec->spec);
 }
 
 static const struct snd_kcontrol_new cxt_capture_mixers[] = {
@@ -673,14 +659,6 @@ static const struct hda_input_mux cxt5045_capture_source_benq = {
        }
 };
 
-static const struct hda_input_mux cxt5045_capture_source_hp530 = {
-       .num_items = 2,
-       .items = {
-               { "Mic",          0x1 },
-               { "Internal Mic", 0x2 },
-       }
-};
-
 /* turn on/off EAPD (+ mute HP) as a master switch */
 static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_value *ucontrol)
@@ -796,28 +774,6 @@ static const struct snd_kcontrol_new cxt5045_benq_mixers[] = {
        {}
 };
 
-static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
-       HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT),
-       HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
-       HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
-       HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
-       HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
-       HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
-       HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
-       HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Master Playback Switch",
-               .info = cxt_eapd_info,
-               .get = cxt_eapd_get,
-               .put = cxt5045_hp_master_sw_put,
-               .private_value = 0x10,
-       },
-
-       {}
-};
-
 static const struct hda_verb cxt5045_init_verbs[] = {
        /* Line in, Mic */
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
@@ -1000,7 +956,6 @@ enum {
        CXT5045_LAPTOP_MICSENSE,
        CXT5045_LAPTOP_HPMICSENSE,
        CXT5045_BENQ,
-       CXT5045_LAPTOP_HP530,
 #ifdef CONFIG_SND_DEBUG
        CXT5045_TEST,
 #endif
@@ -1013,7 +968,6 @@ static const char * const cxt5045_models[CXT5045_MODELS] = {
        [CXT5045_LAPTOP_MICSENSE]       = "laptop-micsense",
        [CXT5045_LAPTOP_HPMICSENSE]     = "laptop-hpmicsense",
        [CXT5045_BENQ]                  = "benq",
-       [CXT5045_LAPTOP_HP530]          = "laptop-hp530",
 #ifdef CONFIG_SND_DEBUG
        [CXT5045_TEST]          = "test",
 #endif
@@ -1021,8 +975,6 @@ static const char * const cxt5045_models[CXT5045_MODELS] = {
 };
 
 static const struct snd_pci_quirk cxt5045_cfg_tbl[] = {
-       SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
-       SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
        SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
        SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
        SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
@@ -1113,14 +1065,6 @@ static int patch_cxt5045(struct hda_codec *codec)
                spec->num_mixers = 2;
                codec->patch_ops.init = cxt5045_init;
                break;
-       case CXT5045_LAPTOP_HP530:
-               codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
-               spec->input_mux = &cxt5045_capture_source_hp530;
-               spec->num_init_verbs = 2;
-               spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
-               spec->mixers[0] = cxt5045_mixers_hp530;
-               codec->patch_ops.init = cxt5045_init;
-               break;
 #ifdef CONFIG_SND_DEBUG
        case CXT5045_TEST:
                spec->input_mux = &cxt5045_test_capture_source;
@@ -1940,11 +1884,6 @@ static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 };
 static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 };
 static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 };
 
-/* OLPC's microphone port is DC coupled for use with external sensors,
- * therefore we use a 50% mic bias in order to center the input signal with
- * the DC input range of the codec. */
-#define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
-
 static const struct hda_channel_mode cxt5066_modes[1] = {
        { 2, NULL },
 };
@@ -1959,7 +1898,8 @@ static void cxt5066_update_speaker(struct hda_codec *codec)
        struct conexant_spec *spec = codec->spec;
        unsigned int pinctl;
 
-       snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
+       codec_dbg(codec,
+                 "CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
                    spec->hp_present, spec->cur_eapd);
 
        /* Port A (HP) */
@@ -1997,88 +1937,6 @@ static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol,
        return 1;
 }
 
-static const struct hda_input_mux cxt5066_olpc_dc_bias = {
-       .num_items = 3,
-       .items = {
-               { "Off", PIN_IN },
-               { "50%", PIN_VREF50 },
-               { "80%", PIN_VREF80 },
-       },
-};
-
-static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec)
-{
-       struct conexant_spec *spec = codec->spec;
-       /* Even though port F is the DC input, the bias is controlled on port B.
-        * we also leave that port as an active input (but unselected) in DC mode
-        * just in case that is necessary to make the bias setting take effect. */
-       return snd_hda_set_pin_ctl_cache(codec, 0x1a,
-               cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index);
-}
-
-/* OLPC defers mic widget control until when capture is started because the
- * microphone LED comes on as soon as these settings are put in place. if we
- * did this before recording, it would give the false indication that recording
- * is happening when it is not. */
-static void cxt5066_olpc_select_mic(struct hda_codec *codec)
-{
-       struct conexant_spec *spec = codec->spec;
-       if (!spec->recording)
-               return;
-
-       if (spec->dc_enable) {
-               /* in DC mode we ignore presence detection and just use the jack
-                * through our special DC port */
-               const struct hda_verb enable_dc_mode[] = {
-                       /* disble internal mic, port C */
-                       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-                       /* enable DC capture, port F */
-                       {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
-                       {},
-               };
-
-               snd_hda_sequence_write(codec, enable_dc_mode);
-               /* port B input disabled (and bias set) through the following call */
-               cxt5066_set_olpc_dc_bias(codec);
-               return;
-       }
-
-       /* disable DC (port F) */
-       snd_hda_set_pin_ctl(codec, 0x1e, 0);
-
-       /* external mic, port B */
-       snd_hda_set_pin_ctl(codec, 0x1a,
-               spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0);
-
-       /* internal mic, port C */
-       snd_hda_set_pin_ctl(codec, 0x1b,
-               spec->ext_mic_present ? 0 : PIN_VREF80);
-}
-
-/* toggle input of built-in and mic jack appropriately */
-static void cxt5066_olpc_automic(struct hda_codec *codec)
-{
-       struct conexant_spec *spec = codec->spec;
-       unsigned int present;
-
-       if (spec->dc_enable) /* don't do presence detection in DC mode */
-               return;
-
-       present = snd_hda_codec_read(codec, 0x1a, 0,
-                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
-       if (present)
-               snd_printdd("CXT5066: external microphone detected\n");
-       else
-               snd_printdd("CXT5066: external microphone absent\n");
-
-       snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
-               present ? 0 : 1);
-       spec->ext_mic_present = !!present;
-
-       cxt5066_olpc_select_mic(codec);
-}
-
 /* toggle input of built-in digital mic and mic jack appropriately */
 static void cxt5066_vostro_automic(struct hda_codec *codec)
 {
@@ -2110,10 +1968,10 @@ static void cxt5066_vostro_automic(struct hda_codec *codec)
 
        present = snd_hda_jack_detect(codec, 0x1a);
        if (present) {
-               snd_printdd("CXT5066: external microphone detected\n");
+               codec_dbg(codec, "CXT5066: external microphone detected\n");
                snd_hda_sequence_write(codec, ext_mic_present);
        } else {
-               snd_printdd("CXT5066: external microphone absent\n");
+               codec_dbg(codec, "CXT5066: external microphone absent\n");
                snd_hda_sequence_write(codec, ext_mic_absent);
        }
 }
@@ -2138,10 +1996,10 @@ static void cxt5066_ideapad_automic(struct hda_codec *codec)
 
        present = snd_hda_jack_detect(codec, 0x1b);
        if (present) {
-               snd_printdd("CXT5066: external microphone detected\n");
+               codec_dbg(codec, "CXT5066: external microphone detected\n");
                snd_hda_sequence_write(codec, ext_mic_present);
        } else {
-               snd_printdd("CXT5066: external microphone absent\n");
+               codec_dbg(codec, "CXT5066: external microphone absent\n");
                snd_hda_sequence_write(codec, ext_mic_absent);
        }
 }
@@ -2153,7 +2011,7 @@ static void cxt5066_asus_automic(struct hda_codec *codec)
        unsigned int present;
 
        present = snd_hda_jack_detect(codec, 0x1b);
-       snd_printdd("CXT5066: external microphone present=%d\n", present);
+       codec_dbg(codec, "CXT5066: external microphone present=%d\n", present);
        snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
                            present ? 1 : 0);
 }
@@ -2165,7 +2023,7 @@ static void cxt5066_hp_laptop_automic(struct hda_codec *codec)
        unsigned int present;
 
        present = snd_hda_jack_detect(codec, 0x1b);
-       snd_printdd("CXT5066: external microphone present=%d\n", present);
+       codec_dbg(codec, "CXT5066: external microphone present=%d\n", present);
        snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
                            present ? 1 : 3);
 }
@@ -2204,13 +2062,13 @@ static void cxt5066_thinkpad_automic(struct hda_codec *codec)
        ext_present = snd_hda_jack_detect(codec, 0x1b);
        dock_present = snd_hda_jack_detect(codec, 0x1a);
        if (ext_present) {
-               snd_printdd("CXT5066: external microphone detected\n");
+               codec_dbg(codec, "CXT5066: external microphone detected\n");
                snd_hda_sequence_write(codec, ext_mic_present);
        } else if (dock_present) {
-               snd_printdd("CXT5066: dock microphone detected\n");
+               codec_dbg(codec, "CXT5066: dock microphone detected\n");
                snd_hda_sequence_write(codec, dock_mic_present);
        } else {
-               snd_printdd("CXT5066: external microphone absent\n");
+               codec_dbg(codec, "CXT5066: external microphone absent\n");
                snd_hda_sequence_write(codec, ext_mic_absent);
        }
 }
@@ -2229,7 +2087,7 @@ static void cxt5066_hp_automute(struct hda_codec *codec)
 
        spec->hp_present = portA ? HP_PRESENT_PORT_A : 0;
        spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0;
-       snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
+       codec_dbg(codec, "CXT5066: hp automute portA=%x portD=%x present=%d\n",
                portA, portD, spec->hp_present);
        cxt5066_update_speaker(codec);
 }
@@ -2251,27 +2109,10 @@ static void cxt5066_automic(struct hda_codec *codec)
                cxt5066_asus_automic(codec);
 }
 
-/* unsolicited event for jack sensing */
-static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res)
-{
-       struct conexant_spec *spec = codec->spec;
-       snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
-       switch (res >> 26) {
-       case CONEXANT_HP_EVENT:
-               cxt5066_hp_automute(codec);
-               break;
-       case CONEXANT_MIC_EVENT:
-               /* ignore mic events in DC mode; we're always using the jack */
-               if (!spec->dc_enable)
-                       cxt5066_olpc_automic(codec);
-               break;
-       }
-}
-
 /* unsolicited event for jack sensing */
 static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res)
 {
-       snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
+       codec_dbg(codec, "CXT5066: unsol event %x (%x)\n", res, res >> 26);
        switch (res >> 26) {
        case CONEXANT_HP_EVENT:
                cxt5066_hp_automute(codec);
@@ -2338,124 +2179,10 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
                idx = imux->num_items - 1;
 
        spec->mic_boost = idx;
-       if (!spec->dc_enable)
-               cxt5066_set_mic_boost(codec);
-       return 1;
-}
-
-static void cxt5066_enable_dc(struct hda_codec *codec)
-{
-       const struct hda_verb enable_dc_mode[] = {
-               /* disable gain */
-               {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
-
-               /* switch to DC input */
-               {0x17, AC_VERB_SET_CONNECT_SEL, 3},
-               {}
-       };
-
-       /* configure as input source */
-       snd_hda_sequence_write(codec, enable_dc_mode);
-       cxt5066_olpc_select_mic(codec); /* also sets configured bias */
-}
-
-static void cxt5066_disable_dc(struct hda_codec *codec)
-{
-       /* reconfigure input source */
        cxt5066_set_mic_boost(codec);
-       /* automic also selects the right mic if we're recording */
-       cxt5066_olpc_automic(codec);
-}
-
-static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol,
-                            struct snd_ctl_elem_value *ucontrol)
-{
-       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
-       struct conexant_spec *spec = codec->spec;
-       ucontrol->value.integer.value[0] = spec->dc_enable;
-       return 0;
-}
-
-static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol,
-                            struct snd_ctl_elem_value *ucontrol)
-{
-       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
-       struct conexant_spec *spec = codec->spec;
-       int dc_enable = !!ucontrol->value.integer.value[0];
-
-       if (dc_enable == spec->dc_enable)
-               return 0;
-
-       spec->dc_enable = dc_enable;
-       if (dc_enable)
-               cxt5066_enable_dc(codec);
-       else
-               cxt5066_disable_dc(codec);
-
-       return 1;
-}
-
-static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
-                                          struct snd_ctl_elem_info *uinfo)
-{
-       return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo);
-}
-
-static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
-                                         struct snd_ctl_elem_value *ucontrol)
-{
-       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
-       struct conexant_spec *spec = codec->spec;
-       ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
-       return 0;
-}
-
-static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
-                                         struct snd_ctl_elem_value *ucontrol)
-{
-       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
-       struct conexant_spec *spec = codec->spec;
-       const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
-       unsigned int idx;
-
-       idx = ucontrol->value.enumerated.item[0];
-       if (idx >= imux->num_items)
-               idx = imux->num_items - 1;
-
-       spec->dc_input_bias = idx;
-       if (spec->dc_enable)
-               cxt5066_set_olpc_dc_bias(codec);
        return 1;
 }
 
-static void cxt5066_olpc_capture_prepare(struct hda_codec *codec)
-{
-       struct conexant_spec *spec = codec->spec;
-       /* mark as recording and configure the microphone widget so that the
-        * recording LED comes on. */
-       spec->recording = 1;
-       cxt5066_olpc_select_mic(codec);
-}
-
-static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec)
-{
-       struct conexant_spec *spec = codec->spec;
-       const struct hda_verb disable_mics[] = {
-               /* disable external mic, port B */
-               {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-               /* disble internal mic, port C */
-               {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-               /* disable DC capture, port F */
-               {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-               {},
-       };
-
-       snd_hda_sequence_write(codec, disable_mics);
-       spec->recording = 0;
-}
-
 static void conexant_check_dig_outs(struct hda_codec *codec,
                                    const hda_nid_t *dig_pins,
                                    int num_pins)
@@ -2506,43 +2233,6 @@ static const struct snd_kcontrol_new cxt5066_mixer_master[] = {
        {}
 };
 
-static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = {
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Master Playback Volume",
-               .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
-                                 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-                                 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
-               .subdevice = HDA_SUBDEV_AMP_FLAG,
-               .info = snd_hda_mixer_amp_volume_info,
-               .get = snd_hda_mixer_amp_volume_get,
-               .put = snd_hda_mixer_amp_volume_put,
-               .tlv = { .c = snd_hda_mixer_amp_tlv },
-               /* offset by 28 volume steps to limit minimum gain to -46dB */
-               .private_value =
-                       HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28),
-       },
-       {}
-};
-
-static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = {
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "DC Mode Enable Switch",
-               .info = snd_ctl_boolean_mono_info,
-               .get = cxt5066_olpc_dc_get,
-               .put = cxt5066_olpc_dc_put,
-       },
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "DC Input Bias Enum",
-               .info = cxt5066_olpc_dc_bias_enum_info,
-               .get = cxt5066_olpc_dc_bias_enum_get,
-               .put = cxt5066_olpc_dc_bias_enum_put,
-       },
-       {}
-};
-
 static const struct snd_kcontrol_new cxt5066_mixers[] = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -2633,67 +2323,6 @@ static const struct hda_verb cxt5066_init_verbs[] = {
        { } /* end */
 };
 
-static const struct hda_verb cxt5066_init_verbs_olpc[] = {
-       /* Port A: headphones */
-       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
-       {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
-
-       /* Port B: external microphone */
-       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-       /* Port C: internal microphone */
-       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-       /* Port D: unused */
-       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-       /* Port E: unused, but has primary EAPD */
-       {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-       {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
-
-       /* Port F: external DC input through microphone port */
-       {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-       /* Port G: internal speakers */
-       {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
-       {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
-
-       /* DAC1 */
-       {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
-
-       /* DAC2: unused */
-       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
-
-       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
-       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
-       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
-       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
-       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
-       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
-       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
-       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
-       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
-       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
-
-       /* Disable digital microphone port */
-       {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-       /* Audio input selectors */
-       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
-       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
-
-       /* Disable SPDIF */
-       {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-       {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-
-       /* enable unsolicited events for Port A and B */
-       {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
-       {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
-       { } /* end */
-};
-
 static const struct hda_verb cxt5066_init_verbs_vostro[] = {
        /* Port A: headphones */
        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
@@ -2879,7 +2508,7 @@ static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = {
 /* initialize jack-sensing, too */
 static int cxt5066_init(struct hda_codec *codec)
 {
-       snd_printdd("CXT5066: init\n");
+       codec_dbg(codec, "CXT5066: init\n");
        conexant_init(codec);
        if (codec->patch_ops.unsol_event) {
                cxt5066_hp_automute(codec);
@@ -2889,25 +2518,9 @@ static int cxt5066_init(struct hda_codec *codec)
        return 0;
 }
 
-static int cxt5066_olpc_init(struct hda_codec *codec)
-{
-       struct conexant_spec *spec = codec->spec;
-       snd_printdd("CXT5066: init\n");
-       conexant_init(codec);
-       cxt5066_hp_automute(codec);
-       if (!spec->dc_enable) {
-               cxt5066_set_mic_boost(codec);
-               cxt5066_olpc_automic(codec);
-       } else {
-               cxt5066_enable_dc(codec);
-       }
-       return 0;
-}
-
 enum {
        CXT5066_LAPTOP,         /* Laptops w/ EAPD support */
        CXT5066_DELL_LAPTOP,    /* Dell Laptop */
-       CXT5066_OLPC_XO_1_5,    /* OLPC XO 1.5 */
        CXT5066_DELL_VOSTRO,    /* Dell Vostro 1015i */
        CXT5066_IDEAPAD,        /* Lenovo IdeaPad U150 */
        CXT5066_THINKPAD,       /* Lenovo ThinkPad T410s, others? */
@@ -2920,7 +2533,6 @@ enum {
 static const char * const cxt5066_models[CXT5066_MODELS] = {
        [CXT5066_LAPTOP]        = "laptop",
        [CXT5066_DELL_LAPTOP]   = "dell-laptop",
-       [CXT5066_OLPC_XO_1_5]   = "olpc-xo-1_5",
        [CXT5066_DELL_VOSTRO]   = "dell-vostro",
        [CXT5066_IDEAPAD]       = "ideapad",
        [CXT5066_THINKPAD]      = "thinkpad",
@@ -2941,10 +2553,8 @@ static const struct snd_pci_quirk cxt5066_cfg_tbl[] = {
        SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS),
        SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS),
        SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD),
-       SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
        SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
                      CXT5066_LAPTOP),
-       SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
        SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD),
        SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD),
        SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS),
@@ -3030,32 +2640,11 @@ static int patch_cxt5066(struct hda_codec *codec)
                spec->mic_boost = 3; /* default 30dB gain */
                break;
 
-       case CXT5066_OLPC_XO_1_5:
-               codec->patch_ops.init = cxt5066_olpc_init;
-               codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
-               spec->init_verbs[0] = cxt5066_init_verbs_olpc;
-               spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
-               spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc;
-               spec->mixers[spec->num_mixers++] = cxt5066_mixers;
-               spec->port_d_mode = 0;
-               spec->mic_boost = 3; /* default 30dB gain */
-
-               /* no S/PDIF out */
-               spec->multiout.dig_out_nid = 0;
-
-               /* input source automatically selected */
-               spec->input_mux = NULL;
-
-               /* our capture hooks which allow us to turn on the microphone LED
-                * at the right time */
-               spec->capture_prepare = cxt5066_olpc_capture_prepare;
-               spec->capture_cleanup = cxt5066_olpc_capture_cleanup;
-               break;
        case CXT5066_DELL_VOSTRO:
                codec->patch_ops.init = cxt5066_init;
                codec->patch_ops.unsol_event = cxt5066_unsol_event;
                spec->init_verbs[0] = cxt5066_init_verbs_vostro;
-               spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
+               spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
                spec->mixers[spec->num_mixers++] = cxt5066_mixers;
                spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers;
                spec->port_d_mode = 0;
@@ -3207,11 +2796,7 @@ static int cx_auto_init(struct hda_codec *codec)
        return 0;
 }
 
-static void cx_auto_free(struct hda_codec *codec)
-{
-       snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
-       snd_hda_gen_free(codec);
-}
+#define cx_auto_free   snd_hda_gen_free
 
 static const struct hda_codec_ops cx_auto_patch_ops = {
        .build_controls = cx_auto_build_controls,
@@ -3238,6 +2823,11 @@ enum {
        CXT_FIXUP_HEADPHONE_MIC,
        CXT_FIXUP_GPIO1,
        CXT_FIXUP_THINKPAD_ACPI,
+       CXT_FIXUP_OLPC_XO,
+       CXT_FIXUP_CAP_MIX_AMP,
+       CXT_FIXUP_TOSHIBA_P105,
+       CXT_FIXUP_HP_530,
+       CXT_FIXUP_CAP_MIX_AMP_5047,
 };
 
 /* for hda_fixup_thinkpad_acpi() */
@@ -3316,6 +2906,288 @@ static void cxt_fixup_headphone_mic(struct hda_codec *codec,
        }
 }
 
+/* OPLC XO 1.5 fixup */
+
+/* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
+ * through the microphone jack.
+ * When the user enables this through a mixer switch, both internal and
+ * external microphones are disabled. Gain is fixed at 0dB. In this mode,
+ * we also allow the bias to be configured through a separate mixer
+ * control. */
+
+#define update_mic_pin(codec, nid, val)                                        \
+       snd_hda_codec_update_cache(codec, nid, 0,                       \
+                                  AC_VERB_SET_PIN_WIDGET_CONTROL, val)
+
+static const struct hda_input_mux olpc_xo_dc_bias = {
+       .num_items = 3,
+       .items = {
+               { "Off", PIN_IN },
+               { "50%", PIN_VREF50 },
+               { "80%", PIN_VREF80 },
+       },
+};
+
+static void olpc_xo_update_mic_boost(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       int ch, val;
+
+       for (ch = 0; ch < 2; ch++) {
+               val = AC_AMP_SET_OUTPUT |
+                       (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT);
+               if (!spec->dc_enable)
+                       val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
+               snd_hda_codec_write(codec, 0x17, 0,
+                                   AC_VERB_SET_AMP_GAIN_MUTE, val);
+       }
+}
+
+static void olpc_xo_update_mic_pins(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       int cur_input, val;
+       struct nid_path *path;
+
+       cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]];
+
+       /* Set up mic pins for port-B, C and F dynamically as the recording
+        * LED is turned on/off by these pin controls
+        */
+       if (!spec->dc_enable) {
+               /* disable DC bias path and pin for port F */
+               update_mic_pin(codec, 0x1e, 0);
+               snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
+
+               /* update port B (ext mic) and C (int mic) */
+               /* OLPC defers mic widget control until when capture is
+                * started because the microphone LED comes on as soon as
+                * these settings are put in place. if we did this before
+                * recording, it would give the false indication that
+                * recording is happening when it is not.
+                */
+               update_mic_pin(codec, 0x1a, spec->recording ?
+                              snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
+               update_mic_pin(codec, 0x1b, spec->recording ?
+                              snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
+               /* enable normal mic path */
+               path = snd_hda_get_path_from_idx(codec, cur_input);
+               if (path)
+                       snd_hda_activate_path(codec, path, true, false);
+       } else {
+               /* disable normal mic path */
+               path = snd_hda_get_path_from_idx(codec, cur_input);
+               if (path)
+                       snd_hda_activate_path(codec, path, false, false);
+
+               /* Even though port F is the DC input, the bias is controlled
+                * on port B.  We also leave that port as an active input (but
+                * unselected) in DC mode just in case that is necessary to
+                * make the bias setting take effect.
+                */
+               if (spec->recording)
+                       val = olpc_xo_dc_bias.items[spec->dc_input_bias].index;
+               else
+                       val = 0;
+               update_mic_pin(codec, 0x1a, val);
+               update_mic_pin(codec, 0x1b, 0);
+               /* enable DC bias path and pin */
+               update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
+               snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
+       }
+}
+
+/* mic_autoswitch hook */
+static void olpc_xo_automic(struct hda_codec *codec, struct hda_jack_tbl *jack)
+{
+       struct conexant_spec *spec = codec->spec;
+       int saved_cached_write = codec->cached_write;
+
+       codec->cached_write = 1;
+       /* in DC mode, we don't handle automic */
+       if (!spec->dc_enable)
+               snd_hda_gen_mic_autoswitch(codec, jack);
+       olpc_xo_update_mic_pins(codec);
+       snd_hda_codec_flush_cache(codec);
+       codec->cached_write = saved_cached_write;
+       if (spec->dc_enable)
+               olpc_xo_update_mic_boost(codec);
+}
+
+/* pcm_capture hook */
+static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo,
+                                struct hda_codec *codec,
+                                struct snd_pcm_substream *substream,
+                                int action)
+{
+       struct conexant_spec *spec = codec->spec;
+
+       /* toggle spec->recording flag and update mic pins accordingly
+        * for turning on/off LED
+        */
+       switch (action) {
+       case HDA_GEN_PCM_ACT_PREPARE:
+               spec->recording = 1;
+               olpc_xo_update_mic_pins(codec);
+               break;
+       case HDA_GEN_PCM_ACT_CLEANUP:
+               spec->recording = 0;
+               olpc_xo_update_mic_pins(codec);
+               break;
+       }
+}
+
+static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       ucontrol->value.integer.value[0] = spec->dc_enable;
+       return 0;
+}
+
+static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       int dc_enable = !!ucontrol->value.integer.value[0];
+
+       if (dc_enable == spec->dc_enable)
+               return 0;
+
+       spec->dc_enable = dc_enable;
+       olpc_xo_update_mic_pins(codec);
+       olpc_xo_update_mic_boost(codec);
+       return 1;
+}
+
+static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
+       return 0;
+}
+
+static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_info *uinfo)
+{
+       return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo);
+}
+
+static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       const struct hda_input_mux *imux = &olpc_xo_dc_bias;
+       unsigned int idx;
+
+       idx = ucontrol->value.enumerated.item[0];
+       if (idx >= imux->num_items)
+               idx = imux->num_items - 1;
+       if (spec->dc_input_bias == idx)
+               return 0;
+
+       spec->dc_input_bias = idx;
+       if (spec->dc_enable)
+               olpc_xo_update_mic_pins(codec);
+       return 1;
+}
+
+static const struct snd_kcontrol_new olpc_xo_mixers[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "DC Mode Enable Switch",
+               .info = snd_ctl_boolean_mono_info,
+               .get = olpc_xo_dc_mode_get,
+               .put = olpc_xo_dc_mode_put,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "DC Input Bias Enum",
+               .info = olpc_xo_dc_bias_enum_info,
+               .get = olpc_xo_dc_bias_enum_get,
+               .put = olpc_xo_dc_bias_enum_put,
+       },
+       {}
+};
+
+/* overriding mic boost put callback; update mic boost volume only when
+ * DC mode is disabled
+ */
+static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
+       if (ret > 0 && spec->dc_enable)
+               olpc_xo_update_mic_boost(codec);
+       return ret;
+}
+
+static void cxt_fixup_olpc_xo(struct hda_codec *codec,
+                                   const struct hda_fixup *fix, int action)
+{
+       struct conexant_spec *spec = codec->spec;
+       int i;
+
+       if (action != HDA_FIXUP_ACT_PROBE)
+               return;
+
+       spec->gen.mic_autoswitch_hook = olpc_xo_automic;
+       spec->gen.pcm_capture_hook = olpc_xo_capture_hook;
+       spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
+
+       snd_hda_add_new_ctls(codec, olpc_xo_mixers);
+
+       /* OLPC's microphone port is DC coupled for use with external sensors,
+        * therefore we use a 50% mic bias in order to center the input signal
+        * with the DC input range of the codec.
+        */
+       snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
+
+       /* override mic boost control */
+       for (i = 0; i < spec->gen.kctls.used; i++) {
+               struct snd_kcontrol_new *kctl =
+                       snd_array_elem(&spec->gen.kctls, i);
+               if (!strcmp(kctl->name, "Mic Boost Volume")) {
+                       kctl->put = olpc_xo_mic_boost_put;
+                       break;
+               }
+       }
+}
+
+/*
+ * Fix max input level on mixer widget to 0dB
+ * (originally it has 0x2b steps with 0dB offset 0x14)
+ */
+static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
+                                 const struct hda_fixup *fix, int action)
+{
+       snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
+                                 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
+                                 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
+                                 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
+                                 (1 << AC_AMPCAP_MUTE_SHIFT));
+}
+
+/*
+ * Fix max input level on mixer widget to 0dB
+ * (originally it has 0x1e steps with 0 dB offset 0x17)
+ */
+static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
+                                 const struct hda_fixup *fix, int action)
+{
+       snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
+                                 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
+                                 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
+                                 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
+                                 (1 << AC_AMPCAP_MUTE_SHIFT));
+}
 
 /* ThinkPad X200 & co with cxt5051 */
 static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
@@ -3401,6 +3273,68 @@ static const struct hda_fixup cxt_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = hda_fixup_thinkpad_acpi,
        },
+       [CXT_FIXUP_OLPC_XO] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = cxt_fixup_olpc_xo,
+       },
+       [CXT_FIXUP_CAP_MIX_AMP] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = cxt_fixup_cap_mix_amp,
+       },
+       [CXT_FIXUP_TOSHIBA_P105] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x10, 0x961701f0 }, /* speaker/hp */
+                       { 0x12, 0x02a1901e }, /* ext mic */
+                       { 0x14, 0x95a70110 }, /* int mic */
+                       {}
+               },
+       },
+       [CXT_FIXUP_HP_530] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x12, 0x90a60160 }, /* int mic */
+                       {}
+               },
+               .chained = true,
+               .chain_id = CXT_FIXUP_CAP_MIX_AMP,
+       },
+       [CXT_FIXUP_CAP_MIX_AMP_5047] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = cxt_fixup_cap_mix_amp_5047,
+       },
+};
+
+static const struct snd_pci_quirk cxt5045_fixups[] = {
+       SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530),
+       SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105),
+       /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
+        * really bad sound over 0dB on NID 0x17.
+        */
+       SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP),
+       SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP),
+       SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP),
+       SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP),
+       {}
+};
+
+static const struct hda_model_fixup cxt5045_fixup_models[] = {
+       { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" },
+       { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" },
+       { .id = CXT_FIXUP_HP_530, .name = "hp-530" },
+       {}
+};
+
+static const struct snd_pci_quirk cxt5047_fixups[] = {
+       /* HP laptops have really bad sound over 0 dB on NID 0x10.
+        */
+       SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047),
+       {}
+};
+
+static const struct hda_model_fixup cxt5047_fixup_models[] = {
+       { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" },
+       {}
 };
 
 static const struct snd_pci_quirk cxt5051_fixups[] = {
@@ -3408,10 +3342,16 @@ static const struct snd_pci_quirk cxt5051_fixups[] = {
        {}
 };
 
+static const struct hda_model_fixup cxt5051_fixup_models[] = {
+       { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" },
+       {}
+};
+
 static const struct snd_pci_quirk cxt5066_fixups[] = {
        SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1),
        SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
+       SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
        SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
        SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
        SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
@@ -3428,6 +3368,17 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
        {}
 };
 
+static const struct hda_model_fixup cxt5066_fixup_models[] = {
+       { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" },
+       { .id = CXT_FIXUP_GPIO1, .name = "gpio1" },
+       { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" },
+       { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" },
+       { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" },
+       { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" },
+       { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" },
+       {}
+};
+
 /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
  * can be created (bko#42825)
  */
@@ -3449,8 +3400,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
        struct conexant_spec *spec;
        int err;
 
-       printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
-              codec->chip_name);
+       codec_info(codec, "%s: BIOS auto-probing.\n", codec->chip_name);
 
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (!spec)
@@ -3467,19 +3417,28 @@ static int patch_conexant_auto(struct hda_codec *codec)
        switch (codec->vendor_id) {
        case 0x14f15045:
                codec->single_adc_amp = 1;
+               spec->gen.mixer_nid = 0x17;
+               spec->gen.add_stereo_mix_input = 1;
+               snd_hda_pick_fixup(codec, cxt5045_fixup_models,
+                                  cxt5045_fixups, cxt_fixups);
                break;
        case 0x14f15047:
                codec->pin_amp_workaround = 1;
                spec->gen.mixer_nid = 0x19;
+               spec->gen.add_stereo_mix_input = 1;
+               snd_hda_pick_fixup(codec, cxt5047_fixup_models,
+                                  cxt5047_fixups, cxt_fixups);
                break;
        case 0x14f15051:
                add_cx5051_fake_mutes(codec);
                codec->pin_amp_workaround = 1;
-               snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups);
+               snd_hda_pick_fixup(codec, cxt5051_fixup_models,
+                                  cxt5051_fixups, cxt_fixups);
                break;
        default:
                codec->pin_amp_workaround = 1;
-               snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups);
+               snd_hda_pick_fixup(codec, cxt5066_fixup_models,
+                                  cxt5066_fixups, cxt_fixups);
                break;
        }
 
@@ -3513,7 +3472,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
         * Better to make reset, then.
         */
        if (!codec->bus->sync_write) {
-               snd_printd("hda_codec: "
+               codec_info(codec,
                           "Enable sync_write for stable communication\n");
                codec->bus->sync_write = 1;
                codec->bus->allow_bus_reset = 1;
index 5ef95034d041410be9bd453ed555de99d4bb0374..0cb5b89cd0c8b3e81dd57a0bcdaa471d67d018c1 100644 (file)
@@ -68,6 +68,7 @@ struct hdmi_spec_per_pin {
        hda_nid_t pin_nid;
        int num_mux_nids;
        hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
+       int mux_idx;
        hda_nid_t cvt_nid;
 
        struct hda_codec *codec;
@@ -353,40 +354,43 @@ static struct cea_channel_speaker_allocation channel_allocations[] = {
 #define get_pcm_rec(spec, idx) \
        ((struct hda_pcm *)snd_array_elem(&spec->pcm_rec, idx))
 
-static int pin_nid_to_pin_index(struct hdmi_spec *spec, hda_nid_t pin_nid)
+static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid)
 {
+       struct hdmi_spec *spec = codec->spec;
        int pin_idx;
 
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
                if (get_pin(spec, pin_idx)->pin_nid == pin_nid)
                        return pin_idx;
 
-       snd_printk(KERN_WARNING "HDMI: pin nid %d not registered\n", pin_nid);
+       codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid);
        return -EINVAL;
 }
 
-static int hinfo_to_pin_index(struct hdmi_spec *spec,
+static int hinfo_to_pin_index(struct hda_codec *codec,
                              struct hda_pcm_stream *hinfo)
 {
+       struct hdmi_spec *spec = codec->spec;
        int pin_idx;
 
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
                if (get_pcm_rec(spec, pin_idx)->stream == hinfo)
                        return pin_idx;
 
-       snd_printk(KERN_WARNING "HDMI: hinfo %p not registered\n", hinfo);
+       codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo);
        return -EINVAL;
 }
 
-static int cvt_nid_to_cvt_index(struct hdmi_spec *spec, hda_nid_t cvt_nid)
+static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid)
 {
+       struct hdmi_spec *spec = codec->spec;
        int cvt_idx;
 
        for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++)
                if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid)
                        return cvt_idx;
 
-       snd_printk(KERN_WARNING "HDMI: cvt nid %d not registered\n", cvt_nid);
+       codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid);
        return -EINVAL;
 }
 
@@ -706,7 +710,7 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec,
 
        for (i = 0; i < 8; i++) {
                channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i);
-               printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
+               codec_dbg(codec, "HDMI: ASP channel %d => slot %d\n",
                                                channel, i);
        }
 #endif
@@ -755,8 +759,7 @@ static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
                int channel = (slotsetup & 0xf0) >> 4;
                err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel);
                if (err) {
-                       snd_printdd(KERN_NOTICE
-                                   "HDMI: channel mapping failed\n");
+                       codec_dbg(codec, "HDMI: channel mapping failed\n");
                        break;
                }
        }
@@ -967,12 +970,12 @@ static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
        int size;
 
        size = snd_hdmi_get_eld_size(codec, pin_nid);
-       printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size);
+       codec_dbg(codec, "HDMI: ELD buf size is %d\n", size);
 
        for (i = 0; i < 8; i++) {
                size = snd_hda_codec_read(codec, pin_nid, 0,
                                                AC_VERB_GET_HDMI_DIP_SIZE, i);
-               printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size);
+               codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size);
        }
 #endif
 }
@@ -994,12 +997,12 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
                        hdmi_write_dip_byte(codec, pin_nid, 0x0);
                        hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
                        if (pi != i)
-                               snd_printd(KERN_INFO "dip index %d: %d != %d\n",
+                               codec_dbg(codec, "dip index %d: %d != %d\n",
                                                bi, pi, i);
                        if (bi == 0) /* byte index wrapped around */
                                break;
                }
-               snd_printd(KERN_INFO
+               codec_dbg(codec,
                        "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
                        i, size, j);
        }
@@ -1062,6 +1065,7 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
 {
        union audio_infoframe ai;
 
+       memset(&ai, 0, sizeof(ai));
        if (conn_type == 0) { /* HDMI */
                struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
 
@@ -1080,7 +1084,7 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
                dp_ai->CC02_CT47        = active_channels - 1;
                dp_ai->CA               = ca;
        } else {
-               snd_printd("HDMI: unknown connection type at pin %d\n",
+               codec_dbg(codec, "HDMI: unknown connection type at pin %d\n",
                            pin_nid);
                return;
        }
@@ -1092,8 +1096,8 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
         */
        if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
                                        sizeof(ai))) {
-               snd_printdd("hdmi_pin_setup_infoframe: "
-                           "pin=%d channels=%d ca=0x%02x\n",
+               codec_dbg(codec,
+                         "hdmi_pin_setup_infoframe: pin=%d channels=%d ca=0x%02x\n",
                            pin_nid,
                            active_channels, ca);
                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);
 static void jack_callback(struct hda_codec *codec, struct hda_jack_tbl *jack)
 {
        struct hdmi_spec *spec = codec->spec;
-       int pin_idx = pin_nid_to_pin_index(spec, jack->nid);
+       int pin_idx = pin_nid_to_pin_index(codec, jack->nid);
        if (pin_idx < 0)
                return;
 
@@ -1180,7 +1184,7 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
                return;
        jack->jack_dirty = 1;
 
-       _snd_printd(SND_PR_VERBOSE,
+       codec_dbg(codec,
                "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",
                codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA),
                !!(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)
        int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
        int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
 
-       printk(KERN_INFO
+       codec_info(codec,
                "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
                codec->addr,
                tag,
@@ -1217,7 +1221,7 @@ static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
        int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
 
        if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) {
-               snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
+               codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag);
                return;
        }
 
@@ -1244,7 +1248,7 @@ static void haswell_verify_D0(struct hda_codec *codec,
                msleep(40);
                pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0);
                pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT;
-               snd_printd("Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr);
+               codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr);
        }
 }
 
@@ -1274,8 +1278,8 @@ static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
                else
                        new_pinctl |= AC_PINCTL_EPT_NATIVE;
 
-               snd_printdd("hdmi_pin_hbr_setup: "
-                           "NID=0x%x, %spinctl=0x%x\n",
+               codec_dbg(codec,
+                         "hdmi_pin_hbr_setup: NID=0x%x, %spinctl=0x%x\n",
                            pin_nid,
                            pinctl == new_pinctl ? "" : "new-",
                            new_pinctl);
@@ -1302,7 +1306,7 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
        err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format));
 
        if (err) {
-               snd_printdd("hdmi_setup_stream: HBR is not supported\n");
+               codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n");
                return err;
        }
 
@@ -1341,6 +1345,8 @@ static int hdmi_choose_cvt(struct hda_codec *codec,
        if (cvt_idx == spec->num_cvts)
                return -ENODEV;
 
+       per_pin->mux_idx = mux_idx;
+
        if (cvt_id)
                *cvt_id = cvt_idx;
        if (mux_id)
@@ -1349,6 +1355,22 @@ static int hdmi_choose_cvt(struct hda_codec *codec,
        return 0;
 }
 
+/* Assure the pin select the right convetor */
+static void intel_verify_pin_cvt_connect(struct hda_codec *codec,
+                       struct hdmi_spec_per_pin *per_pin)
+{
+       hda_nid_t pin_nid = per_pin->pin_nid;
+       int mux_idx, curr;
+
+       mux_idx = per_pin->mux_idx;
+       curr = snd_hda_codec_read(codec, pin_nid, 0,
+                                         AC_VERB_GET_CONNECT_SEL, 0);
+       if (curr != mux_idx)
+               snd_hda_codec_write_cache(codec, pin_nid, 0,
+                                           AC_VERB_SET_CONNECT_SEL,
+                                           mux_idx);
+}
+
 /* Intel HDMI workaround to fix audio routing issue:
  * For some Intel display codecs, pins share the same connection list.
  * 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,
                for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
                        per_cvt = get_cvt(spec, cvt_idx);
                        if (!per_cvt->assigned) {
-                               snd_printdd("choose cvt %d for pin nid %d\n",
+                               codec_dbg(codec,
+                                         "choose cvt %d for pin nid %d\n",
                                        cvt_idx, nid);
                                snd_hda_codec_write_cache(codec, nid, 0,
                                            AC_VERB_SET_CONNECT_SEL,
@@ -1416,7 +1439,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
        int err;
 
        /* Validate hinfo */
-       pin_idx = hinfo_to_pin_index(spec, hinfo);
+       pin_idx = hinfo_to_pin_index(codec, hinfo);
        if (snd_BUG_ON(pin_idx < 0))
                return -EINVAL;
        per_pin = get_pin(spec, pin_idx);
@@ -1482,9 +1505,8 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
        hda_nid_t pin_nid = per_pin->pin_nid;
 
        if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
-               snd_printk(KERN_WARNING
-                          "HDMI: pin %d wcaps %#x "
-                          "does not support connection list\n",
+               codec_warn(codec,
+                          "HDMI: pin %d wcaps %#x does not support connection list\n",
                           pin_nid, get_wcaps(codec, pin_nid));
                return -EINVAL;
        }
@@ -1527,7 +1549,7 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
        else
                eld->eld_valid = false;
 
-       _snd_printd(SND_PR_VERBOSE,
+       codec_dbg(codec,
                "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
                codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid);
 
@@ -1690,7 +1712,7 @@ static int hdmi_parse_codec(struct hda_codec *codec)
 
        nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
        if (!nid || nodes < 0) {
-               snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
+               codec_warn(codec, "HDMI: failed to get afg sub nodes\n");
                return -EINVAL;
        }
 
@@ -1744,12 +1766,25 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
 {
        hda_nid_t cvt_nid = hinfo->nid;
        struct hdmi_spec *spec = codec->spec;
-       int pin_idx = hinfo_to_pin_index(spec, hinfo);
+       int pin_idx = hinfo_to_pin_index(codec, hinfo);
        struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
        hda_nid_t pin_nid = per_pin->pin_nid;
        bool non_pcm;
        int pinctl;
 
+       if (is_haswell_plus(codec) || is_valleyview(codec)) {
+               /* Verify pin:cvt selections to avoid silent audio after S3.
+                * After S3, the audio driver restores pin:cvt selections
+                * but this can happen before gfx is ready and such selection
+                * is overlooked by HW. Thus multiple pins can share a same
+                * default convertor and mute control will affect each other,
+                * which can cause a resumed audio playback become silent
+                * after S3.
+                */
+               intel_verify_pin_cvt_connect(codec, per_pin);
+               intel_not_share_assigned_cvt(codec, pin_nid, per_pin->mux_idx);
+       }
+
        non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
        mutex_lock(&per_pin->lock);
        per_pin->channels = substream->runtime->channels;
@@ -1788,7 +1823,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
        int pinctl;
 
        if (hinfo->nid) {
-               cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid);
+               cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid);
                if (snd_BUG_ON(cvt_idx < 0))
                        return -EINVAL;
                per_cvt = get_cvt(spec, cvt_idx);
@@ -1797,7 +1832,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
                per_cvt->assigned = 0;
                hinfo->nid = 0;
 
-               pin_idx = hinfo_to_pin_index(spec, hinfo);
+               pin_idx = hinfo_to_pin_index(codec, hinfo);
                if (snd_BUG_ON(pin_idx < 0))
                        return -EINVAL;
                per_pin = get_pin(spec, pin_idx);
@@ -2211,7 +2246,7 @@ static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
                return;
 
        /* override pins connection list */
-       snd_printdd("hdmi: haswell: override pin connection 0x%x\n", nid);
+       codec_dbg(codec, "hdmi: haswell: override pin connection 0x%x\n", nid);
        snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids);
 }
 
@@ -3132,8 +3167,8 @@ static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
                else
                        hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE;
 
-               snd_printdd("atihdmi_pin_hbr_setup: "
-                               "NID=0x%x, %shbr-ctl=0x%x\n",
+               codec_dbg(codec,
+                         "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n",
                                pin_nid,
                                hbr_ctl == hbr_ctl_new ? "" : "new-",
                                hbr_ctl_new);
index 8d0a84436674bf893ec871173a53b00b89f92c68..ea2351d119f0a0ff5f10b722995eb0e7b4774688 100644 (file)
@@ -395,6 +395,8 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
                goto do_sku;
        }
 
+       if (!codec->bus->pci)
+               return -1;
        ass = codec->subsystem_id & 0xffff;
        if (ass != codec->bus->pci->subsystem_device && (ass & 1))
                goto do_sku;
@@ -405,8 +407,8 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
        ass = snd_hda_codec_get_pincfg(codec, nid);
 
        if (!(ass & 1)) {
-               printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
-                      codec->chip_name, ass);
+               codec_info(codec, "%s: SKU not ready 0x%08x\n",
+                          codec->chip_name, ass);
                return -1;
        }
 
@@ -430,17 +432,17 @@ do_sku:
        spec->cdefine.swap = (ass & 0x2) >> 1;
        spec->cdefine.override = ass & 0x1;
 
-       snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
+       codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
                   nid, spec->cdefine.sku_cfg);
-       snd_printd("SKU: port_connectivity=0x%x\n",
+       codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
                   spec->cdefine.port_connectivity);
-       snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
-       snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
-       snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
-       snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
-       snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
-       snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
-       snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
+       codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
+       codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
+       codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
+       codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
+       codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
+       codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
+       codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
 
        return 0;
 }
@@ -483,7 +485,8 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
        }
 
        ass = codec->subsystem_id & 0xffff;
-       if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
+       if (codec->bus->pci &&
+           ass != codec->bus->pci->subsystem_device && (ass & 1))
                goto do_sku;
 
        /* 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)
        if (codec->vendor_id == 0x10ec0260)
                nid = 0x17;
        ass = snd_hda_codec_get_pincfg(codec, nid);
-       snd_printd("realtek: No valid SSID, "
-                  "checking pincfg 0x%08x for NID 0x%x\n",
+       codec_dbg(codec,
+                 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
                   ass, nid);
        if (!(ass & 1))
                return 0;
@@ -516,7 +519,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
        if (((ass >> 16) & 0xf) != tmp)
                return 0;
 do_sku:
-       snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
+       codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
                   ass & 0xffff, codec->vendor_id);
        /*
         * 0 : override
@@ -574,8 +577,8 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
 {
        if (!alc_subsystem_id(codec, ports)) {
                struct alc_spec *spec = codec->spec;
-               snd_printd("realtek: "
-                          "Enable default setup for auto mode as fallback\n");
+               codec_dbg(codec,
+                         "realtek: Enable default setup for auto mode as fallback\n");
                spec->init_amp = ALC_INIT_DEFAULT;
        }
 }
@@ -845,11 +848,7 @@ static inline void alc_shutup(struct hda_codec *codec)
                snd_hda_shutup_pins(codec);
 }
 
-static void alc_free(struct hda_codec *codec)
-{
-       snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
-       snd_hda_gen_free(codec);
-}
+#define alc_free       snd_hda_gen_free
 
 #ifdef CONFIG_PM
 static void alc_power_eapd(struct hda_codec *codec)
@@ -970,6 +969,8 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
                        return alc_codec_rename(codec, p->name);
        }
 
+       if (!codec->bus->pci)
+               return 0;
        for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
                if (q->codec_vendor_id != codec->vendor_id)
                        continue;
@@ -993,6 +994,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
 
 static const struct snd_pci_quirk beep_white_list[] = {
        SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
+       SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
        SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
        SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
        SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
@@ -2786,6 +2788,237 @@ static void alc269_shutup(struct hda_codec *codec)
        snd_hda_shutup_pins(codec);
 }
 
+static void alc282_restore_default_value(struct hda_codec *codec)
+{
+       int val;
+
+       /* Power Down Control */
+       alc_write_coef_idx(codec, 0x03, 0x0002);
+       /* FIFO and filter clock */
+       alc_write_coef_idx(codec, 0x05, 0x0700);
+       /* DMIC control */
+       alc_write_coef_idx(codec, 0x07, 0x0200);
+       /* Analog clock */
+       val = alc_read_coef_idx(codec, 0x06);
+       alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
+       /* JD */
+       val = alc_read_coef_idx(codec, 0x08);
+       alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
+       /* JD offset1 */
+       alc_write_coef_idx(codec, 0x0a, 0xcccc);
+       /* JD offset2 */
+       alc_write_coef_idx(codec, 0x0b, 0xcccc);
+       /* LDO1/2/3, DAC/ADC */
+       alc_write_coef_idx(codec, 0x0e, 0x6e00);
+       /* JD */
+       val = alc_read_coef_idx(codec, 0x0f);
+       alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
+       /* Capless */
+       val = alc_read_coef_idx(codec, 0x10);
+       alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
+       /* Class D test 4 */
+       alc_write_coef_idx(codec, 0x6f, 0x0);
+       /* IO power down directly */
+       val = alc_read_coef_idx(codec, 0x0c);
+       alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
+       /* ANC */
+       alc_write_coef_idx(codec, 0x34, 0xa0c0);
+       /* AGC MUX */
+       val = alc_read_coef_idx(codec, 0x16);
+       alc_write_coef_idx(codec, 0x16, (val & ~0x0008) | 0x0);
+       /* DAC simple content protection */
+       val = alc_read_coef_idx(codec, 0x1d);
+       alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
+       /* ADC simple content protection */
+       val = alc_read_coef_idx(codec, 0x1f);
+       alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
+       /* DAC ADC Zero Detection */
+       alc_write_coef_idx(codec, 0x21, 0x8804);
+       /* PLL */
+       alc_write_coef_idx(codec, 0x63, 0x2902);
+       /* capless control 2 */
+       alc_write_coef_idx(codec, 0x68, 0xa080);
+       /* capless control 3 */
+       alc_write_coef_idx(codec, 0x69, 0x3400);
+       /* capless control 4 */
+       alc_write_coef_idx(codec, 0x6a, 0x2f3e);
+       /* capless control 5 */
+       alc_write_coef_idx(codec, 0x6b, 0x0);
+       /* class D test 2 */
+       val = alc_read_coef_idx(codec, 0x6d);
+       alc_write_coef_idx(codec, 0x6d, (val & ~0x0fff) | 0x0900);
+       /* class D test 3 */
+       alc_write_coef_idx(codec, 0x6e, 0x110a);
+       /* class D test 5 */
+       val = alc_read_coef_idx(codec, 0x70);
+       alc_write_coef_idx(codec, 0x70, (val & ~0x00f8) | 0x00d8);
+       /* class D test 6 */
+       alc_write_coef_idx(codec, 0x71, 0x0014);
+       /* classD OCP */
+       alc_write_coef_idx(codec, 0x72, 0xc2ba);
+       /* classD pure DC test */
+       val = alc_read_coef_idx(codec, 0x77);
+       alc_write_coef_idx(codec, 0x77, (val & ~0x0f80) | 0x0);
+       /* Class D amp control */
+       alc_write_coef_idx(codec, 0x6c, 0xfc06);
+}
+
+static void alc282_init(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+       bool hp_pin_sense;
+       int coef78;
+
+       alc282_restore_default_value(codec);
+
+       if (!hp_pin)
+               return;
+       hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
+       coef78 = alc_read_coef_idx(codec, 0x78);
+
+       /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
+       /* Headphone capless set to high power mode */
+       alc_write_coef_idx(codec, 0x78, 0x9004);
+
+       if (hp_pin_sense)
+               msleep(2);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
+
+       if (hp_pin_sense)
+               msleep(85);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+
+       if (hp_pin_sense)
+               msleep(100);
+
+       /* Headphone capless set to normal mode */
+       alc_write_coef_idx(codec, 0x78, coef78);
+}
+
+static void alc282_shutup(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+       bool hp_pin_sense;
+       int coef78;
+
+       if (!hp_pin) {
+               alc269_shutup(codec);
+               return;
+       }
+
+       hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
+       coef78 = alc_read_coef_idx(codec, 0x78);
+       alc_write_coef_idx(codec, 0x78, 0x9004);
+
+       if (hp_pin_sense)
+               msleep(2);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
+
+       if (hp_pin_sense)
+               msleep(85);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
+
+       if (hp_pin_sense)
+               msleep(100);
+
+       alc_auto_setup_eapd(codec, false);
+       snd_hda_shutup_pins(codec);
+       alc_write_coef_idx(codec, 0x78, coef78);
+}
+
+static void alc283_restore_default_value(struct hda_codec *codec)
+{
+       int val;
+
+       /* Power Down Control */
+       alc_write_coef_idx(codec, 0x03, 0x0002);
+       /* FIFO and filter clock */
+       alc_write_coef_idx(codec, 0x05, 0x0700);
+       /* DMIC control */
+       alc_write_coef_idx(codec, 0x07, 0x0200);
+       /* Analog clock */
+       val = alc_read_coef_idx(codec, 0x06);
+       alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
+       /* JD */
+       val = alc_read_coef_idx(codec, 0x08);
+       alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
+       /* JD offset1 */
+       alc_write_coef_idx(codec, 0x0a, 0xcccc);
+       /* JD offset2 */
+       alc_write_coef_idx(codec, 0x0b, 0xcccc);
+       /* LDO1/2/3, DAC/ADC */
+       alc_write_coef_idx(codec, 0x0e, 0x6fc0);
+       /* JD */
+       val = alc_read_coef_idx(codec, 0x0f);
+       alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
+       /* Capless */
+       val = alc_read_coef_idx(codec, 0x10);
+       alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
+       /* Class D test 4 */
+       alc_write_coef_idx(codec, 0x3a, 0x0);
+       /* IO power down directly */
+       val = alc_read_coef_idx(codec, 0x0c);
+       alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
+       /* ANC */
+       alc_write_coef_idx(codec, 0x22, 0xa0c0);
+       /* AGC MUX */
+       val = alc_read_coefex_idx(codec, 0x53, 0x01);
+       alc_write_coefex_idx(codec, 0x53, 0x01, (val & ~0x000f) | 0x0008);
+       /* DAC simple content protection */
+       val = alc_read_coef_idx(codec, 0x1d);
+       alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
+       /* ADC simple content protection */
+       val = alc_read_coef_idx(codec, 0x1f);
+       alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
+       /* DAC ADC Zero Detection */
+       alc_write_coef_idx(codec, 0x21, 0x8804);
+       /* PLL */
+       alc_write_coef_idx(codec, 0x2e, 0x2902);
+       /* capless control 2 */
+       alc_write_coef_idx(codec, 0x33, 0xa080);
+       /* capless control 3 */
+       alc_write_coef_idx(codec, 0x34, 0x3400);
+       /* capless control 4 */
+       alc_write_coef_idx(codec, 0x35, 0x2f3e);
+       /* capless control 5 */
+       alc_write_coef_idx(codec, 0x36, 0x0);
+       /* class D test 2 */
+       val = alc_read_coef_idx(codec, 0x38);
+       alc_write_coef_idx(codec, 0x38, (val & ~0x0fff) | 0x0900);
+       /* class D test 3 */
+       alc_write_coef_idx(codec, 0x39, 0x110a);
+       /* class D test 5 */
+       val = alc_read_coef_idx(codec, 0x3b);
+       alc_write_coef_idx(codec, 0x3b, (val & ~0x00f8) | 0x00d8);
+       /* class D test 6 */
+       alc_write_coef_idx(codec, 0x3c, 0x0014);
+       /* classD OCP */
+       alc_write_coef_idx(codec, 0x3d, 0xc2ba);
+       /* classD pure DC test */
+       val = alc_read_coef_idx(codec, 0x42);
+       alc_write_coef_idx(codec, 0x42, (val & ~0x0f80) | 0x0);
+       /* test mode */
+       alc_write_coef_idx(codec, 0x49, 0x0);
+       /* Class D DC enable */
+       val = alc_read_coef_idx(codec, 0x40);
+       alc_write_coef_idx(codec, 0x40, (val & ~0xf800) | 0x9800);
+       /* DC offset */
+       val = alc_read_coef_idx(codec, 0x42);
+       alc_write_coef_idx(codec, 0x42, (val & ~0xf000) | 0x2000);
+       /* Class D amp control */
+       alc_write_coef_idx(codec, 0x37, 0xfc06);
+}
+
 static void alc283_init(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
@@ -2793,6 +3026,8 @@ static void alc283_init(struct hda_codec *codec)
        bool hp_pin_sense;
        int val;
 
+       alc283_restore_default_value(codec);
+
        if (!hp_pin)
                return;
        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,
                spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
                spec->gen.vmaster_mute_enum = 1;
                codec->power_filter = led_power_filter;
-               snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
+               codec_dbg(codec,
+                         "Detected mute LED for %x:%d\n", spec->mute_led_nid,
                           spec->mute_led_polarity);
                break;
        }
@@ -3295,7 +3531,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
                alc_write_coef_idx(codec, 0xb7, 0x802b);
                break;
        }
-       snd_printdd("Headset jack set to unplugged mode.\n");
+       codec_dbg(codec, "Headset jack set to unplugged mode.\n");
 }
 
 
@@ -3338,7 +3574,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
                break;
        }
-       snd_printdd("Headset jack set to mic-in mode.\n");
+       codec_dbg(codec, "Headset jack set to mic-in mode.\n");
 }
 
 static void alc_headset_mode_default(struct hda_codec *codec)
@@ -3366,7 +3602,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
                alc_write_coef_idx(codec, 0xb7, 0x802b);
                break;
        }
-       snd_printdd("Headset jack set to headphone (default) mode.\n");
+       codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
 }
 
 /* Iphone type */
@@ -3395,7 +3631,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
                alc_write_coef_idx(codec, 0xc3, 0x0000);
                break;
        }
-       snd_printdd("Headset jack set to iPhone-style headset mode.\n");
+       codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
 }
 
 /* Nokia type */
@@ -3424,7 +3660,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
                alc_write_coef_idx(codec, 0xc3, 0x0000);
                break;
        }
-       snd_printdd("Headset jack set to Nokia-style headset mode.\n");
+       codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
 }
 
 static void alc_determine_headset_type(struct hda_codec *codec)
@@ -3466,7 +3702,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
                break;
        }
 
-       snd_printdd("Headset jack detected iPhone-style headset: %s\n",
+       codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
                    is_ctia ? "yes" : "no");
        spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
 }
@@ -3592,21 +3828,38 @@ static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
                alc_fixup_headset_mode(codec, fix, action);
 }
 
+static void alc255_set_default_jack_type(struct hda_codec *codec)
+{
+       /* Set to iphone type */
+       alc_write_coef_idx(codec, 0x1b, 0x880b);
+       alc_write_coef_idx(codec, 0x45, 0xd089);
+       alc_write_coef_idx(codec, 0x1b, 0x080b);
+       alc_write_coef_idx(codec, 0x46, 0x0004);
+       alc_write_coef_idx(codec, 0x1b, 0x0c0b);
+       msleep(30);
+}
+
 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
                                const struct hda_fixup *fix, int action)
 {
        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
-               /* Set to iphone type */
-               alc_write_coef_idx(codec, 0x1b, 0x880b);
-               alc_write_coef_idx(codec, 0x45, 0xd089);
-               alc_write_coef_idx(codec, 0x1b, 0x080b);
-               alc_write_coef_idx(codec, 0x46, 0x0004);
-               alc_write_coef_idx(codec, 0x1b, 0x0c0b);
-               msleep(30);
+               alc255_set_default_jack_type(codec);
        }
        alc_fixup_headset_mode(codec, fix, action);
 }
 
+static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
+                               const struct hda_fixup *fix, int action)
+{
+       if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+               struct alc_spec *spec = codec->spec;
+               spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
+               alc255_set_default_jack_type(codec);
+       } 
+       else
+               alc_fixup_headset_mode(codec, fix, action);
+}
+
 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
                                        const struct hda_fixup *fix, int action)
 {
@@ -3887,7 +4140,9 @@ enum {
        ALC290_FIXUP_SUBWOOFER_HSJACK,
        ALC269_FIXUP_THINKPAD_ACPI,
        ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
+       ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
        ALC255_FIXUP_HEADSET_MODE,
+       ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -4264,10 +4519,23 @@ static const struct hda_fixup alc269_fixups[] = {
                .chained = true,
                .chain_id = ALC255_FIXUP_HEADSET_MODE
        },
+       [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
+                       { }
+               },
+               .chained = true,
+               .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
+       },
        [ALC255_FIXUP_HEADSET_MODE] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_headset_mode_alc255,
        },
+       [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
+       },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -4319,6 +4587,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
        SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x0629, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
+       SND_PCI_QUIRK(0x1028, 0x062c, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
+       SND_PCI_QUIRK(0x1028, 0x062e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
+       SND_PCI_QUIRK(0x1028, 0x0632, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
        SND_PCI_QUIRK(0x1028, 0x063e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
        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[] = {
        SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
+       SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
+       SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -4573,13 +4846,15 @@ static int patch_alc269(struct hda_codec *codec)
                spec->codec_variant = ALC269_TYPE_ALC269VA;
                switch (alc_get_coef0(codec) & 0x00f0) {
                case 0x0010:
-                       if (codec->bus->pci->subsystem_vendor == 0x1025 &&
+                       if (codec->bus->pci &&
+                           codec->bus->pci->subsystem_vendor == 0x1025 &&
                            spec->cdefine.platform_type == 1)
                                err = alc_codec_rename(codec, "ALC271X");
                        spec->codec_variant = ALC269_TYPE_ALC269VB;
                        break;
                case 0x0020:
-                       if (codec->bus->pci->subsystem_vendor == 0x17aa &&
+                       if (codec->bus->pci &&
+                           codec->bus->pci->subsystem_vendor == 0x17aa &&
                            codec->bus->pci->subsystem_device == 0x21f3)
                                err = alc_codec_rename(codec, "ALC3202");
                        spec->codec_variant = ALC269_TYPE_ALC269VC;
@@ -4602,6 +4877,8 @@ static int patch_alc269(struct hda_codec *codec)
                break;
        case 0x10ec0282:
                spec->codec_variant = ALC269_TYPE_ALC282;
+               spec->shutup = alc282_shutup;
+               spec->init_hook = alc282_init;
                break;
        case 0x10ec0233:
        case 0x10ec0283:
@@ -4919,8 +5196,7 @@ static void alc272_fixup_mario(struct hda_codec *codec,
                                      (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
                                      (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
                                      (0 << AC_AMPCAP_MUTE_SHIFT)))
-               printk(KERN_WARNING
-                      "hda_codec: failed to override amp caps for NID 0x2\n");
+               codec_warn(codec, "failed to override amp caps for NID 0x2\n");
 }
 
 static 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,
        }
 }
 
+/* turn on/off mute LED per vmaster hook */
+static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
+{
+       struct hda_codec *codec = private_data;
+       struct alc_spec *spec = codec->spec;
+       unsigned int oldval = spec->gpio_led;
+
+       if (enabled)
+               spec->gpio_led &= ~0x01;
+       else
+               spec->gpio_led |= 0x01;
+       if (spec->gpio_led != oldval)
+               snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
+                                   spec->gpio_led);
+}
+
+/* avoid D3 for keeping GPIO up */
+static unsigned int gpio_led_power_filter(struct hda_codec *codec,
+                                         hda_nid_t nid,
+                                         unsigned int power_state)
+{
+       struct alc_spec *spec = codec->spec;
+       if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
+               return AC_PWRST_D0;
+       return power_state;
+}
+
+static void alc662_fixup_led_gpio1(struct hda_codec *codec,
+                                  const struct hda_fixup *fix, int action)
+{
+       struct alc_spec *spec = codec->spec;
+       static const struct hda_verb gpio_init[] = {
+               { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
+               { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
+               {}
+       };
+
+       if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+               spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
+               spec->gpio_led = 0;
+               snd_hda_add_verbs(codec, gpio_init);
+               codec->power_filter = gpio_led_power_filter;
+       }
+}
+
 enum {
        ALC662_FIXUP_ASPIRE,
+       ALC662_FIXUP_LED_GPIO1,
        ALC662_FIXUP_IDEAPAD,
        ALC272_FIXUP_MARIO,
        ALC662_FIXUP_CZC_P10T,
@@ -4962,9 +5284,10 @@ enum {
        ALC662_FIXUP_INV_DMIC,
        ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
        ALC668_FIXUP_HEADSET_MODE,
-       ALC662_FIXUP_BASS_CHMAP,
+       ALC662_FIXUP_BASS_MODE4_CHMAP,
+       ALC662_FIXUP_BASS_16,
        ALC662_FIXUP_BASS_1A,
-       ALC662_FIXUP_BASS_1A_CHMAP,
+       ALC662_FIXUP_BASS_CHMAP,
        ALC668_FIXUP_AUTO_MUTE,
 };
 
@@ -4976,12 +5299,18 @@ static const struct hda_fixup alc662_fixups[] = {
                        { }
                }
        },
+       [ALC662_FIXUP_LED_GPIO1] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc662_fixup_led_gpio1,
+       },
        [ALC662_FIXUP_IDEAPAD] = {
                .type = HDA_FIXUP_PINS,
                .v.pins = (const struct hda_pintbl[]) {
                        { 0x17, 0x99130112 }, /* subwoofer */
                        { }
-               }
+               },
+               .chained = true,
+               .chain_id = ALC662_FIXUP_LED_GPIO1,
        },
        [ALC272_FIXUP_MARIO] = {
                .type = HDA_FIXUP_FUNC,
@@ -5146,24 +5475,33 @@ static const struct hda_fixup alc662_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_headset_mode_alc668,
        },
-       [ALC662_FIXUP_BASS_CHMAP] = {
+       [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_bass_chmap,
                .chained = true,
                .chain_id = ALC662_FIXUP_ASUS_MODE4
        },
+       [ALC662_FIXUP_BASS_16] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       {0x16, 0x80106111}, /* bass speaker */
+                       {}
+               },
+               .chained = true,
+               .chain_id = ALC662_FIXUP_BASS_CHMAP,
+       },
        [ALC662_FIXUP_BASS_1A] = {
                .type = HDA_FIXUP_PINS,
                .v.pins = (const struct hda_pintbl[]) {
                        {0x1a, 0x80106111}, /* bass speaker */
                        {}
                },
+               .chained = true,
+               .chain_id = ALC662_FIXUP_BASS_CHMAP,
        },
-       [ALC662_FIXUP_BASS_1A_CHMAP] = {
+       [ALC662_FIXUP_BASS_CHMAP] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_bass_chmap,
-               .chained = true,
-               .chain_id = ALC662_FIXUP_BASS_1A,
        },
 };
 
@@ -5185,9 +5523,11 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1028, 0x0628, "Dell", ALC668_FIXUP_AUTO_MUTE),
        SND_PCI_QUIRK(0x1028, 0x064e, "Dell", ALC668_FIXUP_AUTO_MUTE),
        SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
-       SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP),
-       SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP),
-       SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_CHMAP),
+       SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
+       SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
+       SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
+       SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
+       SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
        SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
        SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
        SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
@@ -5328,7 +5668,7 @@ static int patch_alc662(struct hda_codec *codec)
                spec->gen.beep_nid = 0x01;
 
        if ((alc_get_coef0(codec) & (1 << 14)) &&
-           codec->bus->pci->subsystem_vendor == 0x1025 &&
+           codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
            spec->cdefine.platform_type == 1) {
                err = alc_codec_rename(codec, "ALC272X");
                if (err < 0)
index 6679a5095e559ddee57fe068593c31e39a613126..3208ad69583ee5564272d16ce2fd97185351a53c 100644 (file)
@@ -236,7 +236,7 @@ static int si3054_init(struct hda_codec *codec)
        } while ((val & SI3054_MEI_READY) != SI3054_MEI_READY && wait_count--);
 
        if((val&SI3054_MEI_READY) != SI3054_MEI_READY) {
-               snd_printk(KERN_ERR "si3054: cannot initialize. EXT MID = %04x\n", val);
+               codec_err(codec, "si3054: cannot initialize. EXT MID = %04x\n", val);
                /* let's pray that this is no fatal error */
                /* return -EACCES; */
        }
@@ -247,7 +247,8 @@ static int si3054_init(struct hda_codec *codec)
        SET_REG(codec, SI3054_LINE_CFG1,0x200);
 
        if((GET_REG(codec,SI3054_LINE_STATUS) & (1<<6)) == 0) {
-               snd_printd("Link Frame Detect(FDT) is not ready (line status: %04x)\n",
+               codec_dbg(codec,
+                         "Link Frame Detect(FDT) is not ready (line status: %04x)\n",
                                GET_REG(codec,SI3054_LINE_STATUS));
        }
 
index 3bc29c9b25296d6ed058eaf552bf71bdba356cab..75515b4940341a8599219f6a3ff2ee741b9f8138 100644 (file)
@@ -296,7 +296,7 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
 {
        unsigned int gpiostate, gpiomask, gpiodir;
 
-       snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
+       codec_dbg(codec, "%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
 
        gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
                                       AC_VERB_GET_GPIO_DATA, 0);
@@ -359,7 +359,7 @@ static int stac_vrefout_set(struct hda_codec *codec,
 {
        int error, pinctl;
 
-       snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
+       codec_dbg(codec, "%s, nid %x ctl %x\n", __func__, nid, new_vref);
        pinctl = snd_hda_codec_read(codec, nid, 0,
                                AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
 
@@ -2086,9 +2086,12 @@ static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
        }
 
        if (find_mute_led_cfg(codec, spec->default_polarity))
-               snd_printd("mute LED gpio %d polarity %d\n",
+               codec_dbg(codec, "mute LED gpio %d polarity %d\n",
                                spec->gpio_led,
                                spec->gpio_led_polarity);
+
+       /* allow auto-switching of dock line-in */
+       spec->gen.line_in_auto_switch = true;
 }
 
 static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
@@ -3077,7 +3080,7 @@ static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
        }
 
        if (find_mute_led_cfg(codec, 1))
-               snd_printd("mute LED gpio %d polarity %d\n",
+               codec_dbg(codec, "mute LED gpio %d polarity %d\n",
                                spec->gpio_led,
                                spec->gpio_led_polarity);
 
@@ -4422,8 +4425,8 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
 
        num_dacs = snd_hda_get_num_conns(codec, 0x0a) - 1;
        if (num_dacs < 3 || num_dacs > 5) {
-               printk(KERN_WARNING "hda_codec: Could not determine "
-                      "number of channels defaulting to DAC count\n");
+               codec_warn(codec,
+                          "Could not determine number of channels defaulting to DAC count\n");
                num_dacs = 5;
        }
 
index f84195f3ea31e2f6bac3c1c5f79355e1ec24c0fb..778166259b3e8e72fe039d08fe5e1671d5c6fd94 100644 (file)
@@ -465,14 +465,8 @@ static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
 
 static void via_free(struct hda_codec *codec)
 {
-       struct via_spec *spec = codec->spec;
-
-       if (!spec)
-               return;
-
        vt1708_stop_hp_work(codec);
-       snd_hda_gen_spec_free(&spec->gen);
-       kfree(spec);
+       snd_hda_gen_free(codec);
 }
 
 #ifdef CONFIG_PM
index 8fe3b8c18ed4b2c25c00b4963ec766b7671829d9..6ba0b5517c407fdb015a8ca366440b32128a92c6 100644 (file)
@@ -63,7 +63,8 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
                if (!led_set_func)
                        led_set_func = symbol_request(tpacpi_led_set);
                if (!led_set_func) {
-                       snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
+                       codec_warn(codec,
+                                  "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
                        return;
                }
 
@@ -75,7 +76,8 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
                }
                if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
                        if (spec->num_adc_nids > 1)
-                               snd_printdd("Skipping micmute LED control due to several ADCs");
+                               codec_dbg(codec,
+                                         "Skipping micmute LED control due to several ADCs");
                        else {
                                spec->cap_sync_hook = update_tpacpi_micmute_led;
                                removefunc = false;
index 55902ec40344d824b17d56d37d047f79281ba294..3b3cf4ac9060ac41b9876e52c94a4151e61cdce5 100644 (file)
@@ -1937,9 +1937,12 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
                snd_ice1712_save_gpio_status(ice);
                id = aureon_cs8415_get(ice, CS8415_ID);
                if (id != 0x41)
-                       snd_printk(KERN_INFO "No CS8415 chip. Skipping CS8415 controls.\n");
+                       dev_info(ice->card->dev,
+                                "No CS8415 chip. Skipping CS8415 controls.\n");
                else if ((id & 0x0F) != 0x01)
-                       snd_printk(KERN_INFO "Detected unsupported CS8415 rev. (%c)\n", (char)((id & 0x0F) + 'A' - 1));
+                       dev_info(ice->card->dev,
+                                "Detected unsupported CS8415 rev. (%c)\n",
+                                (char)((id & 0x0F) + 'A' - 1));
                else {
                        for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) {
                                struct snd_kcontrol *kctl;
index 9e28cc12969b3632357ae4f198634da499864903..ed2144eee38ac872d80e263953733639630169b2 100644 (file)
@@ -425,7 +425,8 @@ static int snd_ice1712_delta1010lt_wordclock_status_get(struct snd_kcontrol *kco
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
 
        if (snd_i2c_sendbytes(ice->cs8427, &reg, 1) != 1)
-               snd_printk(KERN_ERR "unable to send register 0x%x byte to CS8427\n", reg);
+               dev_err(ice->card->dev,
+                       "unable to send register 0x%x byte to CS8427\n", reg);
        snd_i2c_readbytes(ice->cs8427, &reg, 1);
        ucontrol->value.integer.value[0] = (reg & CS8427_UNLOCK) ? 1 : 0;
        return 0;
@@ -575,6 +576,30 @@ static struct snd_ak4xxx_private akm_vx442_priv = {
        .mask_flags = 0,
 };
 
+#ifdef CONFIG_PM_SLEEP
+static int snd_ice1712_delta_resume(struct snd_ice1712 *ice)
+{
+       unsigned char akm_backup[AK4XXX_IMAGE_SIZE];
+       /* init codec and restore registers */
+       if (ice->akm_codecs) {
+               memcpy(akm_backup, ice->akm->images, sizeof(akm_backup));
+               snd_akm4xxx_init(ice->akm);
+               memcpy(ice->akm->images, akm_backup, sizeof(akm_backup));
+               snd_akm4xxx_reset(ice->akm, 0);
+       }
+
+       return 0;
+}
+
+static int snd_ice1712_delta_suspend(struct snd_ice1712 *ice)
+{
+       if (ice->akm_codecs) /* reset & mute codec */
+               snd_akm4xxx_reset(ice->akm, 1);
+
+       return 0;
+}
+#endif
+
 static int snd_ice1712_delta_init(struct snd_ice1712 *ice)
 {
        int err;
@@ -621,7 +646,11 @@ static int snd_ice1712_delta_init(struct snd_ice1712 *ice)
                ice->num_total_adcs = 4;
                break;
        }
-
+#ifdef CONFIG_PM_SLEEP
+       ice->pm_resume = snd_ice1712_delta_resume;
+       ice->pm_suspend = snd_ice1712_delta_suspend;
+       ice->pm_suspend_enabled = 1;
+#endif
        /* initialize the SPI clock to high */
        tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
        tmp |= ICE1712_DELTA_AP_CCLK;
@@ -637,7 +666,7 @@ static int snd_ice1712_delta_init(struct snd_ice1712 *ice)
        case ICE1712_SUBDEVICE_VX442:
        case ICE1712_SUBDEVICE_DELTA66E:
                if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
-                       snd_printk(KERN_ERR "unable to create I2C bus\n");
+                       dev_err(ice->card->dev, "unable to create I2C bus\n");
                        return err;
                }
                ice->i2c->private_data = ice;
index bc2e7011c55d7fa184b63197f82ea7d6fab00a95..817a1bc50a60137e5c6674de07ac0c1a1b928ab1 100644 (file)
@@ -163,7 +163,8 @@ static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mas
 
      __error:
        snd_i2c_unlock(ice->i2c);
-       snd_printk(KERN_ERR "AK4524 chip select failed, check cable to the front module\n");
+       dev_err(ice->card->dev,
+               "AK4524 chip select failed, check cable to the front module\n");
        return -EIO;
 }
 
@@ -174,7 +175,7 @@ static void ews88mt_ak4524_lock(struct snd_akm4xxx *ak, int chip)
        unsigned char tmp;
        /* assert AK4524 CS */
        if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0)
-               snd_printk(KERN_ERR "fatal error (ews88mt chip select)\n");
+               dev_err(ice->card->dev, "fatal error (ews88mt chip select)\n");
        snd_ice1712_save_gpio_status(ice);
        tmp = ICE1712_EWS88_SERIAL_DATA |
                ICE1712_EWS88_SERIAL_CLOCK |
@@ -456,7 +457,7 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice)
 
        /* create i2c */
        if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
-               snd_printk(KERN_ERR "unable to create I2C bus\n");
+               dev_err(ice->card->dev, "unable to create I2C bus\n");
                return err;
        }
        ice->i2c->private_data = ice;
@@ -469,7 +470,8 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice)
                                            ICE1712_6FIRE_PCF9554_ADDR,
                                            &spec->i2cdevs[EWS_I2C_6FIRE]);
                if (err < 0) {
-                       snd_printk(KERN_ERR "PCF9554 initialization failed\n");
+                       dev_err(ice->card->dev,
+                               "PCF9554 initialization failed\n");
                        return err;
                }
                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
        byte = 0;
        if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
                snd_i2c_unlock(ice->i2c);
-               printk(KERN_ERR "cannot read pca\n");
+               dev_err(ice->card->dev, "cannot read pca\n");
                return -EIO;
        }
        snd_i2c_unlock(ice->i2c);
index 28ec872e54c01350369bf47f143db9c2d5da8b8d..291672fc4a99f2428c171c9a57955280776df209 100644 (file)
@@ -394,7 +394,7 @@ int snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr)
        err = snd_cs8427_create(ice->i2c, addr,
                (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427);
        if (err < 0) {
-               snd_printk(KERN_ERR "CS8427 initialization failed\n");
+               dev_err(ice->card->dev, "CS8427 initialization failed\n");
                return err;
        }
        ice->spdif.ops.open = open_cs8427;
@@ -467,7 +467,7 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id)
                        u16 pbkstatus;
                        struct snd_pcm_substream *substream;
                        pbkstatus = inw(ICEDS(ice, INTSTAT));
-                       /* printk(KERN_DEBUG "pbkstatus = 0x%x\n", pbkstatus); */
+                       /* dev_dbg(ice->card->dev, "pbkstatus = 0x%x\n", pbkstatus); */
                        for (idx = 0; idx < 6; idx++) {
                                if ((pbkstatus & (3 << (idx * 2))) == 0)
                                        continue;
@@ -903,7 +903,8 @@ static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm *
        if (rpcm)
                *rpcm = pcm;
 
-       printk(KERN_WARNING "Consumer PCM code does not work well at the moment --jk\n");
+       dev_warn(ice->card->dev,
+                "Consumer PCM code does not work well at the moment --jk\n");
 
        return 0;
 }
@@ -1534,7 +1535,8 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
                ac97.private_free = snd_ice1712_mixer_free_ac97;
                err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
                if (err < 0)
-                       printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n");
+                       dev_warn(ice->card->dev,
+                                "cannot initialize ac97 for consumer, skipped\n");
                else {
                        err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice));
                        if (err < 0)
@@ -1552,7 +1554,8 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
                ac97.private_free = snd_ice1712_mixer_free_ac97;
                err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
                if (err < 0)
-                       printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n");
+                       dev_warn(ice->card->dev,
+                                "cannot initialize pro ac97, skipped\n");
                else
                        return 0;
        }
@@ -2332,7 +2335,8 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
                        pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device);
                        ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device);
                        if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) {
-                               printk(KERN_ERR "ice1712: No valid ID is found\n");
+                               dev_err(ice->card->dev,
+                                       "No valid ID is found\n");
                                return -ENXIO;
                        }
                }
@@ -2340,21 +2344,22 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
        for (tbl = card_tables; *tbl; tbl++) {
                for (c = *tbl; c->subvendor; c++) {
                        if (modelname && c->model && !strcmp(modelname, c->model)) {
-                               printk(KERN_INFO "ice1712: Using board model %s\n", c->name);
+                               dev_info(ice->card->dev,
+                                        "Using board model %s\n", c->name);
                                ice->eeprom.subvendor = c->subvendor;
                        } else if (c->subvendor != ice->eeprom.subvendor)
                                continue;
                        if (!c->eeprom_size || !c->eeprom_data)
                                goto found;
                        /* if the EEPROM is given by the driver, use it */
-                       snd_printdd("using the defined eeprom..\n");
+                       dev_dbg(ice->card->dev, "using the defined eeprom..\n");
                        ice->eeprom.version = 1;
                        ice->eeprom.size = c->eeprom_size + 6;
                        memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
                        goto read_skipped;
                }
        }
-       printk(KERN_WARNING "ice1712: No matching model found for ID 0x%x\n",
+       dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n",
               ice->eeprom.subvendor);
 
  found:
@@ -2362,12 +2367,13 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
        if (ice->eeprom.size < 6)
                ice->eeprom.size = 32; /* FIXME: any cards without the correct size? */
        else if (ice->eeprom.size > 32) {
-               snd_printk(KERN_ERR "invalid EEPROM (size = %i)\n", ice->eeprom.size);
+               dev_err(ice->card->dev,
+                       "invalid EEPROM (size = %i)\n", ice->eeprom.size);
                return -EIO;
        }
        ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05);
        if (ice->eeprom.version != 1) {
-               snd_printk(KERN_ERR "invalid EEPROM version %i\n",
+               dev_err(ice->card->dev, "invalid EEPROM version %i\n",
                           ice->eeprom.version);
                /* return -EIO; */
        }
@@ -2428,6 +2434,13 @@ static int snd_ice1712_chip_init(struct snd_ice1712 *ice)
                snd_ice1712_write(ice, ICE1712_IREG_CONSUMER_POWERDOWN, 0);
        }
        snd_ice1712_set_pro_rate(ice, 48000, 1);
+       /* unmask used interrupts */
+       outb(((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ?
+             ICE1712_IRQ_MPU2 : 0) |
+            ((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ?
+             ICE1712_IRQ_PBKDS | ICE1712_IRQ_CONCAP | ICE1712_IRQ_CONPBK : 0),
+            ICEREG(ice, IRQMASK));
+       outb(0x00, ICEMT(ice, IRQ));
 
        return 0;
 }
@@ -2553,7 +2566,8 @@ static int snd_ice1712_create(struct snd_card *card,
        /* check, if we can restrict PCI DMA transfers to 28 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 28bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -2589,6 +2603,7 @@ static int snd_ice1712_create(struct snd_card *card,
        ice->pci = pci;
        ice->irq = -1;
        pci_set_master(pci);
+       /* disable legacy emulation */
        pci_write_config_word(ice->pci, 0x40, 0x807f);
        pci_write_config_word(ice->pci, 0x42, 0x0006);
        snd_ice1712_proc_init(ice);
@@ -2609,7 +2624,7 @@ static int snd_ice1712_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_ice1712_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, ice)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_ice1712_free(ice);
                return -EIO;
        }
@@ -2625,22 +2640,12 @@ static int snd_ice1712_create(struct snd_card *card,
                return -EIO;
        }
 
-       /* unmask used interrupts */
-       outb(((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ?
-             ICE1712_IRQ_MPU2 : 0) |
-            ((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ?
-             ICE1712_IRQ_PBKDS | ICE1712_IRQ_CONCAP | ICE1712_IRQ_CONPBK : 0),
-            ICEREG(ice, IRQMASK));
-       outb(0x00, ICEMT(ice, IRQ));
-
        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops);
        if (err < 0) {
                snd_ice1712_free(ice);
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_ice1712 = ice;
        return 0;
 }
@@ -2670,7 +2675,8 @@ static int snd_ice1712_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -2809,11 +2815,80 @@ static void snd_ice1712_remove(struct pci_dev *pci)
        snd_card_free(card);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int snd_ice1712_suspend(struct device *dev)
+{
+       struct pci_dev *pci = to_pci_dev(dev);
+       struct snd_card *card = dev_get_drvdata(dev);
+       struct snd_ice1712 *ice = card->private_data;
+
+       if (!ice->pm_suspend_enabled)
+               return 0;
+
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+
+       snd_pcm_suspend_all(ice->pcm);
+       snd_pcm_suspend_all(ice->pcm_pro);
+       snd_pcm_suspend_all(ice->pcm_ds);
+       snd_ac97_suspend(ice->ac97);
+
+       if (ice->pm_suspend)
+               ice->pm_suspend(ice);
+
+       pci_disable_device(pci);
+       pci_save_state(pci);
+       pci_set_power_state(pci, PCI_D3hot);
+       return 0;
+}
+
+static int snd_ice1712_resume(struct device *dev)
+{
+       struct pci_dev *pci = to_pci_dev(dev);
+       struct snd_card *card = dev_get_drvdata(dev);
+       struct snd_ice1712 *ice = card->private_data;
+
+       if (!ice->pm_suspend_enabled)
+               return 0;
+
+       pci_set_power_state(pci, PCI_D0);
+       pci_restore_state(pci);
+
+       if (pci_enable_device(pci) < 0) {
+               snd_card_disconnect(card);
+               return -EIO;
+       }
+
+       pci_set_master(pci);
+
+       if (snd_ice1712_chip_init(ice) < 0) {
+               snd_card_disconnect(card);
+               return -EIO;
+       }
+
+       if (ice->pm_resume)
+               ice->pm_resume(ice);
+
+       if (ice->ac97)
+               snd_ac97_resume(ice->ac97);
+
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+       return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(snd_ice1712_pm, snd_ice1712_suspend, snd_ice1712_resume);
+#define SND_VT1712_PM_OPS      &snd_ice1712_pm
+#else
+#define SND_VT1712_PM_OPS      NULL
+#endif /* CONFIG_PM_SLEEP */
+
 static struct pci_driver ice1712_driver = {
        .name = KBUILD_MODNAME,
        .id_table = snd_ice1712_ids,
        .probe = snd_ice1712_probe,
        .remove = snd_ice1712_remove,
+       .driver = {
+               .pm = SND_VT1712_PM_OPS,
+       },
 };
 
 module_pci_driver(ice1712_driver);
index 50047177829172f97c0c6b9302854bdd8b0aca93..5e7948f3efe91d80609543c1b090a48f969251db 100644 (file)
@@ -146,7 +146,7 @@ static unsigned char snd_vt1724_ac97_ready(struct snd_ice1712 *ice)
                        continue;
                return old_cmd;
        }
-       snd_printd(KERN_ERR "snd_vt1724_ac97_ready: timeout\n");
+       dev_dbg(ice->card->dev, "snd_vt1724_ac97_ready: timeout\n");
        return old_cmd;
 }
 
@@ -156,7 +156,7 @@ static int snd_vt1724_ac97_wait_bit(struct snd_ice1712 *ice, unsigned char bit)
        for (tm = 0; tm < 0x10000; tm++)
                if ((inb(ICEMT1724(ice, AC97_CMD)) & bit) == 0)
                        return 0;
-       snd_printd(KERN_ERR "snd_vt1724_ac97_wait_bit: timeout\n");
+       dev_dbg(ice->card->dev, "snd_vt1724_ac97_wait_bit: timeout\n");
        return -EIO;
 }
 
@@ -430,10 +430,10 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
                spin_lock(&ice->reg_lock);
                if (++timeout > 10) {
                        status = inb(ICEREG1724(ice, IRQSTAT));
-                       printk(KERN_ERR "ice1724: Too long irq loop, "
-                              "status = 0x%x\n", status);
+                       dev_err(ice->card->dev,
+                               "Too long irq loop, status = 0x%x\n", status);
                        if (status & VT1724_IRQ_MPU_TX) {
-                               printk(KERN_ERR "ice1724: Disabling MPU_TX\n");
+                               dev_err(ice->card->dev, "Disabling MPU_TX\n");
                                enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
                        }
                        spin_unlock(&ice->reg_lock);
@@ -801,7 +801,7 @@ static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream)
        spin_unlock_irq(&ice->reg_lock);
 
        /*
-       printk(KERN_DEBUG "pro prepare: ch = %d, addr = 0x%x, "
+       dev_dbg(ice->card->dev, "pro prepare: ch = %d, addr = 0x%x, "
               "buffer = 0x%x, period = 0x%x\n",
               substream->runtime->channels,
               (unsigned int)substream->runtime->dma_addr,
@@ -821,13 +821,13 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substrea
 #if 0 /* read PLAYBACK_ADDR */
        ptr = inl(ICEMT1724(ice, PLAYBACK_ADDR));
        if (ptr < substream->runtime->dma_addr) {
-               snd_printd("ice1724: invalid negative ptr\n");
+               dev_dbg(ice->card->dev, "invalid negative ptr\n");
                return 0;
        }
        ptr -= substream->runtime->dma_addr;
        ptr = bytes_to_frames(substream->runtime, ptr);
        if (ptr >= substream->runtime->buffer_size) {
-               snd_printd("ice1724: invalid ptr %d (size=%d)\n",
+               dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
                           (int)ptr, (int)substream->runtime->period_size);
                return 0;
        }
@@ -840,7 +840,7 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substrea
        else if (ptr <= substream->runtime->buffer_size)
                ptr = substream->runtime->buffer_size - ptr;
        else {
-               snd_printd("ice1724: invalid ptr %d (size=%d)\n",
+               dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
                           (int)ptr, (int)substream->runtime->buffer_size);
                ptr = 0;
        }
@@ -884,7 +884,7 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substr
        else if (ptr <= substream->runtime->buffer_size)
                ptr = substream->runtime->buffer_size - ptr;
        else {
-               snd_printd("ice1724: invalid ptr %d (size=%d)\n",
+               dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
                           (int)ptr, (int)substream->runtime->buffer_size);
                ptr = 0;
        }
@@ -1508,7 +1508,8 @@ static int snd_vt1724_ac97_mixer(struct snd_ice1712 *ice)
                ac97.private_data = ice;
                err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
                if (err < 0)
-                       printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n");
+                       dev_warn(ice->card->dev,
+                                "cannot initialize pro ac97, skipped\n");
                else
                        return 0;
        }
@@ -2271,7 +2272,7 @@ static void wait_i2c_busy(struct snd_ice1712 *ice)
        while ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_BUSY) && t--)
                ;
        if (t == -1)
-               printk(KERN_ERR "ice1724: i2c busy timeout\n");
+               dev_err(ice->card->dev, "i2c busy timeout\n");
 }
 
 unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
@@ -2287,7 +2288,7 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
        val = inb(ICEREG1724(ice, I2C_DATA));
        mutex_unlock(&ice->i2c_mutex);
        /*
-       printk(KERN_DEBUG "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
+       dev_dbg(ice->card->dev, "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
        */
        return val;
 }
@@ -2298,7 +2299,7 @@ void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
        mutex_lock(&ice->i2c_mutex);
        wait_i2c_busy(ice);
        /*
-       printk(KERN_DEBUG "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
+       dev_dbg(ice->card->dev, "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
        */
        outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
        outb(data, ICEREG1724(ice, I2C_DATA));
@@ -2335,7 +2336,8 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
                                ((unsigned int)swab16(vendor) << 16) | swab16(device);
                        if (ice->eeprom.subvendor == 0 ||
                            ice->eeprom.subvendor == (unsigned int)-1) {
-                               printk(KERN_ERR "ice1724: No valid ID is found\n");
+                               dev_err(ice->card->dev,
+                                       "No valid ID is found\n");
                                return -ENXIO;
                        }
                }
@@ -2344,7 +2346,8 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
                for (c = *tbl; c->name; c++) {
                        if (modelname && c->model &&
                            !strcmp(modelname, c->model)) {
-                               printk(KERN_INFO "ice1724: Using board model %s\n",
+                               dev_info(ice->card->dev,
+                                        "Using board model %s\n",
                                       c->name);
                                ice->eeprom.subvendor = c->subvendor;
                        } else if (c->subvendor != ice->eeprom.subvendor)
@@ -2353,14 +2356,14 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
                        if (!c->eeprom_size || !c->eeprom_data)
                                goto found;
                        /* if the EEPROM is given by the driver, use it */
-                       snd_printdd("using the defined eeprom..\n");
+                       dev_dbg(ice->card->dev, "using the defined eeprom..\n");
                        ice->eeprom.version = 2;
                        ice->eeprom.size = c->eeprom_size + 6;
                        memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
                        goto read_skipped;
                }
        }
-       printk(KERN_WARNING "ice1724: No matching model found for ID 0x%x\n",
+       dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n",
               ice->eeprom.subvendor);
 #ifdef CONFIG_PM_SLEEP
        /* assume AC97-only card which can suspend without additional code */
@@ -2372,13 +2375,13 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
        if (ice->eeprom.size < 6)
                ice->eeprom.size = 32;
        else if (ice->eeprom.size > 32) {
-               printk(KERN_ERR "ice1724: Invalid EEPROM (size = %i)\n",
+               dev_err(ice->card->dev, "Invalid EEPROM (size = %i)\n",
                       ice->eeprom.size);
                return -EIO;
        }
        ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05);
        if (ice->eeprom.version != 1 && ice->eeprom.version != 2)
-               printk(KERN_WARNING "ice1724: Invalid EEPROM version %i\n",
+               dev_warn(ice->card->dev, "Invalid EEPROM version %i\n",
                       ice->eeprom.version);
        size = ice->eeprom.size - 6;
        for (i = 0; i < size; i++)
@@ -2586,7 +2589,7 @@ static int snd_vt1724_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_vt1724_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, ice)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_vt1724_free(ice);
                return -EIO;
        }
@@ -2609,8 +2612,6 @@ static int snd_vt1724_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_ice1712 = ice;
        return 0;
 }
@@ -2638,7 +2639,8 @@ static int snd_vt1724_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
index 8855933e710d7fe54e60ddffe6e509558f9b4589..7a6c0786c55c29f9a104c11298148d9e15d0d3a2 100644 (file)
@@ -244,7 +244,7 @@ static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
        /* AK5385 first, since it requires cold reset affecting both codecs */
        old_gpio = ice->gpio.get_data(ice);
        new_gpio =  (old_gpio & ~GPIO_AK5385A_MASK) | ak5385_pins;
-       /* printk(KERN_DEBUG "JULI - ak5385 set_rate_val: new gpio 0x%x\n",
+       /* dev_dbg(ice->card->dev, "JULI - ak5385 set_rate_val: new gpio 0x%x\n",
                new_gpio); */
        ice->gpio.set_data(ice, new_gpio);
 
@@ -344,7 +344,7 @@ static int juli_mute_put(struct snd_kcontrol *kcontrol,
                        new_gpio =  old_gpio &
                                ~((unsigned int) kcontrol->private_value);
        }
-       /* printk(KERN_DEBUG
+       /* dev_dbg(ice->card->dev,
                "JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, "
                "new_gpio 0x%x\n",
                (unsigned int)ucontrol->value.integer.value[0], old_gpio,
@@ -439,9 +439,9 @@ static void add_slaves(struct snd_card *card,
 {
        for (; *list; list++) {
                struct snd_kcontrol *slave = ctl_find(card, *list);
-               /* printk(KERN_DEBUG "add_slaves - %s\n", *list); */
+               /* dev_dbg(card->dev, "add_slaves - %s\n", *list); */
                if (slave) {
-                       /* printk(KERN_DEBUG "slave %s found\n", *list); */
+                       /* dev_dbg(card->dev, "slave %s found\n", *list); */
                        snd_ctl_add_slave(master, slave);
                }
        }
@@ -536,7 +536,7 @@ static void juli_set_rate(struct snd_ice1712 *ice, unsigned int rate)
 
        old = ice->gpio.get_data(ice);
        new =  (old & ~GPIO_RATE_MASK) | get_gpio_val(rate);
-       /* printk(KERN_DEBUG "JULI - set_rate: old %x, new %x\n",
+       /* dev_dbg(ice->card->dev, "JULI - set_rate: old %x, new %x\n",
                        old & GPIO_RATE_MASK,
                        new & GPIO_RATE_MASK); */
 
@@ -573,7 +573,7 @@ static void juli_ak4114_change(struct ak4114 *ak4114, unsigned char c0,
        if (ice->is_spdif_master(ice) && c1) {
                /* only for SPDIF master mode, rate was changed */
                rate = snd_ak4114_external_rate(ak4114);
-               /* printk(KERN_DEBUG "ak4114 - input rate changed to %d\n",
+               /* dev_dbg(ice->card->dev, "ak4114 - input rate changed to %d\n",
                                rate); */
                juli_akm_set_rate_val(ice->akm, rate);
        }
@@ -628,7 +628,7 @@ static int juli_init(struct snd_ice1712 *ice)
 #endif
 
        if (spec->analog) {
-               printk(KERN_INFO "juli@: analog I/O detected\n");
+               dev_info(ice->card->dev, "juli@: analog I/O detected\n");
                ice->num_total_dacs = 2;
                ice->num_total_adcs = 2;
 
index e610339f7601416c972364192011e4f176819727..f3b491aa3e223ce8fc8825e921ebe9e49067afac 100644 (file)
@@ -98,7 +98,7 @@ static int stac9460_dac_mute(struct snd_ice1712 *ice, int idx,
        new = (~mute << 7 & 0x80) | (old & ~0x80);
        change = (new != old);
        if (change)
-               /*printk ("Volume register 0x%02x: 0x%02x\n", idx, new);*/
+               /* dev_dbg(ice->card->dev, "Volume register 0x%02x: 0x%02x\n", idx, new);*/
                stac9460_put(ice, idx, new);
        return change;
 }
@@ -133,7 +133,7 @@ static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
        /* due to possible conflicts with stac9460_set_rate_val, mutexing */
        mutex_lock(&spec->mute_mutex);
        /*
-       printk(KERN_DEBUG "Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx,
+       dev_dbg(ice->card->dev, "Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx,
               ucontrol->value.integer.value[0]);
        */
        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
        if (change) {
                ovol =  (0x7f - nvol) | (tmp & 0x80);
                /*
-               printk(KERN_DEBUG "DAC Volume: reg 0x%02x: 0x%02x\n",
+               dev_dbg(ice->card->dev, "DAC Volume: reg 0x%02x: 0x%02x\n",
                       idx, ovol);
                */
                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)
        for (idx = 0; idx < 7 ; ++idx)
                changed[idx] = stac9460_dac_mute(ice,
                                STAC946X_MASTER_VOLUME + idx, 0);
-       /*printk(KERN_DEBUG "Rate change: %d, new MC: 0x%02x\n", rate, new);*/
+       /*dev_dbg(ice->card->dev, "Rate change: %d, new MC: 0x%02x\n", rate, new);*/
        stac9460_put(ice, STAC946X_MASTER_CLOCKING, new);
        udelay(10);
        /* unmuting - only originally unmuted dacs -
@@ -768,9 +768,10 @@ static int prodigy192_init(struct snd_ice1712 *ice)
                /* from this moment if err = 0 then
                 * spec->ak4114 should not be null
                 */
-               snd_printdd("AK4114 initialized with status %d\n", err);
+               dev_dbg(ice->card->dev,
+                       "AK4114 initialized with status %d\n", err);
        } else
-               snd_printdd("AK4114 not found\n");
+               dev_dbg(ice->card->dev, "AK4114 not found\n");
        if (err < 0)
                return err;
 
index 71c6003ef338a04d5c400b3c0c300d58cf4ddede..2c2df4b74e01420966853324fbeebae6c66b53fa 100644 (file)
@@ -280,7 +280,7 @@ static void qtet_akm_write(struct snd_akm4xxx *ak, int chip,
 
        if (snd_BUG_ON(chip < 0 || chip >= 4))
                return;
-       /*printk(KERN_DEBUG "Writing to AK4620: chip=%d, addr=0x%x,
+       /*dev_dbg(ice->card->dev, "Writing to AK4620: chip=%d, addr=0x%x,
          data=0x%x\n", chip, addr, data);*/
        orig_dir = ice->gpio.get_dir(ice);
        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)
        new =  (get_cpld(ice) & ~CPLD_CKS_MASK) | get_cks_val(rate);
        /* switch to internal clock, drop CPLD_SYNC_SEL */
        new &= ~CPLD_SYNC_SEL;
-       /* printk(KERN_DEBUG "QT - set_rate: old %x, new %x\n",
+       /* dev_dbg(ice->card->dev, "QT - set_rate: old %x, new %x\n",
           get_cpld(ice), new); */
        set_cpld(ice, new);
 }
@@ -978,7 +978,7 @@ static void qtet_ak4113_change(struct ak4113 *ak4113, unsigned char c0,
                        c1) {
                /* only for SPDIF master mode, rate was changed */
                rate = snd_ak4113_external_rate(ak4113);
-               /* printk(KERN_DEBUG "ak4113 - input rate changed to %d\n",
+               /* dev_dbg(ice->card->dev, "ak4113 - input rate changed to %d\n",
                   rate); */
                qtet_akm_set_rate_val(ice->akm, rate);
        }
index 08d8733604a2ed981d1c5ac32e095c452e56a431..68340d7df76d14cc85bfa534127c60c20db3fada 100644 (file)
@@ -547,7 +547,8 @@ static int snd_intel8x0_codec_semaphore(struct intel8x0 *chip, unsigned int code
        /* access to some forbidden (non existent) ac97 registers will not
         * reset the semaphore. So even if you don't get the semaphore, still
         * continue the access. We don't need the semaphore anyway. */
-       snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
+       dev_err(chip->card->dev,
+               "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
                        igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
        iagetword(chip, 0);     /* clear semaphore flag */
        /* I don't care about the semaphore */
@@ -562,7 +563,9 @@ static void snd_intel8x0_codec_write(struct snd_ac97 *ac97,
        
        if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
                if (! chip->in_ac97_init)
-                       snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
+                       dev_err(chip->card->dev,
+                               "codec_write %d: semaphore is not ready for register 0x%x\n",
+                               ac97->num, reg);
        }
        iaputword(chip, reg + ac97->num * 0x80, val);
 }
@@ -576,7 +579,9 @@ static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97,
 
        if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
                if (! chip->in_ac97_init)
-                       snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
+                       dev_err(chip->card->dev,
+                               "codec_read %d: semaphore is not ready for register 0x%x\n",
+                               ac97->num, reg);
                res = 0xffff;
        } else {
                res = iagetword(chip, reg + ac97->num * 0x80);
@@ -585,7 +590,9 @@ static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97,
                        iputdword(chip, ICHREG(GLOB_STA), tmp &
                                  ~(chip->codec_ready_bits | ICH_GSCI));
                        if (! chip->in_ac97_init)
-                               snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg);
+                               dev_err(chip->card->dev,
+                                       "codec_read %d: read timeout for register 0x%x\n",
+                                       ac97->num, reg);
                        res = 0xffff;
                }
        }
@@ -619,7 +626,7 @@ static int snd_intel8x0_ali_codec_ready(struct intel8x0 *chip, int mask)
                        return 0;
        }
        if (! chip->in_ac97_init)
-               snd_printd(KERN_WARNING "intel8x0: AC97 codec ready timeout.\n");
+               dev_warn(chip->card->dev, "AC97 codec ready timeout.\n");
        return -EBUSY;
 }
 
@@ -631,7 +638,7 @@ static int snd_intel8x0_ali_codec_semaphore(struct intel8x0 *chip)
        while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
                udelay(1);
        if (! time && ! chip->in_ac97_init)
-               snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n");
+               dev_warn(chip->card->dev, "ali_codec_semaphore timeout\n");
        return snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_CODEC_READY);
 }
 
@@ -700,7 +707,7 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
                        bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
                                                     ichdev->fragsize >> ichdev->pos_shift);
 #if 0
-                       printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
+                       dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
                               idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
 #endif
                }
@@ -712,8 +719,8 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
        ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
        ichdev->position = 0;
 #if 0
-       printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
-              "period_size1 = 0x%x\n",
+       dev_dbg(chip->card->dev,
+               "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
               ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
               ichdev->fragsize1);
 #endif
@@ -781,8 +788,8 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
                ichdev->lvi_frag %= ichdev->frags;
                ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
 #if 0
-       printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, "
-              "all = 0x%x, 0x%x\n",
+       dev_dbg(chip->card->dev,
+               "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
               ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
               ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
               inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@ -2289,7 +2296,8 @@ static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
                ac97.num = i;
                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
                        if (err != -EACCES)
-                               snd_printk(KERN_ERR "Unable to initialize codec #%d\n", i);
+                               dev_err(chip->card->dev,
+                                       "Unable to initialize codec #%d\n", i);
                        if (i == 0)
                                goto __err;
                }
@@ -2441,7 +2449,7 @@ static int snd_intel8x0_ich_chip_reset(struct intel8x0 *chip)
                        return 0;
                schedule_timeout_uninterruptible(1);
        } while (time_after_eq(end_time, jiffies));
-       snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n",
+       dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
                   igetdword(chip, ICHREG(GLOB_CNT)));
        return -EIO;
 }
@@ -2483,7 +2491,8 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
                } while (time_after_eq(end_time, jiffies));
                if (! status) {
                        /* no codec is found */
-                       snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n",
+                       dev_err(chip->card->dev,
+                               "codec_ready: codec is not ready [0x%x]\n",
                                   igetdword(chip, ICHREG(GLOB_STA)));
                        return -EIO;
                }
@@ -2547,7 +2556,7 @@ static int snd_intel8x0_ali_chip_init(struct intel8x0 *chip, int probing)
                        goto __ok;
                schedule_timeout_uninterruptible(1);
        }
-       snd_printk(KERN_ERR "AC'97 reset failed.\n");
+       dev_err(chip->card->dev, "AC'97 reset failed.\n");
        if (probing)
                return -EIO;
 
@@ -2591,7 +2600,7 @@ static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing)
                                break;
                 }
                 if (timeout == 0)
-                        printk(KERN_ERR "intel8x0: reset of registers failed?\n");
+                       dev_err(chip->card->dev, "reset of registers failed?\n");
         }
        /* initialize Buffer Descriptor Lists */
        for (i = 0; i < chip->bdbars_count; i++)
@@ -2692,8 +2701,7 @@ static int intel8x0_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "intel8x0: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2701,8 +2709,8 @@ static int intel8x0_resume(struct device *dev)
        snd_intel8x0_chip_init(chip, 0);
        if (request_irq(pci->irq, snd_intel8x0_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
-                      "disabling device\n", pci->irq);
+               dev_err(dev, "unable to grab IRQ %d, disabling device\n",
+                       pci->irq);
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2779,7 +2787,8 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
       __again:
        subs = chip->pcm[0]->streams[0].substream;
        if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) {
-               snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n");
+               dev_warn(chip->card->dev,
+                        "no playback buffer allocated - aborting measure ac97 clock\n");
                return;
        }
        ichdev = &chip->ichd[ICHD_PCMOUT];
@@ -2789,7 +2798,8 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
 
        /* set rate */
        if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) {
-               snd_printk(KERN_ERR "cannot set ac97 rate: clock = %d\n", chip->ac97_bus->clock);
+               dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n",
+                       chip->ac97_bus->clock);
                return;
        }
        snd_intel8x0_setup_periods(chip, ichdev);
@@ -2843,7 +2853,8 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
        spin_unlock_irq(&chip->reg_lock);
 
        if (pos == 0) {
-               snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n");
+               dev_err(chip->card->dev,
+                       "measure - unreliable DMA position..\n");
              __retry:
                if (attempt < 3) {
                        msleep(300);
@@ -2857,16 +2868,17 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
        t = stop_time.tv_sec - start_time.tv_sec;
        t *= 1000000;
        t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
-       printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
+       dev_info(chip->card->dev,
+                "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
        if (t == 0) {
-               snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n");
+               dev_err(chip->card->dev, "?? calculation error..\n");
                goto __retry;
        }
        pos *= 1000;
        pos = (pos / t) * 1000 + ((pos % t) * 1000) / t;
        if (pos < 40000 || pos >= 60000) {
                /* abnormal value. hw problem? */
-               printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos);
+               dev_info(chip->card->dev, "measured clock %ld rejected\n", pos);
                goto __retry;
        } else if (pos > 40500 && pos < 41500)
                /* first exception - 41000Hz reference clock */
@@ -2878,7 +2890,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
                /* not 48000Hz, tuning the clock.. */
                chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
       __end:
-       printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock);
+       dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock);
        snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
 }
 
@@ -2899,7 +2911,7 @@ static int intel8x0_in_clock_list(struct intel8x0 *chip)
        wl = snd_pci_quirk_lookup(pci, intel8x0_clock_list);
        if (!wl)
                return 0;
-       printk(KERN_INFO "intel8x0: white list rate for %04x:%04x is %i\n",
+       dev_info(chip->card->dev, "white list rate for %04x:%04x is %i\n",
               pci->subsystem_vendor, pci->subsystem_device, wl->value);
        chip->ac97_bus->clock = wl->value;
        return 1;
@@ -3003,7 +3015,7 @@ static int snd_intel8x0_inside_vm(struct pci_dev *pci)
 
 fini:
        if (msg != NULL)
-               printk(KERN_INFO "intel8x0: %s optimization\n", msg);
+               dev_info(&pci->dev, "%s optimization\n", msg);
 
        return result;
 }
@@ -3098,7 +3110,7 @@ static int snd_intel8x0_create(struct snd_card *card,
        else
                chip->addr = pci_iomap(pci, 0, 0);
        if (!chip->addr) {
-               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               dev_err(card->dev, "AC'97 space ioremap problem\n");
                snd_intel8x0_free(chip);
                return -EIO;
        }
@@ -3107,7 +3119,7 @@ static int snd_intel8x0_create(struct snd_card *card,
        else
                chip->bmaddr = pci_iomap(pci, 1, 0);
        if (!chip->bmaddr) {
-               snd_printk(KERN_ERR "Controller space ioremap problem\n");
+               dev_err(card->dev, "Controller space ioremap problem\n");
                snd_intel8x0_free(chip);
                return -EIO;
        }
@@ -3152,7 +3164,7 @@ static int snd_intel8x0_create(struct snd_card *card,
                                chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2,
                                &chip->bdbars) < 0) {
                snd_intel8x0_free(chip);
-               snd_printk(KERN_ERR "intel8x0: cannot allocate buffer descriptors\n");
+               dev_err(card->dev, "cannot allocate buffer descriptors\n");
                return -ENOMEM;
        }
        /* 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,
        /* request irq after initializaing int_sta_mask, etc */
        if (request_irq(pci->irq, snd_intel8x0_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_intel8x0_free(chip);
                return -EBUSY;
        }
@@ -3217,8 +3229,6 @@ static int snd_intel8x0_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_intel8x0 = chip;
        return 0;
 }
@@ -3265,12 +3275,12 @@ static int check_default_spdif_aclink(struct pci_dev *pci)
        w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults);
        if (w) {
                if (w->value)
-                       snd_printdd(KERN_INFO
-                                   "intel8x0: Using SPDIF over AC-Link for %s\n",
+                       dev_dbg(&pci->dev,
+                               "Using SPDIF over AC-Link for %s\n",
                                    snd_pci_quirk_name(w));
                else
-                       snd_printdd(KERN_INFO
-                                   "intel8x0: Using integrated SPDIF DMA for %s\n",
+                       dev_dbg(&pci->dev,
+                               "Using integrated SPDIF DMA for %s\n",
                                    snd_pci_quirk_name(w));
                return w->value;
        }
@@ -3285,7 +3295,7 @@ static int snd_intel8x0_probe(struct pci_dev *pci,
        int err;
        struct shortname_table *name;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index 3573c11936656d8f1b003573d559494618c7a694..b54d3e93cab13bfe516ecbf5de6c72113df328a4 100644 (file)
@@ -334,7 +334,8 @@ static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int co
        /* access to some forbidden (non existent) ac97 registers will not
         * reset the semaphore. So even if you don't get the semaphore, still
         * continue the access. We don't need the semaphore anyway. */
-       snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
+       dev_err(chip->card->dev,
+               "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
                        igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
        iagetword(chip, 0);     /* clear semaphore flag */
        /* I don't care about the semaphore */
@@ -349,7 +350,9 @@ static void snd_intel8x0m_codec_write(struct snd_ac97 *ac97,
        
        if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
                if (! chip->in_ac97_init)
-                       snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
+                       dev_err(chip->card->dev,
+                               "codec_write %d: semaphore is not ready for register 0x%x\n",
+                               ac97->num, reg);
        }
        iaputword(chip, reg + ac97->num * 0x80, val);
 }
@@ -363,7 +366,9 @@ static unsigned short snd_intel8x0m_codec_read(struct snd_ac97 *ac97,
 
        if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
                if (! chip->in_ac97_init)
-                       snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
+                       dev_err(chip->card->dev,
+                               "codec_read %d: semaphore is not ready for register 0x%x\n",
+                               ac97->num, reg);
                res = 0xffff;
        } else {
                res = iagetword(chip, reg + ac97->num * 0x80);
@@ -372,7 +377,9 @@ static unsigned short snd_intel8x0m_codec_read(struct snd_ac97 *ac97,
                        iputdword(chip, ICHREG(GLOB_STA),
                                  tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
                        if (! chip->in_ac97_init)
-                               snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg);
+                               dev_err(chip->card->dev,
+                                       "codec_read %d: read timeout for register 0x%x\n",
+                                       ac97->num, reg);
                        res = 0xffff;
                }
        }
@@ -412,7 +419,7 @@ static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *i
                        bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
                                                     ichdev->fragsize >> chip->pcm_pos_shift);
                        /*
-                       printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
+                       dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
                               idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
                        */
                }
@@ -424,8 +431,8 @@ static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *i
        ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
        ichdev->position = 0;
 #if 0
-       printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
-              "period_size1 = 0x%x\n",
+       dev_dbg(chip->card->dev,
+               "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
               ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
               ichdev->fragsize1);
 #endif
@@ -470,8 +477,8 @@ static inline void snd_intel8x0m_update(struct intel8x0m *chip, struct ichdev *i
                                                             ichdev->lvi_frag *
                                                             ichdev->fragsize1);
 #if 0
-               printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], "
-                      "prefetch = %i, all = 0x%x, 0x%x\n",
+               dev_dbg(chip->card->dev,
+                       "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
                       ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
                       ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
                       inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@ -850,7 +857,8 @@ static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock)
        ac97.pci = chip->pci;
        ac97.num = glob_sta & ICH_SCR ? 1 : 0;
        if ((err = snd_ac97_mixer(pbus, &ac97, &x97)) < 0) {
-               snd_printk(KERN_ERR "Unable to initialize codec #%d\n", ac97.num);
+               dev_err(chip->card->dev,
+                       "Unable to initialize codec #%d\n", ac97.num);
                if (ac97.num == 0)
                        goto __err;
                return err;
@@ -901,7 +909,7 @@ static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
                        goto __ok;
                schedule_timeout_uninterruptible(1);
        } while (time_after_eq(end_time, jiffies));
-       snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n",
+       dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
                   igetdword(chip, ICHREG(GLOB_CNT)));
        return -EIO;
 
@@ -921,7 +929,8 @@ static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
                } while (time_after_eq(end_time, jiffies));
                if (! status) {
                        /* no codec is found */
-                       snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n",
+                       dev_err(chip->card->dev,
+                               "codec_ready: codec is not ready [0x%x]\n",
                                   igetdword(chip, ICHREG(GLOB_STA)));
                        return -EIO;
                }
@@ -1042,16 +1051,15 @@ static int intel8x0m_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "intel8x0m: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
        pci_set_master(pci);
        if (request_irq(pci->irq, snd_intel8x0m_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR "intel8x0m: unable to grab IRQ %d, "
-                      "disabling device\n", pci->irq);
+               dev_err(dev, "unable to grab IRQ %d, disabling device\n",
+                       pci->irq);
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -1165,7 +1173,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
        else
                chip->addr = pci_iomap(pci, 0, 0);
        if (!chip->addr) {
-               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               dev_err(card->dev, "AC'97 space ioremap problem\n");
                snd_intel8x0m_free(chip);
                return -EIO;
        }
@@ -1174,7 +1182,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
        else
                chip->bmaddr = pci_iomap(pci, 1, 0);
        if (!chip->bmaddr) {
-               snd_printk(KERN_ERR "Controller space ioremap problem\n");
+               dev_err(card->dev, "Controller space ioremap problem\n");
                snd_intel8x0m_free(chip);
                return -EIO;
        }
@@ -1182,7 +1190,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
  port_inited:
        if (request_irq(pci->irq, snd_intel8x0m_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_intel8x0m_free(chip);
                return -EBUSY;
        }
@@ -1243,8 +1251,6 @@ static int snd_intel8x0m_create(struct snd_card *card,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_intel8x0m = chip;
        return 0;
 }
@@ -1283,7 +1289,7 @@ static int snd_intel8x0m_probe(struct pci_dev *pci,
        int err;
        struct shortname_table *name;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index 9cf9829555d422a250cff10dd956b23e09dca996..8f36d77f01e5573620c6660d9e8a6b0d3d4810b0 100644 (file)
@@ -2418,8 +2418,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         snd_korg1212_proc_init(korg1212);
         
-       snd_card_set_dev(card, &pci->dev);
-
         * rchip = korg1212;
        return 0;
 
@@ -2445,7 +2443,8 @@ snd_korg1212_probe(struct pci_dev *pci,
                dev++;
                return -ENOENT;
        }
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
index 0568540dc8d353995879ba6ab26be56360b164e4..68824cdd137de7bcfc8c80397c59f558970e070b 100644 (file)
@@ -75,7 +75,7 @@ MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 static int debug;
 module_param(debug, int, 0644);
 #define verbose_debug(fmt, args...)                    \
-       do { if (debug > 1) printk(KERN_DEBUG SFX fmt, ##args); } while (0)
+       do { if (debug > 1) pr_debug(SFX fmt, ##args); } while (0)
 #else
 #define verbose_debug(fmt, args...)
 #endif
@@ -168,7 +168,7 @@ static int rirb_get_response(struct lola *chip, unsigned int *val,
                        verbose_debug("get_response: %x, %x\n",
                                      chip->res, chip->res_ex);
                        if (chip->res_ex & LOLA_RIRB_EX_ERROR) {
-                               printk(KERN_WARNING SFX "RIRB ERROR: "
+                               dev_warn(chip->card->dev, "RIRB ERROR: "
                                       "NID=%x, verb=%x, data=%x, ext=%x\n",
                                       chip->last_cmd_nid,
                                       chip->last_verb, chip->last_data,
@@ -182,9 +182,9 @@ static int rirb_get_response(struct lola *chip, unsigned int *val,
                udelay(20);
                cond_resched();
        }
-       printk(KERN_WARNING SFX "RIRB response error\n");
+       dev_warn(chip->card->dev, "RIRB response error\n");
        if (!chip->polling_mode) {
-               printk(KERN_WARNING SFX "switching to polling mode\n");
+               dev_warn(chip->card->dev, "switching to polling mode\n");
                chip->polling_mode = 1;
                goto again;
        }
@@ -327,7 +327,7 @@ static int reset_controller(struct lola *chip)
                        break;
        } while (time_before(jiffies, end_time));
        if (!gctl) {
-               printk(KERN_ERR SFX "cannot reset controller\n");
+               dev_err(chip->card->dev, "cannot reset controller\n");
                return -EIO;
        }
        return 0;
@@ -452,40 +452,40 @@ static int lola_parse_tree(struct lola *chip)
 
        err = lola_read_param(chip, 0, LOLA_PAR_VENDOR_ID, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read VENDOR_ID\n");
+               dev_err(chip->card->dev, "Can't read VENDOR_ID\n");
                return err;
        }
        val >>= 16;
        if (val != 0x1369) {
-               printk(KERN_ERR SFX "Unknown codec vendor 0x%x\n", val);
+               dev_err(chip->card->dev, "Unknown codec vendor 0x%x\n", val);
                return -EINVAL;
        }
 
        err = lola_read_param(chip, 1, LOLA_PAR_FUNCTION_TYPE, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read FUNCTION_TYPE\n");
+               dev_err(chip->card->dev, "Can't read FUNCTION_TYPE\n");
                return err;
        }
        if (val != 1) {
-               printk(KERN_ERR SFX "Unknown function type %d\n", val);
+               dev_err(chip->card->dev, "Unknown function type %d\n", val);
                return -EINVAL;
        }
 
        err = lola_read_param(chip, 1, LOLA_PAR_SPECIFIC_CAPS, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read SPECCAPS\n");
+               dev_err(chip->card->dev, "Can't read SPECCAPS\n");
                return err;
        }
        chip->lola_caps = val;
        chip->pin[CAPT].num_pins = LOLA_AFG_INPUT_PIN_COUNT(chip->lola_caps);
        chip->pin[PLAY].num_pins = LOLA_AFG_OUTPUT_PIN_COUNT(chip->lola_caps);
-       snd_printdd(SFX "speccaps=0x%x, pins in=%d, out=%d\n",
+       dev_dbg(chip->card->dev, "speccaps=0x%x, pins in=%d, out=%d\n",
                    chip->lola_caps,
                    chip->pin[CAPT].num_pins, chip->pin[PLAY].num_pins);
 
        if (chip->pin[CAPT].num_pins > MAX_AUDIO_INOUT_COUNT ||
            chip->pin[PLAY].num_pins > MAX_AUDIO_INOUT_COUNT) {
-               printk(KERN_ERR SFX "Invalid Lola-spec caps 0x%x\n", val);
+               dev_err(chip->card->dev, "Invalid Lola-spec caps 0x%x\n", val);
                return -EINVAL;
        }
 
@@ -586,7 +586,6 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
 
        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (!chip) {
-               snd_printk(KERN_ERR SFX "cannot allocate chip\n");
                pci_disable_device(pci);
                return -ENOMEM;
        }
@@ -609,7 +608,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
                chip->sample_rate_max = 192000;
                break;
        default:
-               snd_printk(KERN_WARNING SFX
+               dev_warn(chip->card->dev,
                           "Invalid granularity %d, reset to %d\n",
                           chip->granularity, LOLA_GRANULARITY_MAX);
                chip->granularity = LOLA_GRANULARITY_MAX;
@@ -618,7 +617,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
        }
        chip->sample_rate_min = sample_rate_min[dev];
        if (chip->sample_rate_min > chip->sample_rate_max) {
-               snd_printk(KERN_WARNING SFX
+               dev_warn(chip->card->dev,
                           "Invalid sample_rate_min %d, reset to 16000\n",
                           chip->sample_rate_min);
                chip->sample_rate_min = 16000;
@@ -636,7 +635,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
        chip->bar[1].addr = pci_resource_start(pci, 2);
        chip->bar[1].remap_addr = pci_ioremap_bar(pci, 2);
        if (!chip->bar[0].remap_addr || !chip->bar[1].remap_addr) {
-               snd_printk(KERN_ERR SFX "ioremap error\n");
+               dev_err(chip->card->dev, "ioremap error\n");
                err = -ENXIO;
                goto errout;
        }
@@ -649,7 +648,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
 
        if (request_irq(pci->irq, lola_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               printk(KERN_ERR SFX "unable to grab IRQ %d\n", pci->irq);
+               dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
                err = -EBUSY;
                goto errout;
        }
@@ -660,7 +659,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
        chip->pcm[CAPT].num_streams = (dever >> 0) & 0x3ff;
        chip->pcm[PLAY].num_streams = (dever >> 10) & 0x3ff;
        chip->version = (dever >> 24) & 0xff;
-       snd_printdd(SFX "streams in=%d, out=%d, version=0x%x\n",
+       dev_dbg(chip->card->dev, "streams in=%d, out=%d, version=0x%x\n",
                    chip->pcm[CAPT].num_streams, chip->pcm[PLAY].num_streams,
                    chip->version);
 
@@ -669,7 +668,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
            chip->pcm[PLAY].num_streams > MAX_STREAM_OUT_COUNT ||
            (!chip->pcm[CAPT].num_streams &&
             !chip->pcm[PLAY].num_streams)) {
-               printk(KERN_ERR SFX "invalid DEVER = %x\n", dever);
+               dev_err(chip->card->dev, "invalid DEVER = %x\n", dever);
                err = -EINVAL;
                goto errout;
        }
@@ -680,7 +679,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
 
        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
        if (err < 0) {
-               snd_printk(KERN_ERR SFX "Error creating device [card]!\n");
+               dev_err(chip->card->dev, "Error creating device [card]!\n");
                goto errout;
        }
 
@@ -717,14 +716,13 @@ static int lola_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
-               snd_printk(KERN_ERR SFX "Error creating card!\n");
+               dev_err(card->dev, "Error creating card!\n");
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        err = lola_create(card, pci, dev, &chip);
        if (err < 0)
                goto out_free;
index eb1d6b97df164f20517222be0173df1e792dce1b..2bef6b412aeee42081d6c33ee827b62fffb6c64c 100644 (file)
@@ -128,21 +128,21 @@ int lola_init_clock_widget(struct lola *chip, int nid)
 
        err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
                return err;
        }
 
        if ((val & 0xfff00000) != 0x01f00000) { /* test SubType and Type */
-               snd_printdd("No valid clock widget\n");
+               dev_dbg(chip->card->dev, "No valid clock widget\n");
                return 0;
        }
 
        chip->clock.nid = nid;
        chip->clock.items = val & 0xff;
-       snd_printdd("clock_list nid=%x, entries=%d\n", nid,
+       dev_dbg(chip->card->dev, "clock_list nid=%x, entries=%d\n", nid,
                    chip->clock.items);
        if (chip->clock.items > MAX_SAMPLE_CLOCK_COUNT) {
-               printk(KERN_ERR SFX "CLOCK_LIST too big: %d\n",
+               dev_err(chip->card->dev, "CLOCK_LIST too big: %d\n",
                       chip->clock.items);
                return -EINVAL;
        }
@@ -158,7 +158,7 @@ int lola_init_clock_widget(struct lola *chip, int nid)
                err = lola_codec_read(chip, nid, LOLA_VERB_GET_CLOCK_LIST,
                                      idx, 0, &val, &res_ex);
                if (err < 0) {
-                       printk(KERN_ERR SFX "Can't read CLOCK_LIST\n");
+                       dev_err(chip->card->dev, "Can't read CLOCK_LIST\n");
                        return -EINVAL;
                }
 
@@ -223,7 +223,7 @@ int lola_enable_clock_events(struct lola *chip)
        if (err < 0)
                return err;
        if (res) {
-               printk(KERN_WARNING SFX "error in enable_clock_events %d\n",
+               dev_warn(chip->card->dev, "error in enable_clock_events %d\n",
                       res);
                return -EINVAL;
        }
@@ -242,7 +242,7 @@ int lola_set_clock_index(struct lola *chip, unsigned int idx)
        if (err < 0)
                return err;
        if (res) {
-               printk(KERN_WARNING SFX "error in set_clock %d\n", res);
+               dev_warn(chip->card->dev, "error in set_clock %d\n", res);
                return -EINVAL;
        }
        return 0;
index 52c8d6b0f39b9c7b35183f89642a816d8cdd7e58..782f4d8299ae85bd76b52a0b05679ad6add4b75c 100644 (file)
@@ -37,7 +37,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
        pin->nid = nid;
        err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
                return err;
        }
        val &= 0x00f00fff; /* test TYPE and bits 0..11 */
@@ -48,7 +48,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
        else if (val == 0x0040000c && dir == PLAY) /* Dig=0, OutAmp/ovrd */
                pin->is_analog = true;
        else {
-               printk(KERN_ERR SFX "Invalid wcaps 0x%x for 0x%x\n", val, nid);
+               dev_err(chip->card->dev, "Invalid wcaps 0x%x for 0x%x\n", val, nid);
                return -EINVAL;
        }
 
@@ -62,7 +62,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
        else
                err = lola_read_param(chip, nid, LOLA_PAR_AMP_IN_CAP, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read AMP-caps for 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't read AMP-caps for 0x%x\n", nid);
                return err;
        }
 
@@ -79,7 +79,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
        err = lola_codec_read(chip, nid, LOLA_VERB_GET_MAX_LEVEL, 0, 0, &val,
                              NULL);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't get MAX_LEVEL 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't get MAX_LEVEL 0x%x\n", nid);
                return err;
        }
        pin->max_level = val & 0x3ff;   /* 10 bits */
@@ -119,12 +119,12 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
 
        err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
                return err;
        }
 
        if ((val & 0xfff00000) != 0x02f00000) { /* test SubType and Type */
-               snd_printdd("No valid mixer widget\n");
+               dev_dbg(chip->card->dev, "No valid mixer widget\n");
                return 0;
        }
 
@@ -202,7 +202,7 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
         */
        if (chip->mixer.src_stream_out_ofs > MAX_AUDIO_INOUT_COUNT ||
            chip->mixer.dest_phys_out_ofs > MAX_STREAM_IN_COUNT) {
-               printk(KERN_ERR SFX "Invalid mixer widget size\n");
+               dev_err(chip->card->dev, "Invalid mixer widget size\n");
                return -EINVAL;
        }
 
@@ -213,7 +213,7 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
                (((1U << chip->mixer.dest_phys_outs) - 1)
                 << chip->mixer.dest_phys_out_ofs);
 
-       snd_printdd("Mixer src_mask=%x, dest_mask=%x\n",
+       dev_dbg(chip->card->dev, "Mixer src_mask=%x, dest_mask=%x\n",
                    chip->mixer.src_mask, chip->mixer.dest_mask);
 
        return 0;
@@ -236,7 +236,8 @@ static int lola_mixer_set_src_gain(struct lola *chip, unsigned int id,
            (gain == readw(&chip->mixer.array->src_gain[id])))
                return 0;
 
-       snd_printdd("lola_mixer_set_src_gain (id=%d, gain=%d) enable=%x\n",
+       dev_dbg(chip->card->dev,
+               "lola_mixer_set_src_gain (id=%d, gain=%d) enable=%x\n",
                        id, gain, val);
        writew(gain, &chip->mixer.array->src_gain[id]);
        writel(val, &chip->mixer.array->src_gain_enable);
@@ -409,7 +410,8 @@ static int set_analog_volume(struct lola *chip, int dir,
                return 0;
        if (external_call)
                lola_codec_flush(chip);
-       snd_printdd("set_analog_volume (dir=%d idx=%d, volume=%d)\n",
+       dev_dbg(chip->card->dev,
+               "set_analog_volume (dir=%d idx=%d, volume=%d)\n",
                        dir, idx, val);
        err = lola_codec_write(chip, pin->nid,
                               LOLA_VERB_SET_AMP_GAIN_MUTE, val, 0);
index 5ea85e8b83ab5018029d92504902775170adb018..3bd6985430e824b72e2fd71432ff13afd864a000 100644 (file)
@@ -103,7 +103,7 @@ static void wait_for_srst_clear(struct lola *chip, struct lola_stream *str)
                        return;
                msleep(1);
        }
-       printk(KERN_WARNING SFX "SRST not clear (stream %d)\n", str->dsd);
+       dev_warn(chip->card->dev, "SRST not clear (stream %d)\n", str->dsd);
 }
 
 static int lola_stream_wait_for_fifo(struct lola *chip,
@@ -118,7 +118,7 @@ static int lola_stream_wait_for_fifo(struct lola *chip,
                        return 0;
                msleep(1);
        }
-       printk(KERN_WARNING SFX "FIFO not ready (stream %d)\n", str->dsd);
+       dev_warn(chip->card->dev, "FIFO not ready (stream %d)\n", str->dsd);
        return -EIO;
 }
 
@@ -156,7 +156,7 @@ static int lola_sync_wait_for_fifo(struct lola *chip,
                        return 0;
                msleep(1);
        }
-       printk(KERN_WARNING SFX "FIFO not ready (pending %d)\n", pending - 1);
+       dev_warn(chip->card->dev, "FIFO not ready (pending %d)\n", pending - 1);
        return -EIO;
 }
 
@@ -373,7 +373,7 @@ static int lola_setup_periods(struct lola *chip, struct lola_pcm *pcm,
        return 0;
 
  error:
-       snd_printk(KERN_ERR SFX "Too many BDL entries: buffer=%d, period=%d\n",
+       dev_err(chip->card->dev, "Too many BDL entries: buffer=%d, period=%d\n",
                   str->bufsize, period_bytes);
        return -EINVAL;
 }
@@ -415,7 +415,7 @@ static int lola_set_stream_config(struct lola *chip,
        err = lola_codec_read(chip, str->nid, LOLA_VERB_SET_STREAM_FORMAT,
                              str->format_verb, 0, &val, NULL);
        if (err < 0) {
-               printk(KERN_ERR SFX "Cannot set stream format 0x%x\n",
+               dev_err(chip->card->dev, "Cannot set stream format 0x%x\n",
                       str->format_verb);
                return err;
        }
@@ -427,7 +427,8 @@ static int lola_set_stream_config(struct lola *chip,
                                      LOLA_VERB_SET_CHANNEL_STREAMID, 0, verb,
                                      &val, NULL);
                if (err < 0) {
-                       printk(KERN_ERR SFX "Cannot set stream channel %d\n", i);
+                       dev_err(chip->card->dev,
+                               "Cannot set stream channel %d\n", i);
                        return err;
                }
        }
@@ -651,13 +652,14 @@ static int lola_init_stream(struct lola *chip, struct lola_stream *str,
                str->dsd += MAX_STREAM_IN_COUNT;
        err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
                return err;
        }
        if (dir == PLAY) {
                /* test TYPE and bits 0..11 (no test bit9 : Digital = 0/1) */
                if ((val & 0x00f00dff) != 0x00000010) {
-                       printk(KERN_ERR SFX "Invalid wcaps 0x%x for 0x%x\n",
+                       dev_err(chip->card->dev,
+                               "Invalid wcaps 0x%x for 0x%x\n",
                               val, nid);
                        return -EINVAL;
                }
@@ -666,7 +668,8 @@ static int lola_init_stream(struct lola *chip, struct lola_stream *str,
                 * (bug : ignore bit8: Conn list = 0/1)
                 */
                if ((val & 0x00f00cff) != 0x00100010) {
-                       printk(KERN_ERR SFX "Invalid wcaps 0x%x for 0x%x\n",
+                       dev_err(chip->card->dev,
+                               "Invalid wcaps 0x%x for 0x%x\n",
                               val, nid);
                        return -EINVAL;
                }
@@ -677,14 +680,15 @@ static int lola_init_stream(struct lola *chip, struct lola_stream *str,
 
        err = lola_read_param(chip, nid, LOLA_PAR_STREAM_FORMATS, &val);
        if (err < 0) {
-               printk(KERN_ERR SFX "Can't read FORMATS 0x%x\n", nid);
+               dev_err(chip->card->dev, "Can't read FORMATS 0x%x\n", nid);
                return err;
        }
        val &= 3;
        if (val == 3)
                str->can_float = true;
        if (!(val & 1)) {
-               printk(KERN_ERR SFX "Invalid formats 0x%x for 0x%x", val, nid);
+               dev_err(chip->card->dev,
+                       "Invalid formats 0x%x for 0x%x", val, nid);
                return -EINVAL;
        }
        return 0;
index 5fcaaa6da4a811b1bc1ae3e4a6fe431b90b378de..27f60ce8a55c41b5275aeeb014958838800ee21b 100644 (file)
@@ -112,16 +112,16 @@ static int lx_hardware_open(struct lx6464es *chip,
 
        snd_pcm_uframes_t period_size = runtime->period_size;
 
-       snd_printd(LXP "allocating pipe for %d channels\n", channels);
+       dev_dbg(chip->card->dev, "allocating pipe for %d channels\n", channels);
        err = lx_pipe_allocate(chip, 0, is_capture, channels);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "allocating pipe failed\n");
+               dev_err(chip->card->dev, LXP "allocating pipe failed\n");
                return err;
        }
 
        err = lx_set_granularity(chip, period_size);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "setting granularity to %ld failed\n",
+               dev_err(chip->card->dev, "setting granularity to %ld failed\n",
                           period_size);
                return err;
        }
@@ -136,24 +136,24 @@ static int lx_hardware_start(struct lx6464es *chip,
        struct snd_pcm_runtime *runtime = substream->runtime;
        int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
 
-       snd_printd(LXP "setting stream format\n");
+       dev_dbg(chip->card->dev, "setting stream format\n");
        err = lx_stream_set_format(chip, runtime, 0, is_capture);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "setting stream format failed\n");
+               dev_err(chip->card->dev, "setting stream format failed\n");
                return err;
        }
 
-       snd_printd(LXP "starting pipe\n");
+       dev_dbg(chip->card->dev, "starting pipe\n");
        err = lx_pipe_start(chip, 0, is_capture);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "starting pipe failed\n");
+               dev_err(chip->card->dev, "starting pipe failed\n");
                return err;
        }
 
-       snd_printd(LXP "waiting for pipe to start\n");
+       dev_dbg(chip->card->dev, "waiting for pipe to start\n");
        err = lx_pipe_wait_for_start(chip, 0, is_capture);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "waiting for pipe failed\n");
+               dev_err(chip->card->dev, "waiting for pipe failed\n");
                return err;
        }
 
@@ -167,24 +167,24 @@ static int lx_hardware_stop(struct lx6464es *chip,
        int err = 0;
        int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
 
-       snd_printd(LXP "pausing pipe\n");
+       dev_dbg(chip->card->dev, "pausing pipe\n");
        err = lx_pipe_pause(chip, 0, is_capture);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "pausing pipe failed\n");
+               dev_err(chip->card->dev, "pausing pipe failed\n");
                return err;
        }
 
-       snd_printd(LXP "waiting for pipe to become idle\n");
+       dev_dbg(chip->card->dev, "waiting for pipe to become idle\n");
        err = lx_pipe_wait_for_idle(chip, 0, is_capture);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "waiting for pipe failed\n");
+               dev_err(chip->card->dev, "waiting for pipe failed\n");
                return err;
        }
 
-       snd_printd(LXP "stopping pipe\n");
+       dev_dbg(chip->card->dev, "stopping pipe\n");
        err = lx_pipe_stop(chip, 0, is_capture);
        if (err < 0) {
-               snd_printk(LXP "stopping pipe failed\n");
+               dev_err(chip->card->dev, "stopping pipe failed\n");
                return err;
        }
 
@@ -198,10 +198,10 @@ static int lx_hardware_close(struct lx6464es *chip,
        int err = 0;
        int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
 
-       snd_printd(LXP "releasing pipe\n");
+       dev_dbg(chip->card->dev, "releasing pipe\n");
        err = lx_pipe_release(chip, 0, is_capture);
        if (err < 0) {
-               snd_printk(LXP "releasing pipe failed\n");
+               dev_err(chip->card->dev, "releasing pipe failed\n");
                return err;
        }
 
@@ -216,7 +216,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
        int err = 0;
        int board_rate;
 
-       snd_printdd("->lx_pcm_open\n");
+       dev_dbg(chip->card->dev, "->lx_pcm_open\n");
        mutex_lock(&chip->setup_mutex);
 
        /* copy the struct snd_pcm_hardware struct */
@@ -227,7 +227,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
        err = snd_pcm_hw_constraint_integer(runtime,
                                            SNDRV_PCM_HW_PARAM_PERIODS);
        if (err < 0) {
-               snd_printk(KERN_WARNING LXP "could not constrain periods\n");
+               dev_warn(chip->card->dev, "could not constrain periods\n");
                goto exit;
        }
 #endif
@@ -238,7 +238,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
                                           board_rate, board_rate);
 
        if (err < 0) {
-               snd_printk(KERN_WARNING LXP "could not constrain periods\n");
+               dev_warn(chip->card->dev, "could not constrain periods\n");
                goto exit;
        }
 
@@ -248,7 +248,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
                                           MICROBLAZE_IBL_MIN,
                                           MICROBLAZE_IBL_MAX);
        if (err < 0) {
-               snd_printk(KERN_WARNING LXP
+               dev_warn(chip->card->dev,
                           "could not constrain period size\n");
                goto exit;
        }
@@ -263,14 +263,14 @@ exit:
        runtime->private_data = chip;
 
        mutex_unlock(&chip->setup_mutex);
-       snd_printdd("<-lx_pcm_open, %d\n", err);
+       dev_dbg(chip->card->dev, "<-lx_pcm_open, %d\n", err);
        return err;
 }
 
 static int lx_pcm_close(struct snd_pcm_substream *substream)
 {
        int err = 0;
-       snd_printdd("->lx_pcm_close\n");
+       dev_dbg(substream->pcm->card->dev, "->lx_pcm_close\n");
        return err;
 }
 
@@ -285,13 +285,13 @@ static snd_pcm_uframes_t lx_pcm_stream_pointer(struct snd_pcm_substream
        struct lx_stream *lx_stream = is_capture ? &chip->capture_stream :
                &chip->playback_stream;
 
-       snd_printdd("->lx_pcm_stream_pointer\n");
+       dev_dbg(chip->card->dev, "->lx_pcm_stream_pointer\n");
 
        spin_lock_irqsave(&chip->lock, flags);
        pos = lx_stream->frame_pos * substream->runtime->period_size;
        spin_unlock_irqrestore(&chip->lock, flags);
 
-       snd_printdd(LXP "stream_pointer at %ld\n", pos);
+       dev_dbg(chip->card->dev, "stream_pointer at %ld\n", pos);
        return pos;
 }
 
@@ -301,37 +301,37 @@ static int lx_pcm_prepare(struct snd_pcm_substream *substream)
        int err = 0;
        const int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
 
-       snd_printdd("->lx_pcm_prepare\n");
+       dev_dbg(chip->card->dev, "->lx_pcm_prepare\n");
 
        mutex_lock(&chip->setup_mutex);
 
        if (chip->hardware_running[is_capture]) {
                err = lx_hardware_stop(chip, substream);
                if (err < 0) {
-                       snd_printk(KERN_ERR LXP "failed to stop hardware. "
+                       dev_err(chip->card->dev, "failed to stop hardware. "
                                   "Error code %d\n", err);
                        goto exit;
                }
 
                err = lx_hardware_close(chip, substream);
                if (err < 0) {
-                       snd_printk(KERN_ERR LXP "failed to close hardware. "
+                       dev_err(chip->card->dev, "failed to close hardware. "
                                   "Error code %d\n", err);
                        goto exit;
                }
        }
 
-       snd_printd(LXP "opening hardware\n");
+       dev_dbg(chip->card->dev, "opening hardware\n");
        err = lx_hardware_open(chip, substream);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "failed to open hardware. "
+               dev_err(chip->card->dev, "failed to open hardware. "
                           "Error code %d\n", err);
                goto exit;
        }
 
        err = lx_hardware_start(chip, substream);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "failed to start hardware. "
+               dev_err(chip->card->dev, "failed to start hardware. "
                           "Error code %d\n", err);
                goto exit;
        }
@@ -354,7 +354,7 @@ static int lx_pcm_hw_params(struct snd_pcm_substream *substream,
        struct lx6464es *chip = snd_pcm_substream_chip(substream);
        int err = 0;
 
-       snd_printdd("->lx_pcm_hw_params\n");
+       dev_dbg(chip->card->dev, "->lx_pcm_hw_params\n");
 
        mutex_lock(&chip->setup_mutex);
 
@@ -389,20 +389,20 @@ static int lx_pcm_hw_free(struct snd_pcm_substream *substream)
        int err = 0;
        int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
 
-       snd_printdd("->lx_pcm_hw_free\n");
+       dev_dbg(chip->card->dev, "->lx_pcm_hw_free\n");
        mutex_lock(&chip->setup_mutex);
 
        if (chip->hardware_running[is_capture]) {
                err = lx_hardware_stop(chip, substream);
                if (err < 0) {
-                       snd_printk(KERN_ERR LXP "failed to stop hardware. "
+                       dev_err(chip->card->dev, "failed to stop hardware. "
                                   "Error code %d\n", err);
                        goto exit;
                }
 
                err = lx_hardware_close(chip, substream);
                if (err < 0) {
-                       snd_printk(KERN_ERR LXP "failed to close hardware. "
+                       dev_err(chip->card->dev, "failed to close hardware. "
                                   "Error code %d\n", err);
                        goto exit;
                }
@@ -446,25 +446,25 @@ static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream)
 
                err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed,
                                    size_array);
-               snd_printdd(LXP "starting: needed %d, freed %d\n",
+               dev_dbg(chip->card->dev, "starting: needed %d, freed %d\n",
                            needed, freed);
 
                err = lx_buffer_give(chip, 0, is_capture, period_bytes,
                                     lower_32_bits(buf), upper_32_bits(buf),
                                     &buffer_index);
 
-               snd_printdd(LXP "starting: buffer index %x on 0x%lx (%d bytes)\n",
+               dev_dbg(chip->card->dev, "starting: buffer index %x on 0x%lx (%d bytes)\n",
                            buffer_index, (unsigned long)buf, period_bytes);
                buf += period_bytes;
        }
 
        err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array);
-       snd_printdd(LXP "starting: needed %d, freed %d\n", needed, freed);
+       dev_dbg(chip->card->dev, "starting: needed %d, freed %d\n", needed, freed);
 
-       snd_printd(LXP "starting: starting stream\n");
+       dev_dbg(chip->card->dev, "starting: starting stream\n");
        err = lx_stream_start(chip, 0, is_capture);
        if (err < 0)
-               snd_printk(KERN_ERR LXP "couldn't start stream\n");
+               dev_err(chip->card->dev, "couldn't start stream\n");
        else
                lx_stream->status = LX_STREAM_STATUS_RUNNING;
 
@@ -476,10 +476,10 @@ static void lx_trigger_stop(struct lx6464es *chip, struct lx_stream *lx_stream)
        const unsigned int is_capture = lx_stream->is_capture;
        int err;
 
-       snd_printd(LXP "stopping: stopping stream\n");
+       dev_dbg(chip->card->dev, "stopping: stopping stream\n");
        err = lx_stream_stop(chip, 0, is_capture);
        if (err < 0)
-               snd_printk(KERN_ERR LXP "couldn't stop stream\n");
+               dev_err(chip->card->dev, "couldn't stop stream\n");
        else
                lx_stream->status = LX_STREAM_STATUS_FREE;
 
@@ -507,7 +507,7 @@ static void lx_trigger_tasklet(unsigned long data)
        struct lx6464es *chip = (struct lx6464es *)data;
        unsigned long flags;
 
-       snd_printdd("->lx_trigger_tasklet\n");
+       dev_dbg(chip->card->dev, "->lx_trigger_tasklet\n");
 
        spin_lock_irqsave(&chip->lock, flags);
        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)
        struct lx_stream *stream = is_capture ? &chip->capture_stream :
                &chip->playback_stream;
 
-       snd_printdd("->lx_pcm_trigger\n");
+       dev_dbg(chip->card->dev, "->lx_pcm_trigger\n");
 
        return lx_pcm_trigger_dispatch(chip, stream, cmd);
 }
 
 static int snd_lx6464es_free(struct lx6464es *chip)
 {
-       snd_printdd("->snd_lx6464es_free\n");
+       dev_dbg(chip->card->dev, "->snd_lx6464es_free\n");
 
        lx_irq_disable(chip);
 
@@ -583,7 +583,7 @@ static int lx_init_xilinx_reset(struct lx6464es *chip)
        int i;
        u32 plx_reg = lx_plx_reg_read(chip, ePLX_CHIPSC);
 
-       snd_printdd("->lx_init_xilinx_reset\n");
+       dev_dbg(chip->card->dev, "->lx_init_xilinx_reset\n");
 
        /* activate reset of xilinx */
        plx_reg &= ~CHIPSC_RESET_XILINX;
@@ -603,8 +603,8 @@ static int lx_init_xilinx_reset(struct lx6464es *chip)
                msleep(10);
                reg_mbox3 = lx_plx_reg_read(chip, ePLX_MBOX3);
                if (reg_mbox3) {
-                       snd_printd(LXP "xilinx reset done\n");
-                       snd_printdd(LXP "xilinx took %d loops\n", i);
+                       dev_dbg(chip->card->dev, "xilinx reset done\n");
+                       dev_dbg(chip->card->dev, "xilinx took %d loops\n", i);
                        break;
                }
        }
@@ -624,7 +624,7 @@ static int lx_init_xilinx_test(struct lx6464es *chip)
 {
        u32 reg;
 
-       snd_printdd("->lx_init_xilinx_test\n");
+       dev_dbg(chip->card->dev, "->lx_init_xilinx_test\n");
 
        /* TEST if we have access to Xilinx/MicroBlaze */
        lx_dsp_reg_write(chip, eReg_CSM, 0);
@@ -632,19 +632,19 @@ static int lx_init_xilinx_test(struct lx6464es *chip)
        reg = lx_dsp_reg_read(chip, eReg_CSM);
 
        if (reg) {
-               snd_printk(KERN_ERR LXP "Problem: Reg_CSM %x.\n", reg);
+               dev_err(chip->card->dev, "Problem: Reg_CSM %x.\n", reg);
 
                /* PCI9056_SPACE0_REMAP */
                lx_plx_reg_write(chip, ePLX_PCICR, 1);
 
                reg = lx_dsp_reg_read(chip, eReg_CSM);
                if (reg) {
-                       snd_printk(KERN_ERR LXP "Error: Reg_CSM %x.\n", reg);
+                       dev_err(chip->card->dev, "Error: Reg_CSM %x.\n", reg);
                        return -EAGAIN; /* seems to be appropriate */
                }
        }
 
-       snd_printd(LXP "Xilinx/MicroBlaze access test successful\n");
+       dev_dbg(chip->card->dev, "Xilinx/MicroBlaze access test successful\n");
 
        return 0;
 }
@@ -661,7 +661,7 @@ static int lx_init_ethersound_config(struct lx6464es *chip)
                (64 << IOCR_OUTPUTS_OFFSET) |
                (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET);
 
-       snd_printdd("->lx_init_ethersound\n");
+       dev_dbg(chip->card->dev, "->lx_init_ethersound\n");
 
        chip->freq_ratio = FREQ_RATIO_SINGLE_MODE;
 
@@ -675,18 +675,18 @@ static int lx_init_ethersound_config(struct lx6464es *chip)
 
        for (i = 0; i != 1000; ++i) {
                if (lx_dsp_reg_read(chip, eReg_CSES) & 4) {
-                       snd_printd(LXP "ethersound initialized after %dms\n",
+                       dev_dbg(chip->card->dev, "ethersound initialized after %dms\n",
                                   i);
                        goto ethersound_initialized;
                }
                msleep(1);
        }
-       snd_printk(KERN_WARNING LXP
+       dev_warn(chip->card->dev,
                   "ethersound could not be initialized after %dms\n", i);
        return -ETIMEDOUT;
 
  ethersound_initialized:
-       snd_printd(LXP "ethersound initialized\n");
+       dev_dbg(chip->card->dev, "ethersound initialized\n");
        return 0;
 }
 
@@ -696,14 +696,14 @@ static int lx_init_get_version_features(struct lx6464es *chip)
 
        int err;
 
-       snd_printdd("->lx_init_get_version_features\n");
+       dev_dbg(chip->card->dev, "->lx_init_get_version_features\n");
 
        err = lx_dsp_get_version(chip, &dsp_version);
 
        if (err == 0) {
                u32 freq;
 
-               snd_printk(LXP "DSP version: V%02d.%02d #%d\n",
+               dev_info(chip->card->dev, "DSP version: V%02d.%02d #%d\n",
                           (dsp_version>>16) & 0xff, (dsp_version>>8) & 0xff,
                           dsp_version & 0xff);
 
@@ -718,9 +718,9 @@ static int lx_init_get_version_features(struct lx6464es *chip)
                err = lx_dsp_get_clock_frequency(chip, &freq);
                if (err == 0)
                        chip->board_sample_rate = freq;
-               snd_printd(LXP "actual clock frequency %d\n", freq);
+               dev_dbg(chip->card->dev, "actual clock frequency %d\n", freq);
        } else {
-               snd_printk(KERN_ERR LXP "DSP corrupted \n");
+               dev_err(chip->card->dev, "DSP corrupted \n");
                err = -EAGAIN;
        }
 
@@ -732,7 +732,7 @@ static int lx_set_granularity(struct lx6464es *chip, u32 gran)
        int err = 0;
        u32 snapped_gran = MICROBLAZE_IBL_MIN;
 
-       snd_printdd("->lx_set_granularity\n");
+       dev_dbg(chip->card->dev, "->lx_set_granularity\n");
 
        /* blocksize is a power of 2 */
        while ((snapped_gran < gran) &&
@@ -745,14 +745,14 @@ static int lx_set_granularity(struct lx6464es *chip, u32 gran)
 
        err = lx_dsp_set_granularity(chip, snapped_gran);
        if (err < 0) {
-               snd_printk(KERN_WARNING LXP "could not set granularity\n");
+               dev_warn(chip->card->dev, "could not set granularity\n");
                err = -EAGAIN;
        }
 
        if (snapped_gran != gran)
-               snd_printk(LXP "snapped blocksize to %d\n", snapped_gran);
+               dev_err(chip->card->dev, "snapped blocksize to %d\n", snapped_gran);
 
-       snd_printd(LXP "set blocksize on board %d\n", snapped_gran);
+       dev_dbg(chip->card->dev, "set blocksize on board %d\n", snapped_gran);
        chip->pcm_granularity = snapped_gran;
 
        return err;
@@ -764,19 +764,19 @@ static int lx_init_dsp(struct lx6464es *chip)
        int err;
        int i;
 
-       snd_printdd("->lx_init_dsp\n");
+       dev_dbg(chip->card->dev, "->lx_init_dsp\n");
 
-       snd_printd(LXP "initialize board\n");
+       dev_dbg(chip->card->dev, "initialize board\n");
        err = lx_init_xilinx_reset(chip);
        if (err)
                return err;
 
-       snd_printd(LXP "testing board\n");
+       dev_dbg(chip->card->dev, "testing board\n");
        err = lx_init_xilinx_test(chip);
        if (err)
                return err;
 
-       snd_printd(LXP "initialize ethersound configuration\n");
+       dev_dbg(chip->card->dev, "initialize ethersound configuration\n");
        err = lx_init_ethersound_config(chip);
        if (err)
                return err;
@@ -797,8 +797,9 @@ static int lx_init_dsp(struct lx6464es *chip)
        return -ETIMEDOUT;
 
 mac_ready:
-       snd_printd(LXP "mac address ready read after: %dms\n", i);
-       snd_printk(LXP "mac address: %02X.%02X.%02X.%02X.%02X.%02X\n",
+       dev_dbg(chip->card->dev, "mac address ready read after: %dms\n", i);
+       dev_info(chip->card->dev,
+                "mac address: %02X.%02X.%02X.%02X.%02X.%02X\n",
                   chip->mac_address[0], chip->mac_address[1], chip->mac_address[2],
                   chip->mac_address[3], chip->mac_address[4], chip->mac_address[5]);
 
@@ -977,7 +978,7 @@ static int snd_lx6464es_create(struct snd_card *card,
                .dev_free = snd_lx6464es_dev_free,
        };
 
-       snd_printdd("->snd_lx6464es_create\n");
+       dev_dbg(card->dev, "->snd_lx6464es_create\n");
 
        *rchip = NULL;
 
@@ -991,8 +992,8 @@ static int snd_lx6464es_create(struct snd_card *card,
        /* check if we can restrict PCI DMA transfers to 32 bits */
        err = pci_set_dma_mask(pci, DMA_BIT_MASK(32));
        if (err < 0) {
-               snd_printk(KERN_ERR "architecture does not support "
-                          "32bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 32bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -1034,7 +1035,7 @@ static int snd_lx6464es_create(struct snd_card *card,
        err = request_irq(pci->irq, lx_interrupt, IRQF_SHARED,
                          KBUILD_MODNAME, chip);
        if (err) {
-               snd_printk(KERN_ERR LXP "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                goto request_irq_failed;
        }
        chip->irq = pci->irq;
@@ -1045,7 +1046,7 @@ static int snd_lx6464es_create(struct snd_card *card,
 
        err = lx_init_dsp(chip);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "error during DSP initialization\n");
+               dev_err(card->dev, "error during DSP initialization\n");
                return err;
        }
 
@@ -1062,8 +1063,6 @@ static int snd_lx6464es_create(struct snd_card *card,
        if (err < 0)
                return err;
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        return 0;
 
@@ -1090,7 +1089,7 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
        struct lx6464es *chip;
        int err;
 
-       snd_printdd("->snd_lx6464es_probe\n");
+       dev_dbg(&pci->dev, "->snd_lx6464es_probe\n");
 
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
@@ -1099,13 +1098,14 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
        err = snd_lx6464es_create(card, pci, &chip);
        if (err < 0) {
-               snd_printk(KERN_ERR LXP "error during snd_lx6464es_create\n");
+               dev_err(card->dev, "error during snd_lx6464es_create\n");
                goto out_free;
        }
 
@@ -1125,7 +1125,7 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
        if (err < 0)
                goto out_free;
 
-       snd_printdd(LXP "initialization successful\n");
+       dev_dbg(chip->card->dev, "initialization successful\n");
        pci_set_drvdata(pci, card);
        dev++;
        return 0;
index 626ecad4dae78bb95fd238f97cc299c4c2b03761..2d8e95e9fbe59c547ad0026a136788e8e4f1d411 100644 (file)
@@ -141,63 +141,6 @@ void lx_plx_reg_write(struct lx6464es *chip, int port, u32 data)
        iowrite32(data, address);
 }
 
-u32 lx_plx_mbox_read(struct lx6464es *chip, int mbox_nr)
-{
-       int index;
-
-       switch (mbox_nr) {
-       case 1:
-               index = ePLX_MBOX1;    break;
-       case 2:
-               index = ePLX_MBOX2;    break;
-       case 3:
-               index = ePLX_MBOX3;    break;
-       case 4:
-               index = ePLX_MBOX4;    break;
-       case 5:
-               index = ePLX_MBOX5;    break;
-       case 6:
-               index = ePLX_MBOX6;    break;
-       case 7:
-               index = ePLX_MBOX7;    break;
-       case 0:                 /* reserved for HF flags */
-               snd_BUG();
-       default:
-               return 0xdeadbeef;
-       }
-
-       return lx_plx_reg_read(chip, index);
-}
-
-int lx_plx_mbox_write(struct lx6464es *chip, int mbox_nr, u32 value)
-{
-       int index = -1;
-
-       switch (mbox_nr) {
-       case 1:
-               index = ePLX_MBOX1;    break;
-       case 3:
-               index = ePLX_MBOX3;    break;
-       case 4:
-               index = ePLX_MBOX4;    break;
-       case 5:
-               index = ePLX_MBOX5;    break;
-       case 6:
-               index = ePLX_MBOX6;    break;
-       case 7:
-               index = ePLX_MBOX7;    break;
-       case 0:                 /* reserved for HF flags */
-       case 2:                 /* reserved for Pipe States
-                                * the DSP keeps an image of it */
-               snd_BUG();
-               return -EBADRQC;
-       }
-
-       lx_plx_reg_write(chip, index, value);
-       return 0;
-}
-
-
 /* rmh */
 
 #ifdef CONFIG_SND_DEBUG
@@ -330,7 +273,7 @@ static int lx_message_send_atomic(struct lx6464es *chip, struct lx_rmh *rmh)
        int dwloop;
 
        if (lx_dsp_reg_read(chip, eReg_CSM) & (Reg_CSM_MC | Reg_CSM_MR)) {
-               snd_printk(KERN_ERR LXP "PIOSendMessage eReg_CSM %x\n", reg);
+               dev_err(chip->card->dev, "PIOSendMessage eReg_CSM %x\n", reg);
                return -EBUSY;
        }
 
@@ -351,7 +294,7 @@ static int lx_message_send_atomic(struct lx6464es *chip, struct lx_rmh *rmh)
                } else
                        udelay(1);
        }
-       snd_printk(KERN_WARNING LXP "TIMEOUT lx_message_send_atomic! "
+       dev_warn(chip->card->dev, "TIMEOUT lx_message_send_atomic! "
                   "polling failed\n");
 
 polling_successful:
@@ -363,18 +306,18 @@ polling_successful:
                                           rmh->stat_len);
                }
        } else
-               snd_printk(LXP "rmh error: %08x\n", reg);
+               dev_err(chip->card->dev, "rmh error: %08x\n", reg);
 
        /* clear Reg_CSM_MR */
        lx_dsp_reg_write(chip, eReg_CSM, 0);
 
        switch (reg) {
        case ED_DSP_TIMED_OUT:
-               snd_printk(KERN_WARNING LXP "lx_message_send: dsp timeout\n");
+               dev_warn(chip->card->dev, "lx_message_send: dsp timeout\n");
                return -ETIMEDOUT;
 
        case ED_DSP_CRASHED:
-               snd_printk(KERN_WARNING LXP "lx_message_send: dsp crashed\n");
+               dev_warn(chip->card->dev, "lx_message_send: dsp crashed\n");
                return -EAGAIN;
        }
 
@@ -491,33 +434,6 @@ int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data)
 #define CSES_BROADCAST      0x0002
 #define CSES_UPDATE_LDSV    0x0004
 
-int lx_dsp_es_check_pipeline(struct lx6464es *chip)
-{
-       int i;
-
-       for (i = 0; i != CSES_TIMEOUT; ++i) {
-               /*
-                * le bit CSES_UPDATE_LDSV est ÃƒÂ  1 dés que le macprog
-                * est pret. il re-passe ÃƒÂ  0 lorsque le premier read a
-                * ÃƒÂ©té fait. pour l'instant on retire le test car ce bit
-                * passe a 1 environ 200 ÃƒÂ  400 ms aprés que le registre
-                * confES ÃƒÂ  ÃƒÂ©té ÃƒÂ©crit (kick du xilinx ES).
-                *
-                * On ne teste que le bit CE.
-                * */
-
-               u32 cses = lx_dsp_reg_read(chip, eReg_CSES);
-
-               if ((cses & CSES_CE) == 0)
-                       return 0;
-
-               udelay(1);
-       }
-
-       return -ETIMEDOUT;
-}
-
-
 #define PIPE_INFO_TO_CMD(capture, pipe)                                        \
        ((u32)((u32)(pipe) | ((capture) ? ID_IS_CAPTURE : 0L)) << ID_OFFSET)
 
@@ -542,7 +458,7 @@ int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture,
        spin_unlock_irqrestore(&chip->msg_lock, flags);
 
        if (err != 0)
-               snd_printk(KERN_ERR "lx6464es: could not allocate pipe\n");
+               dev_err(chip->card->dev, "could not allocate pipe\n");
 
        return err;
 }
@@ -604,11 +520,13 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
                }
 
 #if 0
-               snd_printdd(LXP "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
+               dev_dbg(chip->card->dev,
+                       "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
                            *r_needed, *r_freed);
                for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
                        for (i = 0; i != chip->rmh.stat_len; ++i)
-                               snd_printdd("  stat[%d]: %x, %x\n", i,
+                               dev_dbg(chip->card->dev,
+                                       "  stat[%d]: %x, %x\n", i,
                                            chip->rmh.stat[i],
                                            chip->rmh.stat[i] & MASK_DATA_SIZE);
                }
@@ -701,8 +619,8 @@ int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture,
        err = lx_message_send_atomic(chip, &chip->rmh); /* don't sleep! */
 
        if (err != 0)
-               snd_printk(KERN_ERR
-                          "lx6464es: could not query pipe's sample count\n");
+               dev_err(chip->card->dev,
+                       "could not query pipe's sample count\n");
        else {
                *rsample_count = ((u64)(chip->rmh.stat[0] & MASK_SPL_COUNT_HI)
                                  << 24)     /* hi part */
@@ -728,7 +646,7 @@ int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate)
        err = lx_message_send_atomic(chip, &chip->rmh);
 
        if (err != 0)
-               snd_printk(KERN_ERR "lx6464es: could not query pipe's state\n");
+               dev_err(chip->card->dev, "could not query pipe's state\n");
        else
                *rstate = (chip->rmh.stat[0] >> PSTATE_OFFSET) & 0x0F;
 
@@ -801,7 +719,7 @@ int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime,
        u32 channels = runtime->channels;
 
        if (runtime->channels != channels)
-               snd_printk(KERN_ERR LXP "channel count mismatch: %d vs %d",
+               dev_err(chip->card->dev, "channel count mismatch: %d vs %d",
                           runtime->channels, channels);
 
        spin_lock_irqsave(&chip->msg_lock, flags);
@@ -904,13 +822,16 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture,
        }
 
        if (err == EB_RBUFFERS_TABLE_OVERFLOW)
-               snd_printk(LXP "lx_buffer_give EB_RBUFFERS_TABLE_OVERFLOW\n");
+               dev_err(chip->card->dev,
+                       "lx_buffer_give EB_RBUFFERS_TABLE_OVERFLOW\n");
 
        if (err == EB_INVALID_STREAM)
-               snd_printk(LXP "lx_buffer_give EB_INVALID_STREAM\n");
+               dev_err(chip->card->dev,
+                       "lx_buffer_give EB_INVALID_STREAM\n");
 
        if (err == EB_CMD_REFUSED)
-               snd_printk(LXP "lx_buffer_give EB_CMD_REFUSED\n");
+               dev_err(chip->card->dev,
+                       "lx_buffer_give EB_CMD_REFUSED\n");
 
  done:
        spin_unlock_irqrestore(&chip->msg_lock, flags);
@@ -983,7 +904,8 @@ int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute)
        chip->rmh.cmd[1] = (u32)(mute_mask >> (u64)32);        /* hi part */
        chip->rmh.cmd[2] = (u32)(mute_mask & (u64)0xFFFFFFFF); /* lo part */
 
-       snd_printk("mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1],
+       dev_dbg(chip->card->dev,
+               "mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1],
                   chip->rmh.cmd[2]);
 
        err = lx_message_send_atomic(chip, &chip->rmh);
@@ -1093,7 +1015,7 @@ static int lx_interrupt_ack(struct lx6464es *chip, u32 *r_irqsrc,
        }
 
        if (irq_async) {
-               /* snd_printd("interrupt: async event pending\n"); */
+               /* dev_dbg(chip->card->dev, "interrupt: async event pending\n"); */
                *r_async_pending = 1;
        }
 
@@ -1139,13 +1061,13 @@ static int lx_interrupt_handle_async_events(struct lx6464es *chip, u32 irqsrc,
        if (eb_pending_in) {
                *r_notified_in_pipe_mask = ((u64)stat[3] << 32)
                        + stat[4];
-               snd_printdd(LXP "interrupt: EOBI pending %llx\n",
+               dev_dbg(chip->card->dev, "interrupt: EOBI pending %llx\n",
                            *r_notified_in_pipe_mask);
        }
        if (eb_pending_out) {
                *r_notified_out_pipe_mask = ((u64)stat[1] << 32)
                        + stat[2];
-               snd_printdd(LXP "interrupt: EOBO pending %llx\n",
+               dev_dbg(chip->card->dev, "interrupt: EOBO pending %llx\n",
                            *r_notified_out_pipe_mask);
        }
 
@@ -1181,17 +1103,19 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip,
        u32 needed, freed;
        u32 size_array[MAX_STREAM_BUFFER];
 
-       snd_printdd("->lx_interrupt_request_new_buffer\n");
+       dev_dbg(chip->card->dev, "->lx_interrupt_request_new_buffer\n");
 
        spin_lock_irqsave(&chip->lock, flags);
 
        err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array);
-       snd_printdd(LXP "interrupt: needed %d, freed %d\n", needed, freed);
+       dev_dbg(chip->card->dev,
+               "interrupt: needed %d, freed %d\n", needed, freed);
 
        unpack_pointer(buf, &buf_lo, &buf_hi);
        err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi,
                             &buffer_index);
-       snd_printdd(LXP "interrupt: gave buffer index %x on 0x%lx (%d bytes)\n",
+       dev_dbg(chip->card->dev,
+               "interrupt: gave buffer index %x on 0x%lx (%d bytes)\n",
                    buffer_index, (unsigned long)buf, period_bytes);
 
        lx_stream->frame_pos = next_pos;
@@ -1206,11 +1130,11 @@ void lx_tasklet_playback(unsigned long data)
        struct lx_stream *lx_stream = &chip->playback_stream;
        int err;
 
-       snd_printdd("->lx_tasklet_playback\n");
+       dev_dbg(chip->card->dev, "->lx_tasklet_playback\n");
 
        err = lx_interrupt_request_new_buffer(chip, lx_stream);
        if (err < 0)
-               snd_printk(KERN_ERR LXP
+               dev_err(chip->card->dev,
                           "cannot request new buffer for playback\n");
 
        snd_pcm_period_elapsed(lx_stream->stream);
@@ -1222,10 +1146,10 @@ void lx_tasklet_capture(unsigned long data)
        struct lx_stream *lx_stream = &chip->capture_stream;
        int err;
 
-       snd_printdd("->lx_tasklet_capture\n");
+       dev_dbg(chip->card->dev, "->lx_tasklet_capture\n");
        err = lx_interrupt_request_new_buffer(chip, lx_stream);
        if (err < 0)
-               snd_printk(KERN_ERR LXP
+               dev_err(chip->card->dev,
                           "cannot request new buffer for capture\n");
 
        snd_pcm_period_elapsed(lx_stream->stream);
@@ -1240,12 +1164,14 @@ static int lx_interrupt_handle_audio_transfer(struct lx6464es *chip,
        int err = 0;
 
        if (notified_in_pipe_mask) {
-               snd_printdd(LXP "requesting audio transfer for capture\n");
+               dev_dbg(chip->card->dev,
+                       "requesting audio transfer for capture\n");
                tasklet_hi_schedule(&chip->tasklet_capture);
        }
 
        if (notified_out_pipe_mask) {
-               snd_printdd(LXP "requesting audio transfer for playback\n");
+               dev_dbg(chip->card->dev,
+                       "requesting audio transfer for playback\n");
                tasklet_hi_schedule(&chip->tasklet_playback);
        }
 
@@ -1261,11 +1187,12 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
 
        spin_lock(&chip->lock);
 
-       snd_printdd("**************************************************\n");
+       dev_dbg(chip->card->dev,
+               "**************************************************\n");
 
        if (!lx_interrupt_ack(chip, &irqsrc, &async_pending, &async_escmd)) {
                spin_unlock(&chip->lock);
-               snd_printdd("IRQ_NONE\n");
+               dev_dbg(chip->card->dev, "IRQ_NONE\n");
                return IRQ_NONE; /* this device did not cause the interrupt */
        }
 
@@ -1274,16 +1201,16 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
 
 #if 0
        if (irqsrc & MASK_SYS_STATUS_EOBI)
-               snd_printdd(LXP "interrupt: EOBI\n");
+               dev_dgg(chip->card->dev, "interrupt: EOBI\n");
 
        if (irqsrc & MASK_SYS_STATUS_EOBO)
-               snd_printdd(LXP "interrupt: EOBO\n");
+               dev_dbg(chip->card->dev, "interrupt: EOBO\n");
 
        if (irqsrc & MASK_SYS_STATUS_URUN)
-               snd_printdd(LXP "interrupt: URUN\n");
+               dev_dbg(chip->card->dev, "interrupt: URUN\n");
 
        if (irqsrc & MASK_SYS_STATUS_ORUN)
-               snd_printdd(LXP "interrupt: ORUN\n");
+               dev_dbg(chip->card->dev, "interrupt: ORUN\n");
 #endif
 
        if (async_pending) {
@@ -1298,7 +1225,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
                                                       &notified_in_pipe_mask,
                                                       &notified_out_pipe_mask);
                if (err)
-                       snd_printk(KERN_ERR LXP
+                       dev_err(chip->card->dev,
                                   "error handling async events\n");
 
                err = lx_interrupt_handle_audio_transfer(chip,
@@ -1306,7 +1233,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
                                                         notified_out_pipe_mask
                        );
                if (err)
-                       snd_printk(KERN_ERR LXP
+                       dev_err(chip->card->dev,
                                   "error during audio transfer\n");
        }
 
@@ -1318,7 +1245,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
                 *
                 * */
 
-               snd_printdd("lx6464es: interrupt requests escmd handling\n");
+               dev_dbg(chip->card->dev, "interrupt requests escmd handling\n");
 #endif
        }
 
@@ -1346,12 +1273,12 @@ static void lx_irq_set(struct lx6464es *chip, int enable)
 
 void lx_irq_enable(struct lx6464es *chip)
 {
-       snd_printdd("->lx_irq_enable\n");
+       dev_dbg(chip->card->dev, "->lx_irq_enable\n");
        lx_irq_set(chip, 1);
 }
 
 void lx_irq_disable(struct lx6464es *chip)
 {
-       snd_printdd("->lx_irq_disable\n");
+       dev_dbg(chip->card->dev, "->lx_irq_disable\n");
        lx_irq_set(chip, 0);
 }
index d5417360f51fb8be6a43be6ddef9bd6c2e7ac2e3..0d3ea3e79952a0eeab478949c51ddb90fa5a2aa1 100644 (file)
@@ -1403,7 +1403,7 @@ static int snd_m3_pcm_hw_params(struct snd_pcm_substream *substream,
        /* set buffer address */
        s->buffer_addr = substream->runtime->dma_addr;
        if (s->buffer_addr & 0x3) {
-               snd_printk(KERN_ERR "oh my, not aligned\n");
+               dev_err(substream->pcm->card->dev, "oh my, not aligned\n");
                s->buffer_addr = s->buffer_addr & ~0x3;
        }
        return 0;
@@ -1900,7 +1900,7 @@ static int snd_m3_ac97_wait(struct snd_m3 *chip)
                cpu_relax();
        } while (i-- > 0);
 
-       snd_printk(KERN_ERR "ac97 serial bus busy\n");
+       dev_err(chip->card->dev, "ac97 serial bus busy\n");
        return 1;
 }
 
@@ -2015,7 +2015,8 @@ static void snd_m3_ac97_reset(struct snd_m3 *chip)
                delay1 += 10;
                delay2 += 100;
 
-               snd_printd("maestro3: retrying codec reset with delays of %d and %d ms\n",
+               dev_dbg(chip->card->dev,
+                       "retrying codec reset with delays of %d and %d ms\n",
                           delay1, delay2);
        }
 
@@ -2194,7 +2195,8 @@ static int snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int in
        address = 0x1100 + ((data_bytes/2) * index);
 
        if ((address + (data_bytes/2)) >= 0x1c00) {
-               snd_printk(KERN_ERR "no memory for %d bytes at ind %d (addr 0x%x)\n",
+               dev_err(chip->card->dev,
+                       "no memory for %d bytes at ind %d (addr 0x%x)\n",
                           data_bytes, index, address);
                return -ENOMEM;
        }
@@ -2439,8 +2441,7 @@ static int m3_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "maestor3: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2553,7 +2554,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
        /* check, if we can restrict PCI DMA transfers to 28 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 28bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -2586,9 +2588,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
        else {
                quirk = snd_pci_quirk_lookup(pci, m3_amp_quirk_list);
                if (quirk) {
-                       snd_printdd(KERN_INFO
-                                   "maestro3: set amp-gpio for '%s'\n",
-                                   snd_pci_quirk_name(quirk));
+                       dev_info(card->dev, "set amp-gpio for '%s'\n",
+                                snd_pci_quirk_name(quirk));
                        chip->amp_gpio = quirk->value;
                } else if (chip->allegro_flag)
                        chip->amp_gpio = GPO_EXT_AMP_ALLEGRO;
@@ -2598,9 +2599,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
 
        quirk = snd_pci_quirk_lookup(pci, m3_irda_quirk_list);
        if (quirk) {
-               snd_printdd(KERN_INFO
-                           "maestro3: enabled irda workaround for '%s'\n",
-                           snd_pci_quirk_name(quirk));
+               dev_info(card->dev, "enabled irda workaround for '%s'\n",
+                        snd_pci_quirk_name(quirk));
                chip->irda_workaround = 1;
        }
        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,
 
        if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_m3_free(chip);
                return -ENOMEM;
        }
@@ -2661,7 +2661,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
 #ifdef CONFIG_PM_SLEEP
        chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH));
        if (chip->suspend_mem == NULL)
-               snd_printk(KERN_WARNING "can't allocate apm buffer\n");
+               dev_warn(card->dev, "can't allocate apm buffer\n");
 #endif
 
        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,
        if (chip->hv_config & HV_CTRL_ENABLE) {
                err = snd_m3_input_register(chip);
                if (err)
-                       snd_printk(KERN_WARNING "Input device registration "
-                               "failed with error %i", err);
+                       dev_warn(card->dev,
+                                "Input device registration failed with error %i",
+                                err);
        }
 #endif
 
        snd_m3_enable_ints(chip);
        snd_m3_assp_continue(chip);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *chip_ret = chip;
 
        return 0; 
@@ -2721,7 +2720,8 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -2764,7 +2764,7 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                                  MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
                                  -1, &chip->rmidi);
        if (err < 0)
-               printk(KERN_WARNING "maestro3: no MIDI support.\n");
+               dev_warn(card->dev, "no MIDI support.\n");
 #endif
 
        pci_set_drvdata(pci, card);
index 1e0f6ee193f0a926279e3d3d25a4ea995b78bfdd..a93e7af51eed1138475fbc5b90643ba4703fed1b 100644 (file)
@@ -87,7 +87,8 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
                if(!start) return 0; /* already stopped */
                break;
        default:
-               snd_printk(KERN_ERR "error mixart_set_pipe_state called with wrong pipe->status!\n");
+               dev_err(&mgr->pci->dev,
+                       "error mixart_set_pipe_state called with wrong pipe->status!\n");
                return -EINVAL;      /* function called with wrong pipe status */
        }
 
@@ -102,7 +103,8 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
 
        err = snd_mixart_send_msg_wait_notif(mgr, &request, system_msg_uid);
        if(err) {
-               snd_printk(KERN_ERR "error : MSG_SYSTEM_WAIT_SYNCHRO_CMD was not notified !\n");
+               dev_err(&mgr->pci->dev,
+                       "error : MSG_SYSTEM_WAIT_SYNCHRO_CMD was not notified !\n");
                return err;
        }
 
@@ -123,7 +125,9 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
 
        err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp);
        if (err < 0 || group_state_resp.txx_status != 0) {
-               snd_printk(KERN_ERR "error MSG_STREAM_ST***_STREAM_GRP_PACKET err=%x stat=%x !\n", err, group_state_resp.txx_status);
+               dev_err(&mgr->pci->dev,
+                       "error MSG_STREAM_ST***_STREAM_GRP_PACKET err=%x stat=%x !\n",
+                       err, group_state_resp.txx_status);
                return -EINVAL;
        }
 
@@ -134,7 +138,9 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
 
                err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp);
                if (err < 0 || group_state_resp.txx_status != 0) {
-                       snd_printk(KERN_ERR "error MSG_STREAM_START_STREAM_GRP_PACKET err=%x stat=%x !\n", err, group_state_resp.txx_status);
+                       dev_err(&mgr->pci->dev,
+                               "error MSG_STREAM_START_STREAM_GRP_PACKET err=%x stat=%x !\n",
+                               err, group_state_resp.txx_status);
                        return -EINVAL;
                }
 
@@ -147,7 +153,9 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
 
                err = snd_mixart_send_msg(mgr, &request, sizeof(stat), &stat);
                if (err < 0 || stat != 0) {
-                       snd_printk(KERN_ERR "error MSG_SYSTEM_SEND_SYNCHRO_CMD err=%x stat=%x !\n", err, stat);
+                       dev_err(&mgr->pci->dev,
+                               "error MSG_SYSTEM_SEND_SYNCHRO_CMD err=%x stat=%x !\n",
+                               err, stat);
                        return -EINVAL;
                }
 
@@ -178,7 +186,9 @@ static int mixart_set_clock(struct mixart_mgr *mgr,
                if(rate == 0)
                        return 0; /* nothing to do */
                else {
-                       snd_printk(KERN_ERR "error mixart_set_clock(%d) called with wrong pipe->status !\n", rate);
+                       dev_err(&mgr->pci->dev,
+                               "error mixart_set_clock(%d) called with wrong pipe->status !\n",
+                               rate);
                        return -EINVAL;
                }
        }
@@ -190,7 +200,7 @@ static int mixart_set_clock(struct mixart_mgr *mgr,
        clock_properties.nb_callers = 1; /* only one entry in uid_caller ! */
        clock_properties.uid_caller[0] = pipe->group_uid;
 
-       snd_printdd("mixart_set_clock to %d kHz\n", rate);
+       dev_dbg(&mgr->pci->dev, "mixart_set_clock to %d kHz\n", rate);
 
        request.message_id = MSG_CLOCK_SET_PROPERTIES;
        request.uid = mgr->uid_console_manager;
@@ -199,7 +209,9 @@ static int mixart_set_clock(struct mixart_mgr *mgr,
 
        err = snd_mixart_send_msg(mgr, &request, sizeof(clock_prop_resp), &clock_prop_resp);
        if (err < 0 || clock_prop_resp.status != 0 || clock_prop_resp.clock_mode != CM_STANDALONE) {
-               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);
+               dev_err(&mgr->pci->dev,
+                       "error MSG_CLOCK_SET_PROPERTIES err=%x stat=%x mod=%x !\n",
+                       err, clock_prop_resp.status, clock_prop_resp.clock_mode);
                return -EINVAL;
        }
 
@@ -252,7 +264,9 @@ snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
                        struct mixart_streaming_group sgroup_resp;
                } *buf;
 
-               snd_printdd("add_ref_pipe audio chip(%d) pcm(%d)\n", chip->chip_idx, pcm_number);
+               dev_dbg(chip->card->dev,
+                       "add_ref_pipe audio chip(%d) pcm(%d)\n",
+                       chip->chip_idx, pcm_number);
 
                buf = kmalloc(sizeof(*buf), GFP_KERNEL);
                if (!buf)
@@ -302,7 +316,9 @@ snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
 
                err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp);
                if((err < 0) || (buf->sgroup_resp.status != 0)) {
-                       snd_printk(KERN_ERR "error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n", err, buf->sgroup_resp.status);
+                       dev_err(chip->card->dev,
+                               "error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n",
+                               err, buf->sgroup_resp.status);
                        kfree(buf);
                        return NULL;
                }
@@ -343,13 +359,14 @@ int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
                /* release the clock */
                err = mixart_set_clock( mgr, pipe, 0);
                if( err < 0 ) {
-                       snd_printk(KERN_ERR "mixart_set_clock(0) return error!\n");
+                       dev_err(&mgr->pci->dev,
+                               "mixart_set_clock(0) return error!\n");
                }
 
                /* stop the pipe */
                err = mixart_set_pipe_state(mgr, pipe, 0);
                if( err < 0 ) {
-                       snd_printk(KERN_ERR "error stopping pipe!\n");
+                       dev_err(&mgr->pci->dev, "error stopping pipe!\n");
                }
 
                request.message_id = MSG_STREAM_DELETE_GROUP;
@@ -360,7 +377,9 @@ int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
                /* delete the pipe */
                err = snd_mixart_send_msg(mgr, &request, sizeof(delete_resp), &delete_resp);
                if ((err < 0) || (delete_resp.status != 0)) {
-                       snd_printk(KERN_ERR "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n", err, delete_resp.status);
+                       dev_err(&mgr->pci->dev,
+                               "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n",
+                               err, delete_resp.status);
                }
 
                pipe->group_uid = (struct mixart_uid){0,0};
@@ -414,7 +433,7 @@ static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
 
-               snd_printdd("SNDRV_PCM_TRIGGER_START\n");
+               dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_START\n");
 
                /* START_STREAM */
                if( mixart_set_stream_state(stream, 1) )
@@ -431,19 +450,19 @@ static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
 
                stream->status = MIXART_STREAM_STATUS_OPEN;
 
-               snd_printdd("SNDRV_PCM_TRIGGER_STOP\n");
+               dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_STOP\n");
 
                break;
 
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                /* TODO */
                stream->status = MIXART_STREAM_STATUS_PAUSE;
-               snd_printdd("SNDRV_PCM_PAUSE_PUSH\n");
+               dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_PUSH\n");
                break;
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                /* TODO */
                stream->status = MIXART_STREAM_STATUS_RUNNING;
-               snd_printdd("SNDRV_PCM_PAUSE_RELEASE\n");
+               dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_RELEASE\n");
                break;
        default:
                return -EINVAL;
@@ -456,7 +475,8 @@ static int mixart_sync_nonblock_events(struct mixart_mgr *mgr)
        unsigned long timeout = jiffies + HZ;
        while (atomic_read(&mgr->msg_processed) > 0) {
                if (time_after(jiffies, timeout)) {
-                       snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
+                       dev_err(&mgr->pci->dev,
+                               "mixart: cannot process nonblock events!\n");
                        return -EBUSY;
                }
                schedule_timeout_uninterruptible(1);
@@ -474,7 +494,7 @@ static int snd_mixart_prepare(struct snd_pcm_substream *subs)
 
        /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
 
-       snd_printdd("snd_mixart_prepare\n");
+       dev_dbg(chip->card->dev, "snd_mixart_prepare\n");
 
        mixart_sync_nonblock_events(chip->mgr);
 
@@ -542,11 +562,13 @@ static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t form
                stream_param.sample_size = 32;
                break;
        default:
-               snd_printk(KERN_ERR "error mixart_set_format() : unknown format\n");
+               dev_err(chip->card->dev,
+                       "error mixart_set_format() : unknown format\n");
                return -EINVAL;
        }
 
-       snd_printdd("set SNDRV_PCM_FORMAT sample_type(%d) sample_size(%d) freq(%d) channels(%d)\n",
+       dev_dbg(chip->card->dev,
+               "set SNDRV_PCM_FORMAT sample_type(%d) sample_size(%d) freq(%d) channels(%d)\n",
                   stream_param.sample_type, stream_param.sample_size, stream_param.sampling_freq, stream->channels);
 
        /* TODO: what else to configure ? */
@@ -566,7 +588,9 @@ static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t form
 
        err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
        if((err < 0) || resp.error_code) {
-               snd_printk(KERN_ERR "MSG_STREAM_SET_INPUT_STAGE_PARAM err=%x; resp=%x\n", err, resp.error_code);
+               dev_err(chip->card->dev,
+                       "MSG_STREAM_SET_INPUT_STAGE_PARAM err=%x; resp=%x\n",
+                       err, resp.error_code);
                return -EINVAL;
        }
        return 0;
@@ -627,8 +651,9 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
                bufferinfo[i].available_length = subs->runtime->dma_bytes;
                /* bufferinfo[i].buffer_id  is already defined */
 
-               snd_printdd("snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n", i,
-                               bufferinfo[i].buffer_address,
+               dev_dbg(chip->card->dev,
+                       "snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n",
+                       i, bufferinfo[i].buffer_address,
                                bufferinfo[i].available_length,
                                subs->number);
        }
@@ -714,14 +739,18 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
-       snd_printdd("snd_mixart_playback_open C%d/P%d/Sub%d\n", chip->chip_idx, pcm_number, subs->number);
+       dev_dbg(chip->card->dev,
+               "snd_mixart_playback_open C%d/P%d/Sub%d\n",
+               chip->chip_idx, pcm_number, subs->number);
 
        /* get stream info */
        stream = &(chip->playback_stream[pcm_number][subs->number]);
 
        if (stream->status != MIXART_STREAM_STATUS_FREE){
                /* streams in use */
-               snd_printk(KERN_ERR "snd_mixart_playback_open C%d/P%d/Sub%d in use\n", chip->chip_idx, pcm_number, subs->number);
+               dev_err(chip->card->dev,
+                       "snd_mixart_playback_open C%d/P%d/Sub%d in use\n",
+                       chip->chip_idx, pcm_number, subs->number);
                err = -EBUSY;
                goto _exit_open;
        }
@@ -737,7 +766,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
        /* start the pipe if necessary */
        err = mixart_set_pipe_state(chip->mgr, pipe, 1);
        if( err < 0 ) {
-               snd_printk(KERN_ERR "error starting pipe!\n");
+               dev_err(chip->card->dev, "error starting pipe!\n");
                snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0);
                err = -EINVAL;
                goto _exit_open;
@@ -792,14 +821,17 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
 
        runtime->hw.channels_min = 2; /* for instance, no mono */
 
-       snd_printdd("snd_mixart_capture_open C%d/P%d/Sub%d\n", chip->chip_idx, pcm_number, subs->number);
+       dev_dbg(chip->card->dev, "snd_mixart_capture_open C%d/P%d/Sub%d\n",
+               chip->chip_idx, pcm_number, subs->number);
 
        /* get stream info */
        stream = &(chip->capture_stream[pcm_number]);
 
        if (stream->status != MIXART_STREAM_STATUS_FREE){
                /* streams in use */
-               snd_printk(KERN_ERR "snd_mixart_capture_open C%d/P%d/Sub%d in use\n", chip->chip_idx, pcm_number, subs->number);
+               dev_err(chip->card->dev,
+                       "snd_mixart_capture_open C%d/P%d/Sub%d in use\n",
+                       chip->chip_idx, pcm_number, subs->number);
                err = -EBUSY;
                goto _exit_open;
        }
@@ -815,7 +847,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
        /* start the pipe if necessary */
        err = mixart_set_pipe_state(chip->mgr, pipe, 1);
        if( err < 0 ) {
-               snd_printk(KERN_ERR "error starting pipe!\n");
+               dev_err(chip->card->dev, "error starting pipe!\n");
                snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0);
                err = -EINVAL;
                goto _exit_open;
@@ -855,7 +887,8 @@ static int snd_mixart_close(struct snd_pcm_substream *subs)
 
        mutex_lock(&mgr->setup_mutex);
 
-       snd_printdd("snd_mixart_close C%d/P%d/Sub%d\n", chip->chip_idx, stream->pcm_number, subs->number);
+       dev_dbg(chip->card->dev, "snd_mixart_close C%d/P%d/Sub%d\n",
+               chip->chip_idx, stream->pcm_number, subs->number);
 
        /* sample rate released */
        if(--mgr->ref_count_rate == 0) {
@@ -865,7 +898,9 @@ static int snd_mixart_close(struct snd_pcm_substream *subs)
        /* delete pipe */
        if (snd_mixart_kill_ref_pipe(mgr, stream->pipe, 0 ) < 0) {
 
-               snd_printk(KERN_ERR "error snd_mixart_kill_ref_pipe C%dP%d\n", chip->chip_idx, stream->pcm_number);
+               dev_err(chip->card->dev,
+                       "error snd_mixart_kill_ref_pipe C%dP%d\n",
+                       chip->chip_idx, stream->pcm_number);
        }
 
        stream->pipe      = NULL;
@@ -940,7 +975,8 @@ static int snd_mixart_pcm_analog(struct snd_mixart *chip)
        if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG,
                               MIXART_PLAYBACK_STREAMS,
                               MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
-               snd_printk(KERN_ERR "cannot create the analog pcm %d\n", chip->chip_idx);
+               dev_err(chip->card->dev,
+                       "cannot create the analog pcm %d\n", chip->chip_idx);
                return err;
        }
 
@@ -971,7 +1007,8 @@ static int snd_mixart_pcm_digital(struct snd_mixart *chip)
        if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL,
                               MIXART_PLAYBACK_STREAMS,
                               MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
-               snd_printk(KERN_ERR "cannot create the digital pcm %d\n", chip->chip_idx);
+               dev_err(chip->card->dev,
+                       "cannot create the digital pcm %d\n", chip->chip_idx);
                return err;
        }
 
@@ -1014,7 +1051,7 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int
 
        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (! chip) {
-               snd_printk(KERN_ERR "cannot allocate chip\n");
+               dev_err(card->dev, "cannot allocate chip\n");
                return -ENOMEM;
        }
 
@@ -1028,8 +1065,6 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int
        }
 
        mgr->chip[idx] = chip;
-       snd_card_set_dev(card, &mgr->pci->dev);
-
        return 0;
 }
 
@@ -1073,7 +1108,7 @@ static int snd_mixart_free(struct mixart_mgr *mgr)
        /* reset board if some firmware was loaded */
        if(mgr->dsp_loaded) {
                snd_mixart_reset_board(mgr);
-               snd_printdd("reset miXart !\n");
+               dev_dbg(&mgr->pci->dev, "reset miXart !\n");
        }
 
        /* release the i/o ports */
@@ -1234,7 +1269,8 @@ static int snd_mixart_probe(struct pci_dev *pci,
 
        /* check if we can restrict PCI DMA transfers to 32 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
+               dev_err(&pci->dev,
+                       "architecture does not support 32bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -1260,7 +1296,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
                mgr->mem[i].phys = pci_resource_start(pci, i);
                mgr->mem[i].virt = pci_ioremap_bar(pci, i);
                if (!mgr->mem[i].virt) {
-                       printk(KERN_ERR "unable to remap resource 0x%lx\n",
+                       dev_err(&pci->dev, "unable to remap resource 0x%lx\n",
                               mgr->mem[i].phys);
                        snd_mixart_free(mgr);
                        return -EBUSY;
@@ -1269,7 +1305,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
 
        if (request_irq(pci->irq, snd_mixart_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, mgr)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_mixart_free(mgr);
                return -EBUSY;
        }
@@ -1308,10 +1344,11 @@ static int snd_mixart_probe(struct pci_dev *pci,
                else
                        idx = index[dev] + i;
                snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
-               err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card);
+               err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
+                                  0, &card);
 
                if (err < 0) {
-                       snd_printk(KERN_ERR "cannot allocate the card %d\n", i);
+                       dev_err(&pci->dev, "cannot allocate the card %d\n", i);
                        snd_mixart_free(mgr);
                        return err;
                }
index 3df0f530f67c0df6626659c8ad45700b670114c1..71f4bdcc4055fbec2aa37317a5a8d2e1c16bc123 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
+#include <linux/pci.h>
 
 #include <asm/io.h>
 #include <sound/core.h>
@@ -94,7 +95,8 @@ static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
 
        if( (size < MSG_DESCRIPTOR_SIZE) || (resp->size < (size - MSG_DESCRIPTOR_SIZE))) {
                err = -EINVAL;
-               snd_printk(KERN_ERR "problem with response size = %d\n", size);
+               dev_err(&mgr->pci->dev,
+                       "problem with response size = %d\n", size);
                goto _clean_exit;
        }
        size -= MSG_DESCRIPTOR_SIZE;
@@ -161,7 +163,7 @@ static int send_msg( struct mixart_mgr *mgr,
        headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_HEAD));
 
        if (tailptr == headptr) {
-               snd_printk(KERN_ERR "error: no message frame available\n");
+               dev_err(&mgr->pci->dev, "error: no message frame available\n");
                return -EBUSY;
        }
 
@@ -265,7 +267,8 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
        if (! timeout) {
                /* error - no ack */
                mutex_unlock(&mgr->msg_mutex);
-               snd_printk(KERN_ERR "error: no response on msg %x\n", msg_frame);
+               dev_err(&mgr->pci->dev,
+                       "error: no response on msg %x\n", msg_frame);
                return -EIO;
        }
 
@@ -278,7 +281,7 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
        err = get_msg(mgr, &resp, msg_frame);
 
        if( request->message_id != resp.message_id )
-               snd_printk(KERN_ERR "RESPONSE ERROR!\n");
+               dev_err(&mgr->pci->dev, "RESPONSE ERROR!\n");
 
        mutex_unlock(&mgr->msg_mutex);
        return err;
@@ -321,7 +324,8 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
        if (! timeout) {
                /* error - no ack */
                mutex_unlock(&mgr->msg_mutex);
-               snd_printk(KERN_ERR "error: notification %x not received\n", notif_event);
+               dev_err(&mgr->pci->dev,
+                       "error: notification %x not received\n", notif_event);
                return -EIO;
        }
 
@@ -378,7 +382,9 @@ void snd_mixart_msg_tasklet(unsigned long arg)
                        resp.size = sizeof(mixart_msg_data);
                        err = get_msg(mgr, &resp, addr);
                        if( err < 0 ) {
-                               snd_printk(KERN_ERR "tasklet: error(%d) reading mf %x\n", err, msg);
+                               dev_err(&mgr->pci->dev,
+                                       "tasklet: error(%d) reading mf %x\n",
+                                       err, msg);
                                break;
                        }
 
@@ -388,10 +394,13 @@ void snd_mixart_msg_tasklet(unsigned long arg)
                        case MSG_STREAM_STOP_INPUT_STAGE_PACKET:
                        case MSG_STREAM_STOP_OUTPUT_STAGE_PACKET:
                                if(mixart_msg_data[0])
-                                       snd_printk(KERN_ERR "tasklet : error MSG_STREAM_ST***_***PUT_STAGE_PACKET status=%x\n", mixart_msg_data[0]);
+                                       dev_err(&mgr->pci->dev,
+                                               "tasklet : error MSG_STREAM_ST***_***PUT_STAGE_PACKET status=%x\n",
+                                               mixart_msg_data[0]);
                                break;
                        default:
-                               snd_printdd("tasklet received mf(%x) : msg_id(%x) uid(%x, %x) size(%zd)\n",
+                               dev_dbg(&mgr->pci->dev,
+                                       "tasklet received mf(%x) : msg_id(%x) uid(%x, %x) size(%zd)\n",
                                           msg, resp.message_id, resp.uid.object_id, resp.uid.desc, resp.size);
                                break;
                        }
@@ -401,7 +410,9 @@ void snd_mixart_msg_tasklet(unsigned long arg)
                case MSG_TYPE_COMMAND:
                        /* get_msg() necessary */
                default:
-                       snd_printk(KERN_ERR "tasklet doesn't know what to do with message %x\n", msg);
+                       dev_err(&mgr->pci->dev,
+                               "tasklet doesn't know what to do with message %x\n",
+                               msg);
                } /* switch type */
 
                /* decrement counter */
@@ -451,7 +462,9 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
                        resp.size = sizeof(mixart_msg_data);
                        err = get_msg(mgr, &resp, msg & ~MSG_TYPE_MASK);
                        if( err < 0 ) {
-                               snd_printk(KERN_ERR "interrupt: error(%d) reading mf %x\n", err, msg);
+                               dev_err(&mgr->pci->dev,
+                                       "interrupt: error(%d) reading mf %x\n",
+                                       err, msg);
                                break;
                        }
 
@@ -472,7 +485,8 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
                                        struct mixart_stream *stream;
 
                                        if ((chip_number >= mgr->num_cards) || (pcm_number >= MIXART_PCM_TOTAL) || (sub_number >= MIXART_PLAYBACK_STREAMS)) {
-                                               snd_printk(KERN_ERR "error MSG_SERVICES_TIMER_NOTIFY buffer_id (%x) pos(%d)\n",
+                                               dev_err(&mgr->pci->dev,
+                                                       "error MSG_SERVICES_TIMER_NOTIFY buffer_id (%x) pos(%d)\n",
                                                           buffer_id, notify->streams[i].sample_pos_low_part);
                                                break;
                                        }
@@ -524,18 +538,22 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
                                        }
 #endif
                                        ((char*)mixart_msg_data)[resp.size - 1] = 0;
-                                       snd_printdd("MIXART TRACE : %s\n", (char*)mixart_msg_data);
+                                       dev_dbg(&mgr->pci->dev,
+                                               "MIXART TRACE : %s\n",
+                                               (char *)mixart_msg_data);
                                }
                                break;
                        }
 
-                       snd_printdd("command %x not handled\n", resp.message_id);
+                       dev_dbg(&mgr->pci->dev, "command %x not handled\n",
+                               resp.message_id);
                        break;
 
                case MSG_TYPE_NOTIFY:
                        if(msg & MSG_CANCEL_NOTIFY_MASK) {
                                msg &= ~MSG_CANCEL_NOTIFY_MASK;
-                               snd_printk(KERN_ERR "canceled notification %x !\n", msg);
+                               dev_err(&mgr->pci->dev,
+                                       "canceled notification %x !\n", msg);
                        }
                        /* no break, continue ! */
                case MSG_TYPE_ANSWER:
@@ -556,7 +574,8 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
                        break;
                case MSG_TYPE_REQUEST:
                default:
-                       snd_printdd("interrupt received request %x\n", msg);
+                       dev_dbg(&mgr->pci->dev,
+                               "interrupt received request %x\n", msg);
                        /* TODO : are there things to do here ? */
                        break;
                } /* switch on msg type */
index ece1f831c16a834c8c0806ea5d5c812bc257f24f..581e1e74863c6471642ea893a4dc77de2419635c 100644 (file)
@@ -165,7 +165,8 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
 
        err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector);
        if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) {
-               snd_printk(KERN_ERR "error MSG_SYSTEM_ENUM_PLAY_CONNECTOR\n");
+               dev_err(&mgr->pci->dev,
+                       "error MSG_SYSTEM_ENUM_PLAY_CONNECTOR\n");
                err = -EINVAL;
                goto __error;
        }
@@ -184,7 +185,7 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
                        pipe->uid_left_connector = connector->uid[k];    /* even */
                }
 
-               /* snd_printk(KERN_DEBUG "playback connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
+               /* dev_dbg(&mgr->pci->dev, "playback connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
 
                /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */
                request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO;
@@ -194,10 +195,11 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
 
                err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info);
                if( err < 0 ) {
-                       snd_printk(KERN_ERR "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
+                       dev_err(&mgr->pci->dev,
+                               "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
                        goto __error;
                }
-               /*snd_printk(KERN_DEBUG "play  analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
+               /*dev_dbg(&mgr->pci->dev, "play  analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
        }
 
        request.message_id = MSG_SYSTEM_ENUM_RECORD_CONNECTOR;
@@ -207,7 +209,8 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
 
        err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector);
        if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) {
-               snd_printk(KERN_ERR "error MSG_SYSTEM_ENUM_RECORD_CONNECTOR\n");
+               dev_err(&mgr->pci->dev,
+                       "error MSG_SYSTEM_ENUM_RECORD_CONNECTOR\n");
                err = -EINVAL;
                goto __error;
        }
@@ -226,7 +229,7 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
                        pipe->uid_left_connector = connector->uid[k];    /* even */
                }
 
-               /* snd_printk(KERN_DEBUG "capture connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
+               /* dev_dbg(&mgr->pci->dev, "capture connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
 
                /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */
                request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO;
@@ -236,10 +239,11 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
 
                err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info);
                if( err < 0 ) {
-                       snd_printk(KERN_ERR "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
+                       dev_err(&mgr->pci->dev,
+                               "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
                        goto __error;
                }
-               /*snd_printk(KERN_DEBUG "rec  analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
+               /*dev_dbg(&mgr->pci->dev, "rec  analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
        }
        err = 0;
 
@@ -272,7 +276,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
        err = snd_mixart_send_msg(mgr, &request, sizeof(console_mgr), &console_mgr);
 
        if( (err < 0) || (console_mgr.error_code != 0) ) {
-               snd_printk(KERN_DEBUG "error MSG_CONSOLE_GET_CLOCK_UID : err=%x\n", console_mgr.error_code);
+               dev_dbg(&mgr->pci->dev,
+                       "error MSG_CONSOLE_GET_CLOCK_UID : err=%x\n",
+                       console_mgr.error_code);
                return -EINVAL;
        }
 
@@ -286,7 +292,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
 
        err = snd_mixart_send_msg(mgr, &request, sizeof(phys_io), &phys_io);
        if( (err < 0) || ( phys_io.error_code != 0 ) ) {
-               snd_printk(KERN_ERR "error MSG_SYSTEM_ENUM_PHYSICAL_IO err(%x) error_code(%x)\n", err, phys_io.error_code );
+               dev_err(&mgr->pci->dev,
+                       "error MSG_SYSTEM_ENUM_PHYSICAL_IO err(%x) error_code(%x)\n",
+                       err, phys_io.error_code);
                return -EINVAL;
        }
 
@@ -322,7 +330,7 @@ static int mixart_first_init(struct mixart_mgr *mgr)
        /* this command has no data. response is a 32 bit status */
        err = snd_mixart_send_msg(mgr, &request, sizeof(k), &k);
        if( (err < 0) || (k != 0) ) {
-               snd_printk(KERN_ERR "error MSG_SYSTEM_SEND_SYNCHRO_CMD\n");
+               dev_err(&mgr->pci->dev, "error MSG_SYSTEM_SEND_SYNCHRO_CMD\n");
                return err == 0 ? -EINVAL : err;
        }
 
@@ -348,7 +356,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
 
        /* motherboard xilinx status 5 will say that the board is performing a reset */
        if (status_xilinx == 5) {
-               snd_printk(KERN_ERR "miXart is resetting !\n");
+               dev_err(&mgr->pci->dev, "miXart is resetting !\n");
                return -EAGAIN; /* try again later */
        }
 
@@ -357,12 +365,13 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
 
                /* xilinx already loaded ? */ 
                if (status_xilinx == 4) {
-                       snd_printk(KERN_DEBUG "xilinx is already loaded !\n");
+                       dev_dbg(&mgr->pci->dev, "xilinx is already loaded !\n");
                        return 0;
                }
                /* the status should be 0 == "idle" */
                if (status_xilinx != 0) {
-                       snd_printk(KERN_ERR "xilinx load error ! status = %d\n",
+                       dev_err(&mgr->pci->dev,
+                               "xilinx load error ! status = %d\n",
                                   status_xilinx);
                        return -EIO; /* modprob -r may help ? */
                }
@@ -393,13 +402,14 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
        case MIXART_MOTHERBOARD_ELF_INDEX:
 
                if (status_elf == 4) {
-                       snd_printk(KERN_DEBUG "elf file already loaded !\n");
+                       dev_dbg(&mgr->pci->dev, "elf file already loaded !\n");
                        return 0;
                }
 
                /* the status should be 0 == "idle" */
                if (status_elf != 0) {
-                       snd_printk(KERN_ERR "elf load error ! status = %d\n",
+                       dev_err(&mgr->pci->dev,
+                               "elf load error ! status = %d\n",
                                   status_elf);
                        return -EIO; /* modprob -r may help ? */
                }
@@ -407,7 +417,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                /* wait for xilinx status == 4 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */
                if (err < 0) {
-                       snd_printk(KERN_ERR "xilinx was not loaded or "
+                       dev_err(&mgr->pci->dev, "xilinx was not loaded or "
                                   "could not be started\n");
                        return err;
                }
@@ -429,7 +439,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                /* wait for elf status == 4 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */
                if (err < 0) {
-                       snd_printk(KERN_ERR "elf could not be started\n");
+                       dev_err(&mgr->pci->dev, "elf could not be started\n");
                        return err;
                }
 
@@ -443,7 +453,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
 
                /* elf and xilinx should be loaded */
                if (status_elf != 4 || status_xilinx != 4) {
-                       printk(KERN_ERR "xilinx or elf not "
+                       dev_err(&mgr->pci->dev, "xilinx or elf not "
                               "successfully loaded\n");
                        return -EIO; /* modprob -r may help ? */
                }
@@ -451,7 +461,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                /* wait for daughter detection != 0 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */
                if (err < 0) {
-                       snd_printk(KERN_ERR "error starting elf file\n");
+                       dev_err(&mgr->pci->dev, "error starting elf file\n");
                        return err;
                }
 
@@ -467,7 +477,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
 
                /* daughter should be idle */
                if (status_daught != 0) {
-                       printk(KERN_ERR "daughter load error ! status = %d\n",
+                       dev_err(&mgr->pci->dev,
+                               "daughter load error ! status = %d\n",
                               status_daught);
                        return -EIO; /* modprob -r may help ? */
                }
@@ -487,7 +498,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                /* wait for status == 2 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */
                if (err < 0) {
-                       snd_printk(KERN_ERR "daughter board load error\n");
+                       dev_err(&mgr->pci->dev, "daughter board load error\n");
                        return err;
                }
 
@@ -509,7 +520,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
         /* wait for daughter status == 3 */
         err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */
         if (err < 0) {
-               snd_printk(KERN_ERR
+               dev_err(&mgr->pci->dev,
                           "daughter board could not be initialised\n");
                return err;
        }
@@ -520,7 +531,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
        /* first communication with embedded */
        err = mixart_first_init(mgr);
         if (err < 0) {
-               snd_printk(KERN_ERR "miXart could not be set up\n");
+               dev_err(&mgr->pci->dev, "miXart could not be set up\n");
                return err;
        }
 
@@ -540,7 +551,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                        return err;
        }
 
-       snd_printdd("miXart firmware downloaded and successfully set up\n");
+       dev_dbg(&mgr->pci->dev,
+               "miXart firmware downloaded and successfully set up\n");
 
        return 0;
 }
@@ -559,7 +571,8 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
        for (i = 0; i < 3; i++) {
                sprintf(path, "mixart/%s", fw_files[i]);
                if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
-                       snd_printk(KERN_ERR "miXart: can't load firmware %s\n", path);
+                       dev_err(&mgr->pci->dev,
+                               "miXart: can't load firmware %s\n", path);
                        return -ENOENT;
                }
                /* fake hwdep dsp record */
index 3ba6174c3df1d80a6d714ddc836b751bbf917bc5..24a1955b8c2963ad0dfd737868a922fad59c3d71 100644 (file)
@@ -329,7 +329,9 @@ static int mixart_update_analog_audio_level(struct snd_mixart* chip, int is_capt
 
        err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
        if((err<0) || (resp.error_code)) {
-               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);
+               dev_dbg(chip->card->dev,
+                       "error MSG_PHYSICALIO_SET_LEVEL card(%d) is_capture(%d) error_code(%x)\n",
+                       chip->chip_idx, is_capture, resp.error_code);
                return -EINVAL;
        }
        return 0;
@@ -762,7 +764,9 @@ int mixart_update_playback_stream_level(struct snd_mixart* chip, int is_aes, int
 
        err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
        if((err<0) || status) {
-               snd_printk(KERN_DEBUG "error MSG_STREAM_SET_OUT_STREAM_LEVEL card(%d) status(%x)\n", chip->chip_idx, status);
+               dev_dbg(chip->card->dev,
+                       "error MSG_STREAM_SET_OUT_STREAM_LEVEL card(%d) status(%x)\n",
+                       chip->chip_idx, status);
                return -EINVAL;
        }
        return 0;
@@ -805,7 +809,9 @@ int mixart_update_capture_stream_level(struct snd_mixart* chip, int is_aes)
 
        err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
        if((err<0) || status) {
-               snd_printk(KERN_DEBUG "error MSG_STREAM_SET_IN_AUDIO_LEVEL card(%d) status(%x)\n", chip->chip_idx, status);
+               dev_dbg(chip->card->dev,
+                       "error MSG_STREAM_SET_IN_AUDIO_LEVEL card(%d) status(%x)\n",
+                       chip->chip_idx, status);
                return -EINVAL;
        }
        return 0;
@@ -977,7 +983,9 @@ static int mixart_update_monitoring(struct snd_mixart* chip, int channel)
 
        err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
        if((err<0) || resp) {
-               snd_printk(KERN_DEBUG "error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d) resp(%x)\n", chip->chip_idx, resp);
+               dev_dbg(chip->card->dev,
+                       "error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d) resp(%x)\n",
+                       chip->chip_idx, resp);
                return -EINVAL;
        }
        return 0;
index fe79fff4c6dc303fd3a5babde6320446979a3f14..ddc60215cc10b3cd2415a30b47830465ff32a1e5 100644 (file)
@@ -318,7 +318,8 @@ snd_nm256_write_buffer(struct nm256 *chip, void *src, int offset, int size)
        offset -= chip->buffer_start;
 #ifdef CONFIG_SND_DEBUG
        if (offset < 0 || offset >= chip->buffer_size) {
-               snd_printk(KERN_ERR "write_buffer invalid offset = %d size = %d\n",
+               dev_err(chip->card->dev,
+                       "write_buffer invalid offset = %d size = %d\n",
                           offset, size);
                return;
        }
@@ -366,7 +367,8 @@ snd_nm256_load_coefficient(struct nm256 *chip, int stream, int number)
                 NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET);
 
        if (snd_nm256_readb(chip, poffset) & 1) {
-               snd_printd("NM256: Engine was enabled while loading coefficients!\n");
+               dev_dbg(chip->card->dev,
+                       "NM256: Engine was enabled while loading coefficients!\n");
                return;
        }
 
@@ -466,7 +468,8 @@ static int snd_nm256_acquire_irq(struct nm256 *chip)
        if (chip->irq < 0) {
                if (request_irq(chip->pci->irq, chip->interrupt, IRQF_SHARED,
                                KBUILD_MODNAME, chip)) {
-                       snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq);
+                       dev_err(chip->card->dev,
+                               "unable to grab IRQ %d\n", chip->pci->irq);
                        mutex_unlock(&chip->irq_mutex);
                        return -EBUSY;
                }
@@ -1039,7 +1042,7 @@ snd_nm256_interrupt(int irq, void *dev_id)
        if (status & NM_MISC_INT_1) {
                status &= ~NM_MISC_INT_1;
                NM_ACK_INT(chip, NM_MISC_INT_1);
-               snd_printd("NM256: Got misc interrupt #1\n");
+               dev_dbg(chip->card->dev, "NM256: Got misc interrupt #1\n");
                snd_nm256_writew(chip, NM_INT_REG, 0x8000);
                cbyte = snd_nm256_readb(chip, 0x400);
                snd_nm256_writeb(chip, 0x400, cbyte | 2);
@@ -1048,14 +1051,15 @@ snd_nm256_interrupt(int irq, void *dev_id)
        if (status & NM_MISC_INT_2) {
                status &= ~NM_MISC_INT_2;
                NM_ACK_INT(chip, NM_MISC_INT_2);
-               snd_printd("NM256: Got misc interrupt #2\n");
+               dev_dbg(chip->card->dev, "NM256: Got misc interrupt #2\n");
                cbyte = snd_nm256_readb(chip, 0x400);
                snd_nm256_writeb(chip, 0x400, cbyte & ~2);
        }
 
        /* Unknown interrupt. */
        if (status) {
-               snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n",
+               dev_dbg(chip->card->dev,
+                       "NM256: Fire in the hole! Unknown status 0x%x\n",
                           status);
                /* Pray. */
                NM_ACK_INT(chip, status);
@@ -1104,7 +1108,7 @@ snd_nm256_interrupt_zx(int irq, void *dev_id)
        if (status & NM2_MISC_INT_1) {
                status &= ~NM2_MISC_INT_1;
                NM2_ACK_INT(chip, NM2_MISC_INT_1);
-               snd_printd("NM256: Got misc interrupt #1\n");
+               dev_dbg(chip->card->dev, "NM256: Got misc interrupt #1\n");
                cbyte = snd_nm256_readb(chip, 0x400);
                snd_nm256_writeb(chip, 0x400, cbyte | 2);
        }
@@ -1112,14 +1116,15 @@ snd_nm256_interrupt_zx(int irq, void *dev_id)
        if (status & NM2_MISC_INT_2) {
                status &= ~NM2_MISC_INT_2;
                NM2_ACK_INT(chip, NM2_MISC_INT_2);
-               snd_printd("NM256: Got misc interrupt #2\n");
+               dev_dbg(chip->card->dev, "NM256: Got misc interrupt #2\n");
                cbyte = snd_nm256_readb(chip, 0x400);
                snd_nm256_writeb(chip, 0x400, cbyte & ~2);
        }
 
        /* Unknown interrupt. */
        if (status) {
-               snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n",
+               dev_dbg(chip->card->dev,
+                       "NM256: Fire in the hole! Unknown status 0x%x\n",
                           status);
                /* Pray. */
                NM2_ACK_INT(chip, status);
@@ -1245,7 +1250,7 @@ snd_nm256_ac97_write(struct snd_ac97 *ac97,
                        return;
                }
        }
-       snd_printd("nm256: ac97 codec not ready..\n");
+       dev_dbg(chip->card->dev, "nm256: ac97 codec not ready..\n");
 }
 
 /* static resolution table */
@@ -1347,7 +1352,8 @@ snd_nm256_peek_for_sig(struct nm256 *chip)
 
        temp = ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16);
        if (temp == NULL) {
-               snd_printk(KERN_ERR "Unable to scan for card signature in video RAM\n");
+               dev_err(chip->card->dev,
+                       "Unable to scan for card signature in video RAM\n");
                return -EBUSY;
        }
 
@@ -1361,12 +1367,14 @@ snd_nm256_peek_for_sig(struct nm256 *chip)
                if (pointer == 0xffffffff ||
                    pointer < chip->buffer_size ||
                    pointer > chip->buffer_end) {
-                       snd_printk(KERN_ERR "invalid signature found: 0x%x\n", pointer);
+                       dev_err(chip->card->dev,
+                               "invalid signature found: 0x%x\n", pointer);
                        iounmap(temp);
                        return -ENODEV;
                } else {
                        pointer_found = pointer;
-                       printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n",
+                       dev_info(chip->card->dev,
+                                "found card signature in video RAM: 0x%x\n",
                               pointer);
                }
        }
@@ -1411,8 +1419,7 @@ static int nm256_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "nm256: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -1520,14 +1527,15 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
        chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE,
                                             card->driver);
        if (chip->res_cport == NULL) {
-               snd_printk(KERN_ERR "memory region 0x%lx (size 0x%x) busy\n",
+               dev_err(card->dev, "memory region 0x%lx (size 0x%x) busy\n",
                           chip->cport_addr, NM_PORT2_SIZE);
                err = -EBUSY;
                goto __error;
        }
        chip->cport = ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE);
        if (chip->cport == NULL) {
-               snd_printk(KERN_ERR "unable to map control port %lx\n", chip->cport_addr);
+               dev_err(card->dev, "unable to map control port %lx\n",
+                       chip->cport_addr);
                err = -ENOMEM;
                goto __error;
        }
@@ -1537,12 +1545,14 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
                pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE);
                if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) {
                        if (! force_ac97) {
-                               printk(KERN_ERR "nm256: no ac97 is found!\n");
-                               printk(KERN_ERR "  force the driver to load by "
-                                      "passing in the module parameter\n");
-                               printk(KERN_ERR "    force_ac97=1\n");
-                               printk(KERN_ERR "  or try sb16, opl3sa2, or "
-                                      "cs423x drivers instead.\n");
+                               dev_err(card->dev,
+                                       "no ac97 is found!\n");
+                               dev_err(card->dev,
+                                       "force the driver to load by passing in the module parameter\n");
+                               dev_err(card->dev,
+                                       " force_ac97=1\n");
+                               dev_err(card->dev,
+                                       "or try sb16, opl3sa2, or cs423x drivers instead.\n");
                                err = -ENXIO;
                                goto __error;
                        }
@@ -1581,14 +1591,14 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
        chip->buffer_start = chip->buffer_end - chip->buffer_size;
        chip->buffer_addr += chip->buffer_start;
 
-       printk(KERN_INFO "nm256: Mapping port 1 from 0x%x - 0x%x\n",
+       dev_info(card->dev, "Mapping port 1 from 0x%x - 0x%x\n",
               chip->buffer_start, chip->buffer_end);
 
        chip->res_buffer = request_mem_region(chip->buffer_addr,
                                              chip->buffer_size,
                                              card->driver);
        if (chip->res_buffer == NULL) {
-               snd_printk(KERN_ERR "nm256: buffer 0x%lx (size 0x%x) busy\n",
+               dev_err(card->dev, "buffer 0x%lx (size 0x%x) busy\n",
                           chip->buffer_addr, chip->buffer_size);
                err = -EBUSY;
                goto __error;
@@ -1596,7 +1606,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
        chip->buffer = ioremap_nocache(chip->buffer_addr, chip->buffer_size);
        if (chip->buffer == NULL) {
                err = -ENOMEM;
-               snd_printk(KERN_ERR "unable to map ring buffer at %lx\n", chip->buffer_addr);
+               dev_err(card->dev, "unable to map ring buffer at %lx\n",
+                       chip->buffer_addr);
                goto __error;
        }
 
@@ -1626,8 +1637,6 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
                goto __error;
 
-       snd_card_set_dev(card, &pci->dev);
-
        *chip_ret = chip;
        return 0;
 
@@ -1660,12 +1669,12 @@ static int snd_nm256_probe(struct pci_dev *pci,
 
        q = snd_pci_quirk_lookup(pci, nm256_quirks);
        if (q) {
-               snd_printdd(KERN_INFO "nm256: Enabled quirk for %s.\n",
+               dev_dbg(&pci->dev, "Enabled quirk for %s.\n",
                            snd_pci_quirk_name(q));
                switch (q->value) {
                case NM_BLACKLISTED:
-                       printk(KERN_INFO "nm256: The device is blacklisted. "
-                              "Loading stopped\n");
+                       dev_info(&pci->dev,
+                                "The device is blacklisted. Loading stopped\n");
                        return -ENODEV;
                case NM_RESET_WORKAROUND_2:
                        reset_workaround_2 = 1;
@@ -1676,7 +1685,7 @@ static int snd_nm256_probe(struct pci_dev *pci,
                }
        }
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -1691,7 +1700,7 @@ static int snd_nm256_probe(struct pci_dev *pci,
                strcpy(card->driver, "NM256XL+");
                break;
        default:
-               snd_printk(KERN_ERR "invalid device id 0x%x\n", pci->device);
+               dev_err(&pci->dev, "invalid device id 0x%x\n", pci->device);
                snd_card_free(card);
                return -EINVAL;
        }
@@ -1714,12 +1723,12 @@ static int snd_nm256_probe(struct pci_dev *pci,
        card->private_data = chip;
 
        if (reset_workaround) {
-               snd_printdd(KERN_INFO "nm256: reset_workaround activated\n");
+               dev_dbg(&pci->dev, "reset_workaround activated\n");
                chip->reset_workaround = 1;
        }
 
        if (reset_workaround_2) {
-               snd_printdd(KERN_INFO "nm256: reset_workaround_2 activated\n");
+               dev_dbg(&pci->dev, "reset_workaround_2 activated\n");
                chip->reset_workaround_2 = 1;
        }
 
index 3274907189febb4b6e3939274417abb58c21ca18..4b8a32c37e3105ef22bce70d881cdbda400ae89a 100644 (file)
@@ -147,7 +147,7 @@ void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
                        return;
                }
        }
-       snd_printk(KERN_ERR "AC'97 write timeout\n");
+       dev_err(chip->card->dev, "AC'97 write timeout\n");
 }
 EXPORT_SYMBOL(oxygen_write_ac97);
 
@@ -179,7 +179,7 @@ u16 oxygen_read_ac97(struct oxygen *chip, unsigned int codec,
                        reg ^= 0xffff;
                }
        }
-       snd_printk(KERN_ERR "AC'97 read timeout on codec %u\n", codec);
+       dev_err(chip->card->dev, "AC'97 read timeout on codec %u\n", codec);
        return 0;
 }
 EXPORT_SYMBOL(oxygen_read_ac97);
@@ -208,7 +208,7 @@ static int oxygen_wait_spi(struct oxygen *chip)
                                                OXYGEN_SPI_BUSY) == 0)
                        return 0;
        }
-       snd_printk(KERN_ERR "oxygen: SPI wait timeout\n");
+       dev_err(chip->card->dev, "oxygen: SPI wait timeout\n");
        return -EIO;
 }
 
@@ -288,5 +288,5 @@ void oxygen_write_eeprom(struct oxygen *chip, unsigned int index, u16 value)
                      & OXYGEN_EEPROM_BUSY))
                        return;
        }
-       snd_printk(KERN_ERR "EEPROM write timeout\n");
+       dev_err(chip->card->dev, "EEPROM write timeout\n");
 }
index b0cb48adddc790c3f87e7a52cdb0431430e13ce2..b67e306024738e3932001e05306708282967e009 100644 (file)
@@ -313,7 +313,7 @@ static void oxygen_restore_eeprom(struct oxygen *chip,
                oxygen_clear_bits8(chip, OXYGEN_MISC,
                                   OXYGEN_MISC_WRITE_PCI_SUBID);
 
-               snd_printk(KERN_INFO "EEPROM ID restored\n");
+               dev_info(chip->card->dev, "EEPROM ID restored\n");
        }
 }
 
@@ -595,7 +595,8 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
        const struct pci_device_id *pci_id;
        int err;
 
-       err = snd_card_create(index, id, owner, sizeof(*chip), &card);
+       err = snd_card_new(&pci->dev, index, id, owner,
+                          sizeof(*chip), &card);
        if (err < 0)
                return err;
 
@@ -616,13 +617,13 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
 
        err = pci_request_regions(pci, DRIVER);
        if (err < 0) {
-               snd_printk(KERN_ERR "cannot reserve PCI resources\n");
+               dev_err(card->dev, "cannot reserve PCI resources\n");
                goto err_pci_enable;
        }
 
        if (!(pci_resource_flags(pci, 0) & IORESOURCE_IO) ||
            pci_resource_len(pci, 0) < OXYGEN_IO_SIZE) {
-               snd_printk(KERN_ERR "invalid PCI I/O range\n");
+               dev_err(card->dev, "invalid PCI I/O range\n");
                err = -ENXIO;
                goto err_pci_regions;
        }
@@ -648,7 +649,6 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
        }
 
        pci_set_master(pci);
-       snd_card_set_dev(card, &pci->dev);
        card->private_free = oxygen_card_free;
 
        configure_pcie_bridge(pci);
@@ -658,7 +658,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
        err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED,
                          KBUILD_MODNAME, chip);
        if (err < 0) {
-               snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq);
+               dev_err(card->dev, "cannot grab interrupt %d\n", pci->irq);
                goto err_card;
        }
        chip->irq = pci->irq;
@@ -796,7 +796,7 @@ static int oxygen_pci_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               snd_printk(KERN_ERR "cannot reenable device");
+               dev_err(dev, "cannot reenable device");
                snd_card_disconnect(card);
                return -EIO;
        }
index 136dac6a396432e687c1915c906e7625249ba846..91d92bc32b75225d75aeb56b1341b8c0a0a328e2 100644 (file)
@@ -120,7 +120,7 @@ void xonar_hdmi_uart_input(struct oxygen *chip)
        if (chip->uart_input_count >= 2 &&
            chip->uart_input[chip->uart_input_count - 2] == 'O' &&
            chip->uart_input[chip->uart_input_count - 1] == 'K') {
-               printk(KERN_DEBUG "message from HDMI chip received:\n");
+               dev_dbg(chip->card->dev, "message from HDMI chip received:\n");
                print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
                                     chip->uart_input, chip->uart_input_count);
                chip->uart_input_count = 0;
index 0ebe7f5916f995a992a227d5ee9fd0755c6c0a87..706b1a42163ff55e8eb4c69d314e6e75de307af9 100644 (file)
@@ -56,9 +56,9 @@ static void xonar_ext_power_gpio_changed(struct oxygen *chip)
        if (has_power != data->has_power) {
                data->has_power = has_power;
                if (has_power) {
-                       snd_printk(KERN_NOTICE "power restored\n");
+                       dev_notice(chip->card->dev, "power restored\n");
                } else {
-                       snd_printk(KERN_CRIT
+                       dev_crit(chip->card->dev,
                                   "Hey! Don't unplug the power cable!\n");
                        /* TODO: stop PCMs */
                }
index d379b284955b23dea2cded6e8efe7e0ba17ccda2..8d09444ff88bd524ef6717e107880e36fa840416 100644 (file)
@@ -284,7 +284,7 @@ static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate,
                        rmh.cmd_len = 3;
                        err = pcxhr_send_msg(mgr, &rmh);
                        if (err < 0) {
-                               snd_printk(KERN_ERR
+                               dev_err(&mgr->pci->dev,
                                           "error CMD_ACCESS_IO_WRITE "
                                           "for PLL register : %x!\n", err);
                                return err;
@@ -357,7 +357,7 @@ static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
                        return err;
        }
        /* set the new frequency */
-       snd_printdd("clock register : set %x\n", val);
+       dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val);
        err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK,
                                          val, changed);
        if (err)
@@ -380,7 +380,7 @@ static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
                mgr->codec_speed = speed;       /* save new codec speed */
        }
 
-       snd_printdd("pcxhr_sub_set_clock to %dHz (realfreq=%d)\n",
+       dev_dbg(&mgr->pci->dev, "pcxhr_sub_set_clock to %dHz (realfreq=%d)\n",
                    rate, realfreq);
        return 0;
 }
@@ -480,7 +480,7 @@ static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr,
        case REG_STATUS_SYNC_192000 :   rate = 192000; break;
        default: rate = 0;
        }
-       snd_printdd("External clock is at %d Hz\n", rate);
+       dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate);
        *sample_rate = rate;
        return 0;
 }
@@ -537,8 +537,8 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream)
 
        err = pcxhr_send_msg(chip->mgr, &rmh);
        if (err)
-               snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state err=%x;\n",
-                          err);
+               dev_err(chip->card->dev,
+                       "ERROR pcxhr_set_stream_state err=%x;\n", err);
        stream->status =
          start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED;
        return err;
@@ -628,7 +628,8 @@ static int pcxhr_set_format(struct pcxhr_stream *stream)
        rmh.cmd[rmh.cmd_len++] = (header & 0xff) << 16;
        err = pcxhr_send_msg(chip->mgr, &rmh);
        if (err)
-               snd_printk(KERN_ERR "ERROR pcxhr_set_format err=%x;\n", err);
+               dev_err(chip->card->dev,
+                       "ERROR pcxhr_set_format err=%x;\n", err);
        return err;
 }
 
@@ -665,7 +666,7 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
        rmh.cmd_len = 4;
        err = pcxhr_send_msg(chip->mgr, &rmh);
        if (err)
-               snd_printk(KERN_ERR
+               dev_err(chip->card->dev,
                           "ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err);
        return err;
 }
@@ -735,11 +736,11 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
        }
        if (capture_mask == 0 && playback_mask == 0) {
                mutex_unlock(&mgr->setup_mutex);
-               snd_printk(KERN_ERR "pcxhr_trigger_tasklet : no pipes\n");
+               dev_err(&mgr->pci->dev, "pcxhr_trigger_tasklet : no pipes\n");
                return;
        }
 
-       snd_printdd("pcxhr_trigger_tasklet : "
+       dev_dbg(&mgr->pci->dev, "pcxhr_trigger_tasklet : "
                    "playback_mask=%x capture_mask=%x\n",
                    playback_mask, capture_mask);
 
@@ -747,7 +748,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
        err = pcxhr_set_pipe_state(mgr,  playback_mask, capture_mask, 0);
        if (err) {
                mutex_unlock(&mgr->setup_mutex);
-               snd_printk(KERN_ERR "pcxhr_trigger_tasklet : "
+               dev_err(&mgr->pci->dev, "pcxhr_trigger_tasklet : "
                           "error stop pipes (P%x C%x)\n",
                           playback_mask, capture_mask);
                return;
@@ -792,7 +793,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
        err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
        if (err) {
                mutex_unlock(&mgr->setup_mutex);
-               snd_printk(KERN_ERR "pcxhr_trigger_tasklet : "
+               dev_err(&mgr->pci->dev, "pcxhr_trigger_tasklet : "
                           "error start pipes (P%x C%x)\n",
                           playback_mask, capture_mask);
                return;
@@ -825,7 +826,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
 
 #ifdef CONFIG_SND_DEBUG_VERBOSE
        do_gettimeofday(&my_tv2);
-       snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n",
+       dev_dbg(&mgr->pci->dev, "***TRIGGER TASKLET*** TIME = %ld (err = %x)\n",
                    (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
 #endif
 }
@@ -902,7 +903,7 @@ static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start)
        }
        err = pcxhr_send_msg(mgr, &rmh);
        if (err < 0)
-               snd_printk(KERN_ERR "error pcxhr_hardware_timer err(%x)\n",
+               dev_err(&mgr->pci->dev, "error pcxhr_hardware_timer err(%x)\n",
                           err);
        return err;
 }
@@ -916,7 +917,8 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
        struct pcxhr_mgr *mgr = chip->mgr;
        int err = 0;
 
-       snd_printdd("pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n",
+       dev_dbg(chip->card->dev,
+               "pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n",
                    subs->runtime->period_size, subs->runtime->periods,
                    subs->runtime->buffer_size);
 
@@ -1025,11 +1027,11 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
        runtime->hw = pcxhr_caps;
 
        if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) {
-               snd_printdd("pcxhr_open playback chip%d subs%d\n",
+               dev_dbg(chip->card->dev, "pcxhr_open playback chip%d subs%d\n",
                            chip->chip_idx, subs->number);
                stream = &chip->playback_stream[subs->number];
        } else {
-               snd_printdd("pcxhr_open capture chip%d subs%d\n",
+               dev_dbg(chip->card->dev, "pcxhr_open capture chip%d subs%d\n",
                            chip->chip_idx, subs->number);
                if (mgr->mono_capture)
                        runtime->hw.channels_max = 1;
@@ -1039,7 +1041,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
        }
        if (stream->status != PCXHR_STREAM_STATUS_FREE){
                /* streams in use */
-               snd_printk(KERN_ERR "pcxhr_open chip%d subs%d in use\n",
+               dev_err(chip->card->dev, "pcxhr_open chip%d subs%d in use\n",
                           chip->chip_idx, subs->number);
                mutex_unlock(&mgr->setup_mutex);
                return -EBUSY;
@@ -1105,7 +1107,7 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
 
        mutex_lock(&mgr->setup_mutex);
 
-       snd_printdd("pcxhr_close chip%d subs%d\n",
+       dev_dbg(chip->card->dev, "pcxhr_close chip%d subs%d\n",
                    chip->chip_idx, subs->number);
 
        /* sample rate released */
@@ -1168,7 +1170,7 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip)
        if ((err = snd_pcm_new(chip->card, name, 0,
                               chip->nb_streams_play,
                               chip->nb_streams_capt, &pcm)) < 0) {
-               snd_printk(KERN_ERR "cannot create pcm %s\n", name);
+               dev_err(chip->card->dev, "cannot create pcm %s\n", name);
                return err;
        }
        pcm->private_data = chip;
@@ -1214,7 +1216,7 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
 
        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (! chip) {
-               snd_printk(KERN_ERR "cannot allocate chip\n");
+               dev_err(card->dev, "cannot allocate chip\n");
                return -ENOMEM;
        }
 
@@ -1239,7 +1241,6 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
        }
 
        mgr->chip[idx] = chip;
-       snd_card_set_dev(card, &mgr->pci->dev);
 
        return 0;
 }
@@ -1488,7 +1489,7 @@ static int pcxhr_free(struct pcxhr_mgr *mgr)
        /* reset board if some firmware was loaded */
        if(mgr->dsp_loaded) {
                pcxhr_reset_board(mgr);
-               snd_printdd("reset pcxhr !\n");
+               dev_dbg(&mgr->pci->dev, "reset pcxhr !\n");
        }
 
        /* release irq  */
@@ -1537,8 +1538,8 @@ static int pcxhr_probe(struct pci_dev *pci,
 
        /* check if we can restrict PCI DMA transfers to 32 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support "
-                          "32bit PCI busmaster DMA\n");
+               dev_err(&pci->dev,
+                       "architecture does not support 32bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -1589,7 +1590,7 @@ static int pcxhr_probe(struct pci_dev *pci,
 
        if (request_irq(pci->irq, pcxhr_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, mgr)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
                pcxhr_free(mgr);
                return -EBUSY;
        }
@@ -1638,10 +1639,11 @@ static int pcxhr_probe(struct pci_dev *pci,
 
                snprintf(tmpid, sizeof(tmpid), "%s-%d",
                         id[dev] ? id[dev] : card_name, i);
-               err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card);
+               err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
+                                  0, &card);
 
                if (err < 0) {
-                       snd_printk(KERN_ERR "cannot allocate the card %d\n", i);
+                       dev_err(card->dev, "cannot allocate the card %d\n", i);
                        pcxhr_free(mgr);
                        return err;
                }
index 37b431b9b69d64fabe211123aea0a44ea589544e..df9371918601e7cfc23874a0324bd3f287bbc6ec 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/firmware.h>
 #include <linux/interrupt.h>
+#include <linux/pci.h>
 #include <asm/io.h>
 #include <sound/core.h>
 #include "pcxhr.h"
@@ -132,14 +133,14 @@ static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg,
                *read = PCXHR_INPB(mgr, reg);
                if ((*read & mask) == bit) {
                        if (i > 100)
-                               snd_printdd("ATTENTION! check_reg(%x) "
-                                           "loopcount=%d\n",
+                               dev_dbg(&mgr->pci->dev,
+                                       "ATTENTION! check_reg(%x) loopcount=%d\n",
                                            reg, i);
                        return 0;
                }
                i++;
        } while (time_after_eq(end_time, jiffies));
-       snd_printk(KERN_ERR
+       dev_err(&mgr->pci->dev,
                   "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=%x\n",
                   reg, mask, *read);
        return -EIO;
@@ -216,7 +217,7 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr,
        err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_CVR,  PCXHR_CVR_HI08_HC, 0,
                                  PCXHR_TIMEOUT_DSP, &reg);
        if (err) {
-               snd_printk(KERN_ERR "pcxhr_send_it_dsp : TIMEOUT CVR\n");
+               dev_err(&mgr->pci->dev, "pcxhr_send_it_dsp : TIMEOUT CVR\n");
                return err;
        }
        if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) {
@@ -227,7 +228,7 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr,
                                          PCXHR_TIMEOUT_DSP,
                                          &reg);
                if (err) {
-                       snd_printk(KERN_ERR
+                       dev_err(&mgr->pci->dev,
                                   "pcxhr_send_it_dsp : TIMEOUT HF5\n");
                        return err;
                }
@@ -294,7 +295,7 @@ int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr,
         */
        if(second) {
                if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) {
-                       snd_printk(KERN_ERR "error loading first xilinx\n");
+                       dev_err(&mgr->pci->dev, "error loading first xilinx\n");
                        return -EINVAL;
                }
                /* activate second xilinx */
@@ -360,7 +361,7 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp)
                                          PCXHR_ISR_HI08_TRDY,
                                          PCXHR_TIMEOUT_DSP, &dummy);
                if (err) {
-                       snd_printk(KERN_ERR
+                       dev_err(&mgr->pci->dev,
                                   "dsp loading error at position %d\n", i);
                        return err;
                }
@@ -396,7 +397,7 @@ int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr,
                msleep(PCXHR_WAIT_DEFAULT);
                PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg);
                msleep(PCXHR_WAIT_DEFAULT);
-               snd_printdd("no need to load eeprom boot\n");
+               dev_dbg(&mgr->pci->dev, "no need to load eeprom boot\n");
                return 0;
        }
        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)
                                          PCXHR_ISR_HI08_RXDF,
                                          PCXHR_TIMEOUT_DSP, &reg);
                if (err) {
-                       snd_printk(KERN_ERR "ERROR RMH stat: "
-                                  "ISR:RXDF=1 (ISR = %x; i=%d )\n",
-                                  reg, i);
+                       dev_err(&mgr->pci->dev,
+                               "ERROR RMH stat: ISR:RXDF=1 (ISR = %x; i=%d )\n",
+                               reg, i);
                        return err;
                }
                /* read data */
@@ -591,13 +592,13 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
                }
 #ifdef CONFIG_SND_DEBUG_VERBOSE
                if (rmh->cmd_idx < CMD_LAST_INDEX)
-                       snd_printdd("    stat[%d]=%x\n", i, data);
+                       dev_dbg(&mgr->pci->dev, "    stat[%d]=%x\n", i, data);
 #endif
                if (i < max_stat_len)
                        rmh->stat[i] = data;
        }
        if (rmh->stat_len > max_stat_len) {
-               snd_printdd("PCXHR : rmh->stat_len=%x too big\n",
+               dev_dbg(&mgr->pci->dev, "PCXHR : rmh->stat_len=%x too big\n",
                            rmh->stat_len);
                rmh->stat_len = max_stat_len;
        }
@@ -615,7 +616,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
                return -EINVAL;
        err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1);
        if (err) {
-               snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n");
+               dev_err(&mgr->pci->dev,
+                       "pcxhr_send_message : ED_DSP_CRASHED\n");
                return err;
        }
        /* wait for chk bit */
@@ -641,7 +643,7 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
                data &= 0xff7fff;       /* MASK_1_WORD_COMMAND */
 #ifdef CONFIG_SND_DEBUG_VERBOSE
        if (rmh->cmd_idx < CMD_LAST_INDEX)
-               snd_printdd("MSG cmd[0]=%x (%s)\n",
+               dev_dbg(&mgr->pci->dev, "MSG cmd[0]=%x (%s)\n",
                            data, cmd_names[rmh->cmd_idx]);
 #endif
 
@@ -671,7 +673,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
                        data = rmh->cmd[i];
 #ifdef CONFIG_SND_DEBUG_VERBOSE
                        if (rmh->cmd_idx < CMD_LAST_INDEX)
-                               snd_printdd("    cmd[%d]=%x\n", i, data);
+                               dev_dbg(&mgr->pci->dev,
+                                       "    cmd[%d]=%x\n", i, data);
 #endif
                        err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR,
                                                  PCXHR_ISR_HI08_TRDY,
@@ -697,14 +700,15 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
                                          PCXHR_ISR_HI08_RXDF,
                                          PCXHR_TIMEOUT_DSP, &reg);
                if (err) {
-                       snd_printk(KERN_ERR "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg);
+                       dev_err(&mgr->pci->dev,
+                               "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg);
                        return err;
                }
                /* read error code */
                data  = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16;
                data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8;
                data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL);
-               snd_printk(KERN_ERR "ERROR RMH(%d): 0x%x\n",
+               dev_err(&mgr->pci->dev, "ERROR RMH(%d): 0x%x\n",
                           rmh->cmd_idx, data);
                err = -EINVAL;
        } else {
@@ -780,7 +784,7 @@ static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr)
         * (PCXHR_PIPE_STATE_CAPTURE_OFFSET)
         */
        start_mask &= 0xffffff;
-       snd_printdd("CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask);
+       dev_dbg(&mgr->pci->dev, "CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask);
        return start_mask;
 }
 
@@ -809,7 +813,7 @@ static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr,
                        }
                        err = pcxhr_send_msg(mgr, &rmh);
                        if (err) {
-                               snd_printk(KERN_ERR
+                               dev_err(&mgr->pci->dev,
                                           "error pipe start "
                                           "(CMD_CAN_START_PIPE) err=%x!\n",
                                           err);
@@ -847,7 +851,7 @@ static int pcxhr_stop_pipes(struct pcxhr_mgr *mgr, int audio_mask)
                        }
                        err = pcxhr_send_msg(mgr, &rmh);
                        if (err) {
-                               snd_printk(KERN_ERR
+                               dev_err(&mgr->pci->dev,
                                           "error pipe stop "
                                           "(CMD_STOP_PIPE) err=%x!\n", err);
                                return err;
@@ -876,7 +880,7 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask)
                                                          1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET));
                        err = pcxhr_send_msg(mgr, &rmh);
                        if (err) {
-                               snd_printk(KERN_ERR
+                               dev_err(&mgr->pci->dev,
                                           "error pipe start "
                                           "(CMD_CONF_PIPE) err=%x!\n", err);
                                return err;
@@ -889,7 +893,7 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask)
        pcxhr_init_rmh(&rmh, CMD_SEND_IRQA);
        err = pcxhr_send_msg(mgr, &rmh);
        if (err) {
-               snd_printk(KERN_ERR
+               dev_err(&mgr->pci->dev,
                           "error pipe start (CMD_SEND_IRQA) err=%x!\n",
                           err);
                return err;
@@ -913,7 +917,8 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
                      (capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET));
        /* current pipe state (playback + record) */
        state = pcxhr_pipes_running(mgr);
-       snd_printdd("pcxhr_set_pipe_state %s (mask %x current %x)\n",
+       dev_dbg(&mgr->pci->dev,
+               "pcxhr_set_pipe_state %s (mask %x current %x)\n",
                    start ? "START" : "STOP", audio_mask, state);
        if (start) {
                /* start only pipes that are not yet started */
@@ -944,7 +949,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
                if ((state & audio_mask) == (start ? audio_mask : 0))
                        break;
                if (++i >= MAX_WAIT_FOR_DSP * 100) {
-                       snd_printk(KERN_ERR "error pipe start/stop\n");
+                       dev_err(&mgr->pci->dev, "error pipe start/stop\n");
                        return -EBUSY;
                }
                udelay(10);                     /* wait 10 microseconds */
@@ -956,7 +961,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
        }
 #ifdef CONFIG_SND_DEBUG_VERBOSE
        do_gettimeofday(&my_tv2);
-       snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n",
+       dev_dbg(&mgr->pci->dev, "***SET PIPE STATE*** TIME = %ld (err = %x)\n",
                    (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
 #endif
        return 0;
@@ -971,7 +976,8 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
 
        spin_lock_irqsave(&mgr->msg_lock, flags);
        if ((mgr->io_num_reg_cont & mask) == value) {
-               snd_printdd("IO_NUM_REG_CONT mask %x already is set to %x\n",
+               dev_dbg(&mgr->pci->dev,
+                       "IO_NUM_REG_CONT mask %x already is set to %x\n",
                            mask, value);
                if (changed)
                        *changed = 0;
@@ -1024,7 +1030,7 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err,
                err = ((err >> 12) & 0xfff);
        if (!err)
                return 0;
-       snd_printdd("CMD_ASYNC : Error %s %s Pipe %d err=%x\n",
+       dev_dbg(&mgr->pci->dev, "CMD_ASYNC : Error %s %s Pipe %d err=%x\n",
                    err_src_name[err_src],
                    is_capture ? "Record" : "Play", pipe, err);
        if (err == 0xe01)
@@ -1045,20 +1051,24 @@ void pcxhr_msg_tasklet(unsigned long arg)
        int i, j;
 
        if (mgr->src_it_dsp & PCXHR_IRQ_FREQ_CHANGE)
-               snd_printdd("TASKLET : PCXHR_IRQ_FREQ_CHANGE event occurred\n");
+               dev_dbg(&mgr->pci->dev,
+                       "TASKLET : PCXHR_IRQ_FREQ_CHANGE event occurred\n");
        if (mgr->src_it_dsp & PCXHR_IRQ_TIME_CODE)
-               snd_printdd("TASKLET : PCXHR_IRQ_TIME_CODE event occurred\n");
+               dev_dbg(&mgr->pci->dev,
+                       "TASKLET : PCXHR_IRQ_TIME_CODE event occurred\n");
        if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY)
-               snd_printdd("TASKLET : PCXHR_IRQ_NOTIFY event occurred\n");
+               dev_dbg(&mgr->pci->dev,
+                       "TASKLET : PCXHR_IRQ_NOTIFY event occurred\n");
        if (mgr->src_it_dsp & (PCXHR_IRQ_FREQ_CHANGE | PCXHR_IRQ_TIME_CODE)) {
                /* clear events FREQ_CHANGE and TIME_CODE */
                pcxhr_init_rmh(prmh, CMD_TEST_IT);
                err = pcxhr_send_msg(mgr, prmh);
-               snd_printdd("CMD_TEST_IT : err=%x, stat=%x\n",
+               dev_dbg(&mgr->pci->dev, "CMD_TEST_IT : err=%x, stat=%x\n",
                            err, prmh->stat[0]);
        }
        if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) {
-               snd_printdd("TASKLET : PCXHR_IRQ_ASYNC event occurred\n");
+               dev_dbg(&mgr->pci->dev,
+                       "TASKLET : PCXHR_IRQ_ASYNC event occurred\n");
 
                pcxhr_init_rmh(prmh, CMD_ASYNC);
                prmh->cmd[0] |= 1;      /* add SEL_ASYNC_EVENTS */
@@ -1066,7 +1076,7 @@ void pcxhr_msg_tasklet(unsigned long arg)
                prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS;
                err = pcxhr_send_msg(mgr, prmh);
                if (err)
-                       snd_printk(KERN_ERR "ERROR pcxhr_msg_tasklet=%x;\n",
+                       dev_err(&mgr->pci->dev, "ERROR pcxhr_msg_tasklet=%x;\n",
                                   err);
                i = 1;
                while (i < prmh->stat_len) {
@@ -1079,7 +1089,8 @@ void pcxhr_msg_tasklet(unsigned long arg)
                        u32 err2;
 
                        if (prmh->stat[i] & 0x800000) { /* if BIT_END */
-                               snd_printdd("TASKLET : End%sPipe %d\n",
+                               dev_dbg(&mgr->pci->dev,
+                                       "TASKLET : End%sPipe %d\n",
                                            is_capture ? "Record" : "Play",
                                            pipe);
                        }
@@ -1136,7 +1147,8 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr,
        hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24;
        hw_sample_count += (u_int64_t)rmh.stat[1];
 
-       snd_printdd("stream %c%d : abs samples real(%llu) timer(%llu)\n",
+       dev_dbg(&mgr->pci->dev,
+               "stream %c%d : abs samples real(%llu) timer(%llu)\n",
                    stream->pipe->is_capture ? 'C' : 'P',
                    stream->substream->number,
                    hw_sample_count,
@@ -1202,7 +1214,7 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr,
                                (u_int32_t)(new_sample_count -
                                            stream->timer_abs_periods);
                } else {
-                       snd_printk(KERN_ERR
+                       dev_err(&mgr->pci->dev,
                                   "ERROR new_sample_count too small ??? %ld\n",
                                   (long unsigned int)new_sample_count);
                }
@@ -1247,33 +1259,39 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
                    (mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) {
                        /* handle dsp counter wraparound without resync */
                        int tmp_diff = dsp_time_diff + PCXHR_DSP_TIME_MASK + 1;
-                       snd_printdd("WARNING DSP timestamp old(%d) new(%d)",
+                       dev_dbg(&mgr->pci->dev,
+                               "WARNING DSP timestamp old(%d) new(%d)",
                                    mgr->dsp_time_last, dsp_time_new);
                        if (tmp_diff > 0 && tmp_diff <= (2*mgr->granularity)) {
-                               snd_printdd("-> timestamp wraparound OK: "
+                               dev_dbg(&mgr->pci->dev,
+                                       "-> timestamp wraparound OK: "
                                            "diff=%d\n", tmp_diff);
                                dsp_time_diff = tmp_diff;
                        } else {
-                               snd_printdd("-> resynchronize all streams\n");
+                               dev_dbg(&mgr->pci->dev,
+                                       "-> resynchronize all streams\n");
                                mgr->dsp_time_err++;
                        }
                }
 #ifdef CONFIG_SND_DEBUG_VERBOSE
                if (dsp_time_diff == 0)
-                       snd_printdd("ERROR DSP TIME NO DIFF time(%d)\n",
+                       dev_dbg(&mgr->pci->dev,
+                               "ERROR DSP TIME NO DIFF time(%d)\n",
                                    dsp_time_new);
                else if (dsp_time_diff >= (2*mgr->granularity))
-                       snd_printdd("ERROR DSP TIME TOO BIG old(%d) add(%d)\n",
+                       dev_dbg(&mgr->pci->dev,
+                               "ERROR DSP TIME TOO BIG old(%d) add(%d)\n",
                                    mgr->dsp_time_last,
                                    dsp_time_new - mgr->dsp_time_last);
                else if (dsp_time_diff % mgr->granularity)
-                       snd_printdd("ERROR DSP TIME increased by %d\n",
+                       dev_dbg(&mgr->pci->dev,
+                               "ERROR DSP TIME increased by %d\n",
                                    dsp_time_diff);
 #endif
                mgr->dsp_time_last = dsp_time_new;
 
                if (timer_toggle == mgr->timer_toggle) {
-                       snd_printdd("ERROR TIMER TOGGLE\n");
+                       dev_dbg(&mgr->pci->dev, "ERROR TIMER TOGGLE\n");
                        mgr->dsp_time_err++;
                }
                mgr->timer_toggle = timer_toggle;
@@ -1308,7 +1326,7 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
        }
 #ifdef CONFIG_SND_DEBUG_VERBOSE
        if (reg & PCXHR_FATAL_DSP_ERR)
-               snd_printdd("FATAL DSP ERROR : %x\n", reg);
+               dev_dbg(&mgr->pci->dev, "FATAL DSP ERROR : %x\n", reg);
 #endif
        spin_unlock(&mgr->lock);
        return IRQ_HANDLED;     /* this device caused the interrupt */
index d995175c1c48c44960071683fd03aff64d260b42..15a8ce5f1f48d84e2a71f1e4557f6fa07bc31279 100644 (file)
@@ -72,7 +72,8 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
        /* test max nb substream per pipe */
        if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS)
                return -EINVAL;
-       snd_printdd("supported formats : playback=%x capture=%x\n",
+       dev_dbg(&mgr->pci->dev,
+               "supported formats : playback=%x capture=%x\n",
                    rmh.stat[2], rmh.stat[3]);
 
        pcxhr_init_rmh(&rmh, CMD_VERSION);
@@ -84,7 +85,8 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
        err = pcxhr_send_msg(mgr, &rmh);
        if (err)
                return err;
-       snd_printdd("PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff,
+       dev_dbg(&mgr->pci->dev,
+               "PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff,
                    (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff);
        mgr->dsp_version = rmh.stat[0];
 
@@ -179,7 +181,7 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr,
                stream_count = PCXHR_PLAYBACK_STREAMS;
                audio_count = 2;        /* always stereo */
        }
-       snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n",
+       dev_dbg(&mgr->pci->dev, "snd_add_ref_pipe pin(%d) pcm%c0\n",
                    pin, is_capture ? 'c' : 'p');
        pipe->is_capture = is_capture;
        pipe->first_audio = pin;
@@ -194,7 +196,7 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr,
        }
        err = pcxhr_send_msg(mgr, &rmh);
        if (err < 0) {
-               snd_printk(KERN_ERR "error pipe allocation "
+               dev_err(&mgr->pci->dev, "error pipe allocation "
                           "(CMD_RES_PIPE) err=%x!\n", err);
                return err;
        }
@@ -222,14 +224,14 @@ static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe)
        /* stop one pipe */
        err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
        if (err < 0)
-               snd_printk(KERN_ERR "error stopping pipe!\n");
+               dev_err(&mgr->pci->dev, "error stopping pipe!\n");
        /* release the pipe */
        pcxhr_init_rmh(&rmh, CMD_FREE_PIPE);
        pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio,
                                  0, 0);
        err = pcxhr_send_msg(mgr, &rmh);
        if (err < 0)
-               snd_printk(KERN_ERR "error pipe release "
+               dev_err(&mgr->pci->dev, "error pipe release "
                           "(CMD_FREE_PIPE) err(%x)\n", err);
        pipe->status = PCXHR_PIPE_UNDEFINED;
        return err;
@@ -289,7 +291,8 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
 {
        int err, card_index;
 
-       snd_printdd("loading dsp [%d] size = %Zd\n", index, dsp->size);
+       dev_dbg(&mgr->pci->dev,
+               "loading dsp [%d] size = %Zd\n", index, dsp->size);
 
        switch (index) {
        case PCXHR_FIRMWARE_XLX_INT_INDEX:
@@ -313,19 +316,19 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
                        return err;
                break;  /* continue with first init */
        default:
-               snd_printk(KERN_ERR "wrong file index\n");
+               dev_err(&mgr->pci->dev, "wrong file index\n");
                return -EFAULT;
        } /* end of switch file index*/
 
        /* first communication with embedded */
        err = pcxhr_init_board(mgr);
         if (err < 0) {
-               snd_printk(KERN_ERR "pcxhr could not be set up\n");
+               dev_err(&mgr->pci->dev, "pcxhr could not be set up\n");
                return err;
        }
        err = pcxhr_config_pipes(mgr);
         if (err < 0) {
-               snd_printk(KERN_ERR "pcxhr pipes could not be set up\n");
+               dev_err(&mgr->pci->dev, "pcxhr pipes could not be set up\n");
                return err;
        }
                /* create devices and mixer in accordance with HW options*/
@@ -344,10 +347,11 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
        }
        err = pcxhr_start_pipes(mgr);
         if (err < 0) {
-               snd_printk(KERN_ERR "pcxhr pipes could not be started\n");
+               dev_err(&mgr->pci->dev, "pcxhr pipes could not be started\n");
                return err;
        }
-       snd_printdd("pcxhr firmware downloaded and successfully set up\n");
+       dev_dbg(&mgr->pci->dev,
+               "pcxhr firmware downloaded and successfully set up\n");
 
        return 0;
 }
@@ -382,7 +386,8 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
                        continue;
                sprintf(path, "pcxhr/%s", fw_files[fw_set][i]);
                if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
-                       snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n",
+                       dev_err(&mgr->pci->dev,
+                               "pcxhr: can't load firmware %s\n",
                                   path);
                        return -ENOENT;
                }
index 84fe57626ebaa256a8581ea0fe345c453fddd421..6a56e5306a6594f5977fcd43d9dc05f3e2cad062 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/pci.h>
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/tlv.h>
@@ -290,7 +291,8 @@ int hr222_sub_init(struct pcxhr_mgr *mgr)
        reg = PCXHR_INPB(mgr, PCXHR_XLX_STATUS);
        if (reg & PCXHR_STAT_MIC_CAPS)
                mgr->board_has_mic = 1; /* microphone available */
-       snd_printdd("MIC input available = %d\n", mgr->board_has_mic);
+       dev_dbg(&mgr->pci->dev,
+               "MIC input available = %d\n", mgr->board_has_mic);
 
        /* reset codec */
        PCXHR_OUTPB(mgr, PCXHR_DSP_RESET,
@@ -405,7 +407,7 @@ int hr222_sub_set_clock(struct pcxhr_mgr *mgr,
 
        hr222_config_akm(mgr, AKM_UNMUTE_CMD);
 
-       snd_printdd("set_clock to %dHz (realfreq=%d pllreg=%x)\n",
+       dev_dbg(&mgr->pci->dev, "set_clock to %dHz (realfreq=%d pllreg=%x)\n",
                    rate, realfreq, pllreg);
        return 0;
 }
@@ -431,13 +433,15 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
                reg = PCXHR_STAT_FREQ_UER1_MASK;
 
        } else {
-               snd_printdd("get_external_clock : type %d not supported\n",
+               dev_dbg(&mgr->pci->dev,
+                       "get_external_clock : type %d not supported\n",
                            clock_type);
                return -EINVAL; /* other clocks not supported */
        }
 
        if ((PCXHR_INPB(mgr, PCXHR_XLX_CSUER) & mask) != mask) {
-               snd_printdd("get_external_clock(%d) = 0 Hz\n", clock_type);
+               dev_dbg(&mgr->pci->dev,
+                       "get_external_clock(%d) = 0 Hz\n", clock_type);
                *sample_rate = 0;
                return 0; /* no external clock locked */
        }
@@ -495,7 +499,7 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
        else
                rate = 0;
 
-       snd_printdd("External clock is at %d Hz (measured %d Hz)\n",
+       dev_dbg(&mgr->pci->dev, "External clock is at %d Hz (measured %d Hz)\n",
                    rate, calc_rate);
        *sample_rate = rate;
        return 0;
@@ -542,7 +546,8 @@ int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable)
 int hr222_update_analog_audio_level(struct snd_pcxhr *chip,
                                    int is_capture, int channel)
 {
-       snd_printdd("hr222_update_analog_audio_level(%s chan=%d)\n",
+       dev_dbg(chip->card->dev,
+               "hr222_update_analog_audio_level(%s chan=%d)\n",
                    is_capture ? "capture" : "playback", channel);
        if (is_capture) {
                int level_l, level_r, level_mic;
@@ -642,7 +647,7 @@ int hr222_iec958_capture_byte(struct snd_pcxhr *chip,
                if (PCXHR_INPB(chip->mgr, PCXHR_XLX_CSUER) & mask)
                        temp |= 1;
        }
-       snd_printdd("read iec958 AES %d byte %d = 0x%x\n",
+       dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n",
                    chip->chip_idx, aes_idx, temp);
        *aes_bits = temp;
        return 0;
@@ -684,7 +689,7 @@ static void hr222_micro_boost(struct pcxhr_mgr *mgr, int level)
 
        PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic);
 
-       snd_printdd("hr222_micro_boost : set %x\n", boost_mask);
+       dev_dbg(&mgr->pci->dev, "hr222_micro_boost : set %x\n", boost_mask);
 }
 
 static 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)
 
        PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic);
 
-       snd_printdd("hr222_phantom_power : set %d\n", power);
+       dev_dbg(&mgr->pci->dev, "hr222_phantom_power : set %d\n", power);
 }
 
 
index fec049344621ef97f922c395e8ff5693e3c48945..95c9571780d8ca5da2df9b28408fb78c8325db38 100644 (file)
@@ -72,7 +72,8 @@ static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip,
        rmh.cmd_len = 3;
        err = pcxhr_send_msg(chip->mgr, &rmh);
        if (err < 0) {
-               snd_printk(KERN_DEBUG "error update_analog_audio_level card(%d)"
+               dev_dbg(chip->card->dev,
+                       "error update_analog_audio_level card(%d)"
                           " is_capture(%d) err(%x)\n",
                           chip->chip_idx, is_capture, err);
                return -EINVAL;
@@ -284,7 +285,7 @@ static int pcxhr_update_playback_stream_level(struct snd_pcxhr* chip, int idx)
 
        err = pcxhr_send_msg(chip->mgr, &rmh);
        if (err < 0) {
-               snd_printk(KERN_DEBUG "error update_playback_stream_level "
+               dev_dbg(chip->card->dev, "error update_playback_stream_level "
                           "card(%d) err(%x)\n", chip->chip_idx, err);
                return -EINVAL;
        }
@@ -335,7 +336,8 @@ static int pcxhr_update_audio_pipe_level(struct snd_pcxhr *chip,
 
        err = pcxhr_send_msg(chip->mgr, &rmh);
        if (err < 0) {
-               snd_printk(KERN_DEBUG "error update_audio_level(%d) err=%x\n",
+               dev_dbg(chip->card->dev,
+                       "error update_audio_level(%d) err=%x\n",
                           chip->chip_idx, err);
                return -EINVAL;
        }
@@ -930,7 +932,7 @@ static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip,
                                temp |= 1;
                }
        }
-       snd_printdd("read iec958 AES %d byte %d = 0x%x\n",
+       dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n",
                    chip->chip_idx, aes_idx, temp);
        *aes_bits = temp;
        return 0;
@@ -992,7 +994,8 @@ static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip,
                        rmh.cmd[0] |= IO_NUM_REG_CUER;
                        rmh.cmd[1] = cmd;
                        rmh.cmd_len = 2;
-                       snd_printdd("write iec958 AES %d byte %d bit %d (cmd %x)\n",
+                       dev_dbg(chip->card->dev,
+                               "write iec958 AES %d byte %d bit %d (cmd %x)\n",
                                    chip->chip_idx, aes_idx, i, cmd);
                        err = pcxhr_send_msg(chip->mgr, &rmh);
                        if (err)
index 56cc891e395e54a17edf0a80b377370b317c628c..b4a8278241b12ffc4d33c82841cccb96a5cafdcf 100644 (file)
@@ -1916,8 +1916,6 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        return 0;
 }
@@ -2086,7 +2084,8 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        err = snd_riptide_create(card, pci, &chip);
index cc26346ae66bf82d6fc4680b56ed4f136ff832ab..cc2f0c1b6484430e04672c2bc7962f6d8b91535d 100644 (file)
@@ -1349,14 +1349,15 @@ static int snd_rme32_create(struct rme32 *rme32)
 
        rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE);
        if (!rme32->iobase) {
-               snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n",
+               dev_err(rme32->card->dev,
+                       "unable to remap memory region 0x%lx-0x%lx\n",
                           rme32->port, rme32->port + RME32_IO_SIZE - 1);
                return -ENOMEM;
        }
 
        if (request_irq(pci->irq, snd_rme32_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, rme32)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(rme32->card->dev, "unable to grab IRQ %d\n", pci->irq);
                return -EBUSY;
        }
        rme32->irq = pci->irq;
@@ -1938,15 +1939,14 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct rme32), &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct rme32), &card);
        if (err < 0)
                return err;
        card->private_free = snd_rme32_card_free;
        rme32 = (struct rme32 *) card->private_data;
        rme32->card = card;
        rme32->pci = pci;
-       snd_card_set_dev(card, &pci->dev);
         if (fullduplex[dev])
                rme32->fullduplex_mode = 1;
        if ((err = snd_rme32_create(rme32)) < 0) {
index 0236363c301f8e12b7f15a218af5fbcdfb06b25c..76169929770dd10b25cc9ef91ecd6f85d2e90d9e 100644 (file)
@@ -240,7 +240,7 @@ struct rme96 {
 
        u8 rev; /* card revision number */
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        u32 playback_pointer;
        u32 capture_pointer;
        void *playback_suspend_buffer;
@@ -1570,7 +1570,7 @@ snd_rme96_free(void *private_data)
                pci_release_regions(rme96->pci);
                rme96->port = 0;
        }
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        vfree(rme96->playback_suspend_buffer);
        vfree(rme96->capture_suspend_buffer);
 #endif
@@ -1609,13 +1609,15 @@ snd_rme96_create(struct rme96 *rme96)
 
        rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
        if (!rme96->iobase) {
-               snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
+               dev_err(rme96->card->dev,
+                       "unable to remap memory region 0x%lx-0x%lx\n",
+                       rme96->port, rme96->port + RME96_IO_SIZE - 1);
                return -ENOMEM;
        }
 
        if (request_irq(pci->irq, snd_rme96_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, rme96)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(rme96->card->dev, "unable to grab IRQ %d\n", pci->irq);
                return -EBUSY;
        }
        rme96->irq = pci->irq;
@@ -2372,13 +2374,12 @@ snd_rme96_create_switches(struct snd_card *card,
  * Card initialisation
  */
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 
-static int
-snd_rme96_suspend(struct pci_dev *pci,
-                 pm_message_t state)
+static int rme96_suspend(struct device *dev)
 {
-       struct snd_card *card = pci_get_drvdata(pci);
+       struct pci_dev *pci = to_pci_dev(dev);
+       struct snd_card *card = dev_get_drvdata(dev);
        struct rme96 *rme96 = card->private_data;
 
        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -2407,15 +2408,15 @@ snd_rme96_suspend(struct pci_dev *pci,
        return 0;
 }
 
-static int
-snd_rme96_resume(struct pci_dev *pci)
+static int rme96_resume(struct device *dev)
 {
-       struct snd_card *card = pci_get_drvdata(pci);
+       struct pci_dev *pci = to_pci_dev(dev);
+       struct snd_card *card = dev_get_drvdata(dev);
        struct rme96 *rme96 = card->private_data;
 
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "rme96: pci_enable_device failed, disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2451,7 +2452,11 @@ snd_rme96_resume(struct pci_dev *pci)
        return 0;
 }
 
-#endif
+static SIMPLE_DEV_PM_OPS(rme96_pm, rme96_suspend, rme96_resume);
+#define RME96_PM_OPS   &rme96_pm
+#else
+#define RME96_PM_OPS   NULL
+#endif /* CONFIG_PM_SLEEP */
 
 static void snd_rme96_card_free(struct snd_card *card)
 {
@@ -2475,31 +2480,30 @@ snd_rme96_probe(struct pci_dev *pci,
                dev++;
                return -ENOENT;
        }
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct rme96), &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct rme96), &card);
        if (err < 0)
                return err;
        card->private_free = snd_rme96_card_free;
        rme96 = card->private_data;
        rme96->card = card;
        rme96->pci = pci;
-       snd_card_set_dev(card, &pci->dev);
        if ((err = snd_rme96_create(rme96)) < 0) {
                snd_card_free(card);
                return err;
        }
        
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        rme96->playback_suspend_buffer = vmalloc(RME96_BUFFER_SIZE);
        if (!rme96->playback_suspend_buffer) {
-               snd_printk(KERN_ERR
+               dev_err(card->dev,
                           "Failed to allocate playback suspend buffer!\n");
                snd_card_free(card);
                return -ENOMEM;
        }
        rme96->capture_suspend_buffer = vmalloc(RME96_BUFFER_SIZE);
        if (!rme96->capture_suspend_buffer) {
-               snd_printk(KERN_ERR
+               dev_err(card->dev,
                           "Failed to allocate capture suspend buffer!\n");
                snd_card_free(card);
                return -ENOMEM;
@@ -2548,10 +2552,9 @@ static struct pci_driver rme96_driver = {
        .id_table = snd_rme96_ids,
        .probe = snd_rme96_probe,
        .remove = snd_rme96_remove,
-#ifdef CONFIG_PM
-       .suspend = snd_rme96_suspend,
-       .resume = snd_rme96_resume,
-#endif
+       .driver = {
+               .pm = RME96_PM_OPS,
+       },
 };
 
 module_pci_driver(rme96_driver);
index bd90c80bb494e7049d830f13a3e6db46395d09cc..4c6f5d1c9882c1e054f0b785995083430cd6be0f 100644 (file)
@@ -675,14 +675,15 @@ static int hdsp_check_for_iobox (struct hdsp *hdsp)
                if (0 == (hdsp_read(hdsp, HDSP_statusRegister) &
                                        HDSP_ConfigError)) {
                        if (i) {
-                               snd_printd("Hammerfall-DSP: IO box found after %d ms\n",
+                               dev_dbg(hdsp->card->dev,
+                                       "IO box found after %d ms\n",
                                                (20 * i));
                        }
                        return 0;
                }
                msleep(20);
        }
-       snd_printk(KERN_ERR "Hammerfall-DSP: no IO box connected!\n");
+       dev_err(hdsp->card->dev, "no IO box connected!\n");
        hdsp->state &= ~HDSP_FirmwareLoaded;
        return -EIO;
 }
@@ -699,13 +700,13 @@ static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops,
                if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError)
                        msleep(delay);
                else {
-                       snd_printd("Hammerfall-DSP: iobox found after %ums!\n",
+                       dev_dbg(hdsp->card->dev, "iobox found after %ums!\n",
                                   i * delay);
                        return 0;
                }
        }
 
-       snd_printk("Hammerfall-DSP: no IO box connected!\n");
+       dev_info(hdsp->card->dev, "no IO box connected!\n");
        hdsp->state &= ~HDSP_FirmwareLoaded;
        return -EIO;
 }
@@ -728,13 +729,14 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
 
        if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
 
-               snd_printk ("Hammerfall-DSP: loading firmware\n");
+               dev_info(hdsp->card->dev, "loading firmware\n");
 
                hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM);
                hdsp_write (hdsp, HDSP_fifoData, 0);
 
                if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
-                       snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n");
+                       dev_info(hdsp->card->dev,
+                                "timeout waiting for download preparation\n");
                        hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200);
                        return -EIO;
                }
@@ -744,7 +746,8 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
                for (i = 0; i < HDSP_FIRMWARE_SIZE / 4; ++i) {
                        hdsp_write(hdsp, HDSP_fifoData, cache[i]);
                        if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) {
-                               snd_printk ("Hammerfall-DSP: timeout during firmware loading\n");
+                               dev_info(hdsp->card->dev,
+                                        "timeout during firmware loading\n");
                                hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200);
                                return -EIO;
                        }
@@ -760,11 +763,12 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
                hdsp->control2_register = 0;
 #endif
                hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
-               snd_printk ("Hammerfall-DSP: finished firmware loading\n");
+               dev_info(hdsp->card->dev, "finished firmware loading\n");
 
        }
        if (hdsp->state & HDSP_InitializationComplete) {
-               snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n");
+               dev_info(hdsp->card->dev,
+                        "firmware loaded from cache, restoring defaults\n");
                spin_lock_irqsave(&hdsp->lock, flags);
                snd_hdsp_set_defaults(hdsp);
                spin_unlock_irqrestore(&hdsp->lock, flags);
@@ -791,7 +795,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
                hdsp_write (hdsp, HDSP_fifoData, 0);
                if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) {
                        hdsp->io_type = Multiface;
-                       snd_printk("Hammerfall-DSP: Multiface found\n");
+                       dev_info(hdsp->card->dev, "Multiface found\n");
                        return 0;
                }
 
@@ -799,7 +803,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
                hdsp_write(hdsp, HDSP_fifoData, 0);
                if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) {
                        hdsp->io_type = Digiface;
-                       snd_printk("Hammerfall-DSP: Digiface found\n");
+                       dev_info(hdsp->card->dev, "Digiface found\n");
                        return 0;
                }
 
@@ -808,7 +812,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
                hdsp_write(hdsp, HDSP_fifoData, 0);
                if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) {
                        hdsp->io_type = Multiface;
-                       snd_printk("Hammerfall-DSP: Multiface found\n");
+                       dev_info(hdsp->card->dev, "Multiface found\n");
                        return 0;
                }
 
@@ -817,12 +821,12 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
                hdsp_write(hdsp, HDSP_fifoData, 0);
                if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) {
                        hdsp->io_type = Multiface;
-                       snd_printk("Hammerfall-DSP: Multiface found\n");
+                       dev_info(hdsp->card->dev, "Multiface found\n");
                        return 0;
                }
 
                hdsp->io_type = RPM;
-               snd_printk("Hammerfall-DSP: RPM found\n");
+               dev_info(hdsp->card->dev, "RPM found\n");
                return 0;
        } else {
                /* firmware was already loaded, get iobox type */
@@ -847,20 +851,18 @@ static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand)
                hdsp->state &= ~HDSP_FirmwareLoaded;
                if (! load_on_demand)
                        return -EIO;
-               snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
+               dev_err(hdsp->card->dev, "firmware not present.\n");
                /* try to load firmware */
                if (! (hdsp->state & HDSP_FirmwareCached)) {
                        if (! hdsp_request_fw_loader(hdsp))
                                return 0;
-                       snd_printk(KERN_ERR
-                                  "Hammerfall-DSP: No firmware loaded nor "
-                                  "cached, please upload firmware.\n");
+                       dev_err(hdsp->card->dev,
+                                  "No firmware loaded nor cached, please upload firmware.\n");
                        return -EIO;
                }
                if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
-                       snd_printk(KERN_ERR
-                                  "Hammerfall-DSP: Firmware loading from "
-                                  "cache failed, please upload manually.\n");
+                       dev_err(hdsp->card->dev,
+                                  "Firmware loading from cache failed, please upload manually.\n");
                        return -EIO;
                }
        }
@@ -888,7 +890,8 @@ static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
                udelay (100);
        }
 
-       snd_printk ("Hammerfall-DSP: wait for FIFO status <= %d failed after %d iterations\n",
+       dev_warn(hdsp->card->dev,
+                "wait for FIFO status <= %d failed after %d iterations\n",
                    count, timeout);
        return -1;
 }
@@ -1005,7 +1008,9 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
        default:
                break;
        }
-       snd_printk ("Hammerfall-DSP: unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
+       dev_warn(hdsp->card->dev,
+                "unknown spdif frequency status; bits = 0x%x, status = 0x%x\n",
+                rate_bits, status);
        return 0;
 }
 
@@ -1139,7 +1144,8 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
        if (!(hdsp->control_register & HDSP_ClockModeMaster)) {
                if (called_internally) {
                        /* request from ctl or card initialization */
-                       snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
+                       dev_err(hdsp->card->dev,
+                               "device is not running as a clock master: cannot set sample rate.\n");
                        return -1;
                } else {
                        /* hw_param request while in AutoSync mode */
@@ -1147,11 +1153,14 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
                        int spdif_freq = hdsp_spdif_sample_rate(hdsp);
 
                        if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
-                               snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n");
+                               dev_info(hdsp->card->dev,
+                                        "Detected ADAT in double speed mode\n");
                        else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
-                               snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");
+                               dev_info(hdsp->card->dev,
+                                        "Detected ADAT in quad speed mode\n");
                        else if (rate != external_freq) {
-                               snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n");
+                               dev_info(hdsp->card->dev,
+                                        "No AutoSync source for requested rate\n");
                                return -1;
                        }
                }
@@ -1223,7 +1232,8 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
        }
 
        if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) {
-               snd_printk ("Hammerfall-DSP: cannot change speed mode (capture PID = %d, playback PID = %d)\n",
+               dev_warn(hdsp->card->dev,
+                        "cannot change speed mode (capture PID = %d, playback PID = %d)\n",
                            hdsp->capture_pid,
                            hdsp->playback_pid);
                return -EBUSY;
@@ -3785,7 +3795,8 @@ static int snd_hdsp_initialize_memory(struct hdsp *hdsp)
            snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) {
                if (hdsp->capture_dma_buf.area)
                        snd_dma_free_pages(&hdsp->capture_dma_buf);
-               printk(KERN_ERR "%s: no buffers available\n", hdsp->card_name);
+               dev_err(hdsp->card->dev,
+                       "%s: no buffers available\n", hdsp->card_name);
                return -ENOMEM;
        }
 
@@ -4747,7 +4758,8 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
                        return err;
 
                if (!(hdsp->state & HDSP_FirmwareLoaded)) {
-                       snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n");
+                       dev_err(hdsp->card->dev,
+                               "firmware needs to be uploaded to the card.\n");
                        return -EINVAL;
                }
 
@@ -4858,7 +4870,8 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
                if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded))
                        return -EBUSY;
 
-               snd_printk(KERN_INFO "Hammerfall-DSP: initializing firmware upload\n");
+               dev_info(hdsp->card->dev,
+                        "initializing firmware upload\n");
                firmware = (struct hdsp_firmware __user *)argp;
 
                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
                        snd_hdsp_initialize_midi_flush(hdsp);
 
                        if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
-                               snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
+                               dev_err(hdsp->card->dev,
+                                       "error creating alsa devices\n");
                                return err;
                        }
                }
@@ -4983,7 +4997,8 @@ static int snd_hdsp_enable_io (struct hdsp *hdsp)
        int i;
 
        if (hdsp_fifo_wait (hdsp, 0, 100)) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n");
+               dev_err(hdsp->card->dev,
+                       "enable_io fifo_wait failed\n");
                return -EIO;
        }
 
@@ -5057,25 +5072,29 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
        int err;
 
        if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n");
+               dev_err(card->dev,
+                       "Error creating pcm interface\n");
                return err;
        }
 
 
        if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n");
+               dev_err(card->dev,
+                       "Error creating first midi interface\n");
                return err;
        }
 
        if (hdsp->io_type == Digiface || hdsp->io_type == H9652) {
                if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) {
-                       snd_printk(KERN_ERR "Hammerfall-DSP: Error creating second midi interface\n");
+                       dev_err(card->dev,
+                               "Error creating second midi interface\n");
                        return err;
                }
        }
 
        if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: Error creating ctl interface\n");
+               dev_err(card->dev,
+                       "Error creating ctl interface\n");
                return err;
        }
 
@@ -5088,7 +5107,8 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
        hdsp->playback_substream = NULL;
 
        if ((err = snd_hdsp_set_defaults(hdsp)) < 0) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n");
+               dev_err(card->dev,
+                       "Error setting default values\n");
                return err;
        }
 
@@ -5098,7 +5118,8 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
                        hdsp->port, hdsp->irq);
 
                if ((err = snd_card_register(card)) < 0) {
-                       snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n");
+                       dev_err(card->dev,
+                               "error registering card\n");
                        return err;
                }
                hdsp->state |= HDSP_InitializationComplete;
@@ -5141,16 +5162,19 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
                        fwfile = "digiface_firmware_rev11.bin";
                break;
        default:
-               snd_printk(KERN_ERR "Hammerfall-DSP: invalid io_type %d\n", hdsp->io_type);
+               dev_err(hdsp->card->dev,
+                       "invalid io_type %d\n", hdsp->io_type);
                return -EINVAL;
        }
 
        if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: cannot load firmware %s\n", fwfile);
+               dev_err(hdsp->card->dev,
+                       "cannot load firmware %s\n", fwfile);
                return -ENOENT;
        }
        if (fw->size < HDSP_FIRMWARE_SIZE) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: too short firmware size %d (expected %d)\n",
+               dev_err(hdsp->card->dev,
+                       "too short firmware size %d (expected %d)\n",
                           (int)fw->size, HDSP_FIRMWARE_SIZE);
                return -EINVAL;
        }
@@ -5167,13 +5191,15 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
                        return err;
 
                if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) {
-                       snd_printk(KERN_ERR "Hammerfall-DSP: error creating hwdep device\n");
+                       dev_err(hdsp->card->dev,
+                               "error creating hwdep device\n");
                        return err;
                }
                snd_hdsp_initialize_channels(hdsp);
                snd_hdsp_initialize_midi_flush(hdsp);
                if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
-                       snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
+                       dev_err(hdsp->card->dev,
+                               "error creating alsa devices\n");
                        return err;
                }
        }
@@ -5249,13 +5275,14 @@ static int snd_hdsp_create(struct snd_card *card,
                return err;
        hdsp->port = pci_resource_start(pci, 0);
        if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
+               dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n",
+                       hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
                return -EBUSY;
        }
 
        if (request_irq(pci->irq, snd_hdsp_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, hdsp)) {
-               snd_printk(KERN_ERR "Hammerfall-DSP: unable to use IRQ %d\n", pci->irq);
+               dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq);
                return -EBUSY;
        }
 
@@ -5281,17 +5308,20 @@ static int snd_hdsp_create(struct snd_card *card,
                                   if userspace is not ready for
                                   firmware upload
                                */
-                               snd_printk(KERN_ERR "Hammerfall-DSP: couldn't get firmware from userspace. try using hdsploader\n");
+                               dev_err(hdsp->card->dev,
+                                       "couldn't get firmware from userspace. try using hdsploader\n");
                        else
                                /* init is complete, we return */
                                return 0;
                        /* we defer initialization */
-                       snd_printk(KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n");
+                       dev_info(hdsp->card->dev,
+                                "card initialization pending : waiting for firmware\n");
                        if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
                                return err;
                        return 0;
                } else {
-                       snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");
+                       dev_info(hdsp->card->dev,
+                                "Firmware already present, initializing card.\n");
                        if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2)
                                hdsp->io_type = RPM;
                        else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
@@ -5375,8 +5405,8 @@ static int snd_hdsp_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct hdsp), &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct hdsp), &card);
        if (err < 0)
                return err;
 
@@ -5384,7 +5414,6 @@ static int snd_hdsp_probe(struct pci_dev *pci,
        card->private_free = snd_hdsp_card_free;
        hdsp->dev = dev;
        hdsp->pci = pci;
-       snd_card_set_dev(card, &pci->dev);
 
        if ((err = snd_hdsp_create(card, hdsp)) < 0) {
                snd_card_free(card);
index e98dc008de0b91e4b7e73f776081893fafa04084..cb82b593473a891a04b4969a9f1d49227c399978 100644 (file)
@@ -1651,9 +1651,8 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
                           just make a warning an remember setting
                           for future master mode switching */
 
-                       snd_printk(KERN_WARNING "HDSPM: "
-                                  "Warning: device is not running "
-                                  "as a clock master.\n");
+                       dev_warn(hdspm->card->dev,
+                                "Warning: device is not running as a clock master.\n");
                        not_set = 1;
                } else {
 
@@ -1664,15 +1663,14 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
                        if (hdspm_autosync_ref(hdspm) ==
                            HDSPM_AUTOSYNC_FROM_NONE) {
 
-                               snd_printk(KERN_WARNING "HDSPM: "
-                                          "Detected no Externel Sync \n");
+                               dev_warn(hdspm->card->dev,
+                                        "Detected no Externel Sync\n");
                                not_set = 1;
 
                        } else if (rate != external_freq) {
 
-                               snd_printk(KERN_WARNING "HDSPM: "
-                                          "Warning: No AutoSync source for "
-                                          "requested rate\n");
+                               dev_warn(hdspm->card->dev,
+                                        "Warning: No AutoSync source for requested rate\n");
                                not_set = 1;
                        }
                }
@@ -1738,13 +1736,11 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
 
        if (current_speed != target_speed
            && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) {
-               snd_printk
-                   (KERN_ERR "HDSPM: "
-                    "cannot change from %s speed to %s speed mode "
-                    "(capture PID = %d, playback PID = %d)\n",
-                    hdspm_speed_names[current_speed],
-                    hdspm_speed_names[target_speed],
-                    hdspm->capture_pid, hdspm->playback_pid);
+               dev_err(hdspm->card->dev,
+                       "cannot change from %s speed to %s speed mode (capture PID = %d, playback PID = %d)\n",
+                       hdspm_speed_names[current_speed],
+                       hdspm_speed_names[target_speed],
+                       hdspm->capture_pid, hdspm->playback_pid);
                return -EBUSY;
        }
 
@@ -5446,7 +5442,7 @@ static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id)
         *          0         64     ~3998231       ~8191558
         **/
        /*
-          snd_printk(KERN_INFO "snd_hdspm_interrupt %llu @ %llx\n",
+         dev_info(hdspm->card->dev, "snd_hdspm_interrupt %llu @ %llx\n",
           now-hdspm->last_interrupt, status & 0xFFC0);
           hdspm->last_interrupt = now;
        */
@@ -5583,7 +5579,7 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
        spin_lock_irq(&hdspm->lock);
        err = hdspm_set_rate(hdspm, params_rate(params), 0);
        if (err < 0) {
-               snd_printk(KERN_INFO "err on hdspm_set_rate: %d\n", err);
+               dev_info(hdspm->card->dev, "err on hdspm_set_rate: %d\n", err);
                spin_unlock_irq(&hdspm->lock);
                _snd_pcm_hw_param_setempty(params,
                                SNDRV_PCM_HW_PARAM_RATE);
@@ -5594,7 +5590,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
        err = hdspm_set_interrupt_interval(hdspm,
                        params_period_size(params));
        if (err < 0) {
-               snd_printk(KERN_INFO "err on hdspm_set_interrupt_interval: %d\n", err);
+               dev_info(hdspm->card->dev,
+                        "err on hdspm_set_interrupt_interval: %d\n", err);
                _snd_pcm_hw_param_setempty(params,
                                SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
                return err;
@@ -5610,7 +5607,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
        err =
                snd_pcm_lib_malloc_pages(substream, HDSPM_DMA_AREA_BYTES);
        if (err < 0) {
-               snd_printk(KERN_INFO "err on snd_pcm_lib_malloc_pages: %d\n", err);
+               dev_info(hdspm->card->dev,
+                        "err on snd_pcm_lib_malloc_pages: %d\n", err);
                return err;
        }
 
@@ -5624,7 +5622,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
 
                hdspm->playback_buffer =
                        (unsigned char *) substream->runtime->dma_area;
-               snd_printdd("Allocated sample buffer for playback at %p\n",
+               dev_dbg(hdspm->card->dev,
+                       "Allocated sample buffer for playback at %p\n",
                                hdspm->playback_buffer);
        } else {
                hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferIn,
@@ -5635,18 +5634,21 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
 
                hdspm->capture_buffer =
                        (unsigned char *) substream->runtime->dma_area;
-               snd_printdd("Allocated sample buffer for capture at %p\n",
+               dev_dbg(hdspm->card->dev,
+                       "Allocated sample buffer for capture at %p\n",
                                hdspm->capture_buffer);
        }
 
        /*
-          snd_printdd("Allocated sample buffer for %s at 0x%08X\n",
+          dev_dbg(hdspm->card->dev,
+          "Allocated sample buffer for %s at 0x%08X\n",
           substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
           "playback" : "capture",
           snd_pcm_sgbuf_get_addr(substream, 0));
           */
        /*
-          snd_printdd("set_hwparams: %s %d Hz, %d channels, bs = %d\n",
+          dev_dbg(hdspm->card->dev,
+          "set_hwparams: %s %d Hz, %d channels, bs = %d\n",
           substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
           "playback" : "capture",
           params_rate(params), params_channels(params),
@@ -5667,12 +5669,14 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
        /* Switch to native float format if requested */
        if (SNDRV_PCM_FORMAT_FLOAT_LE == params_format(params)) {
                if (!(hdspm->control_register & HDSPe_FLOAT_FORMAT))
-                       snd_printk(KERN_INFO "hdspm: Switching to native 32bit LE float format.\n");
+                       dev_info(hdspm->card->dev,
+                                "Switching to native 32bit LE float format.\n");
 
                hdspm->control_register |= HDSPe_FLOAT_FORMAT;
        } else if (SNDRV_PCM_FORMAT_S32_LE == params_format(params)) {
                if (hdspm->control_register & HDSPe_FLOAT_FORMAT)
-                       snd_printk(KERN_INFO "hdspm: Switching to native 32bit LE integer format.\n");
+                       dev_info(hdspm->card->dev,
+                                "Switching to native 32bit LE integer format.\n");
 
                hdspm->control_register &= ~HDSPe_FLOAT_FORMAT;
        }
@@ -5715,12 +5719,16 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                if (snd_BUG_ON(info->channel >= hdspm->max_channels_out)) {
-                       snd_printk(KERN_INFO "snd_hdspm_channel_info: output channel out of range (%d)\n", info->channel);
+                       dev_info(hdspm->card->dev,
+                                "snd_hdspm_channel_info: output channel out of range (%d)\n",
+                                info->channel);
                        return -EINVAL;
                }
 
                if (hdspm->channel_map_out[info->channel] < 0) {
-                       snd_printk(KERN_INFO "snd_hdspm_channel_info: output channel %d mapped out\n", info->channel);
+                       dev_info(hdspm->card->dev,
+                                "snd_hdspm_channel_info: output channel %d mapped out\n",
+                                info->channel);
                        return -EINVAL;
                }
 
@@ -5728,12 +5736,16 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
                        HDSPM_CHANNEL_BUFFER_BYTES;
        } else {
                if (snd_BUG_ON(info->channel >= hdspm->max_channels_in)) {
-                       snd_printk(KERN_INFO "snd_hdspm_channel_info: input channel out of range (%d)\n", info->channel);
+                       dev_info(hdspm->card->dev,
+                                "snd_hdspm_channel_info: input channel out of range (%d)\n",
+                                info->channel);
                        return -EINVAL;
                }
 
                if (hdspm->channel_map_in[info->channel] < 0) {
-                       snd_printk(KERN_INFO "snd_hdspm_channel_info: input channel %d mapped out\n", info->channel);
+                       dev_info(hdspm->card->dev,
+                                "snd_hdspm_channel_info: input channel %d mapped out\n",
+                                info->channel);
                        return -EINVAL;
                }
 
@@ -6283,7 +6295,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
 
                s = copy_to_user(argp, levels, sizeof(struct hdspm_peak_rms));
                if (0 != s) {
-                       /* snd_printk(KERN_ERR "copy_to_user(.., .., %lu): %lu
+                       /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu
                         [Levels]\n", sizeof(struct hdspm_peak_rms), s);
                         */
                        return -EFAULT;
@@ -6329,7 +6341,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
                s = copy_to_user(argp, &ltc, sizeof(struct hdspm_ltc));
                if (0 != s) {
                        /*
-                        snd_printk(KERN_ERR "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); */
+                         dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); */
                        return -EFAULT;
                }
 
@@ -6494,11 +6506,13 @@ static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
                                                   wanted,
                                                   wanted);
        if (err < 0) {
-               snd_printdd("Could not preallocate %zd Bytes\n", wanted);
+               dev_dbg(hdspm->card->dev,
+                       "Could not preallocate %zd Bytes\n", wanted);
 
                return err;
        } else
-               snd_printdd(" Preallocated %zd Bytes\n", wanted);
+               dev_dbg(hdspm->card->dev,
+                       " Preallocated %zd Bytes\n", wanted);
 
        return 0;
 }
@@ -6559,7 +6573,7 @@ static int snd_hdspm_create_alsa_devices(struct snd_card *card,
 {
        int err, i;
 
-       snd_printdd("Create card...\n");
+       dev_dbg(card->dev, "Create card...\n");
        err = snd_hdspm_create_pcm(card, hdspm);
        if (err < 0)
                return err;
@@ -6581,7 +6595,7 @@ static int snd_hdspm_create_alsa_devices(struct snd_card *card,
        if (err < 0)
                return err;
 
-       snd_printdd("proc init...\n");
+       dev_dbg(card->dev, "proc init...\n");
        snd_hdspm_proc_init(hdspm);
 
        hdspm->system_sample_rate = -1;
@@ -6592,23 +6606,23 @@ static int snd_hdspm_create_alsa_devices(struct snd_card *card,
        hdspm->capture_substream = NULL;
        hdspm->playback_substream = NULL;
 
-       snd_printdd("Set defaults...\n");
+       dev_dbg(card->dev, "Set defaults...\n");
        err = snd_hdspm_set_defaults(hdspm);
        if (err < 0)
                return err;
 
-       snd_printdd("Update mixer controls...\n");
+       dev_dbg(card->dev, "Update mixer controls...\n");
        hdspm_update_simple_mixer_controls(hdspm);
 
-       snd_printdd("Initializeing complete ???\n");
+       dev_dbg(card->dev, "Initializeing complete ???\n");
 
        err = snd_card_register(card);
        if (err < 0) {
-               snd_printk(KERN_ERR "HDSPM: error registering card\n");
+               dev_err(card->dev, "error registering card\n");
                return err;
        }
 
-       snd_printdd("... yes now\n");
+       dev_dbg(card->dev, "... yes now\n");
 
        return 0;
 }
@@ -6662,8 +6676,8 @@ static int snd_hdspm_create(struct snd_card *card,
                        hdspm->card_name = "RME MADI";
                        hdspm->midiPorts = 3;
                } else {
-                       snd_printk(KERN_ERR
-                               "HDSPM: unknown firmware revision %x\n",
+                       dev_err(card->dev,
+                               "unknown firmware revision %x\n",
                                hdspm->firmware_rev);
                        return -ENODEV;
                }
@@ -6682,36 +6696,35 @@ static int snd_hdspm_create(struct snd_card *card,
        hdspm->port = pci_resource_start(pci, 0);
        io_extent = pci_resource_len(pci, 0);
 
-       snd_printdd("grabbed memory region 0x%lx-0x%lx\n",
+       dev_dbg(card->dev, "grabbed memory region 0x%lx-0x%lx\n",
                        hdspm->port, hdspm->port + io_extent - 1);
 
        hdspm->iobase = ioremap_nocache(hdspm->port, io_extent);
        if (!hdspm->iobase) {
-               snd_printk(KERN_ERR "HDSPM: "
-                               "unable to remap region 0x%lx-0x%lx\n",
+               dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n",
                                hdspm->port, hdspm->port + io_extent - 1);
                return -EBUSY;
        }
-       snd_printdd("remapped region (0x%lx) 0x%lx-0x%lx\n",
+       dev_dbg(card->dev, "remapped region (0x%lx) 0x%lx-0x%lx\n",
                        (unsigned long)hdspm->iobase, hdspm->port,
                        hdspm->port + io_extent - 1);
 
        if (request_irq(pci->irq, snd_hdspm_interrupt,
                        IRQF_SHARED, KBUILD_MODNAME, hdspm)) {
-               snd_printk(KERN_ERR "HDSPM: unable to use IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to use IRQ %d\n", pci->irq);
                return -EBUSY;
        }
 
-       snd_printdd("use IRQ %d\n", pci->irq);
+       dev_dbg(card->dev, "use IRQ %d\n", pci->irq);
 
        hdspm->irq = pci->irq;
 
-       snd_printdd("kmalloc Mixer memory of %zd Bytes\n",
+       dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n",
                        sizeof(struct hdspm_mixer));
        hdspm->mixer = kzalloc(sizeof(struct hdspm_mixer), GFP_KERNEL);
        if (!hdspm->mixer) {
-               snd_printk(KERN_ERR "HDSPM: "
-                               "unable to kmalloc Mixer memory of %d Bytes\n",
+               dev_err(card->dev,
+                       "unable to kmalloc Mixer memory of %d Bytes\n",
                                (int)sizeof(struct hdspm_mixer));
                return -ENOMEM;
        }
@@ -6780,14 +6793,14 @@ static int snd_hdspm_create(struct snd_card *card,
                hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS;
 
                if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBI_D)) {
-                       snd_printk(KERN_INFO "HDSPM: AEB input board found\n");
+                       dev_info(card->dev, "AEB input board found\n");
                        hdspm->ss_in_channels += 4;
                        hdspm->ds_in_channels += 4;
                        hdspm->qs_in_channels += 4;
                }
 
                if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBO_D)) {
-                       snd_printk(KERN_INFO "HDSPM: AEB output board found\n");
+                       dev_info(card->dev, "AEB output board found\n");
                        hdspm->ss_out_channels += 4;
                        hdspm->ds_out_channels += 4;
                        hdspm->qs_out_channels += 4;
@@ -6854,7 +6867,7 @@ static int snd_hdspm_create(struct snd_card *card,
                        if (NULL != hdspm->tco) {
                                hdspm_tco_write(hdspm);
                        }
-                       snd_printk(KERN_INFO "HDSPM: AIO/RayDAT TCO module found\n");
+                       dev_info(card->dev, "AIO/RayDAT TCO module found\n");
                } else {
                        hdspm->tco = NULL;
                }
@@ -6869,7 +6882,7 @@ static int snd_hdspm_create(struct snd_card *card,
                        if (NULL != hdspm->tco) {
                                hdspm_tco_write(hdspm);
                        }
-                       snd_printk(KERN_INFO "HDSPM: MADI/AES TCO module found\n");
+                       dev_info(card->dev, "MADI/AES TCO module found\n");
                } else {
                        hdspm->tco = NULL;
                }
@@ -6951,7 +6964,7 @@ static int snd_hdspm_create(struct snd_card *card,
                }
        }
 
-       snd_printdd("create alsa devices.\n");
+       dev_dbg(card->dev, "create alsa devices.\n");
        err = snd_hdspm_create_alsa_devices(card, hdspm);
        if (err < 0)
                return err;
@@ -7016,8 +7029,8 @@ static int snd_hdspm_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev],
-                       THIS_MODULE, sizeof(struct hdspm), &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev],
+                          THIS_MODULE, sizeof(struct hdspm), &card);
        if (err < 0)
                return err;
 
@@ -7026,8 +7039,6 @@ static int snd_hdspm_probe(struct pci_dev *pci,
        hdspm->dev = dev;
        hdspm->pci = pci;
 
-       snd_card_set_dev(card, &pci->dev);
-
        err = snd_hdspm_create(card, hdspm);
        if (err < 0) {
                snd_card_free(card);
index 1503ee3585fddee141b5df731055325b6a1292cc..1d9be90f774827fb7f8db9a5d60a4e0138b2ef23 100644 (file)
@@ -394,7 +394,9 @@ static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
        if (offset < period_size) {
                if (offset > rme9652->max_jitter) {
                        if (frag)
-                               printk(KERN_ERR "Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n", status, offset);
+                               dev_err(rme9652->card->dev,
+                                       "Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n",
+                                       status, offset);
                } else if (!frag)
                        return 0;
                offset -= rme9652->max_jitter;
@@ -403,7 +405,9 @@ static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
        } else {
                if (offset > period_size + rme9652->max_jitter) {
                        if (!frag)
-                               printk(KERN_ERR "Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n", status, offset);
+                               dev_err(rme9652->card->dev,
+                                       "Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n",
+                                       status, offset);
                } else if (frag)
                        return period_size;
                offset -= rme9652->max_jitter;
@@ -769,7 +773,8 @@ static inline int rme9652_spdif_sample_rate(struct snd_rme9652 *s)
                break;
 
        default:
-               snd_printk(KERN_ERR "%s: unknown S/PDIF input rate (bits = 0x%x)\n",
+               dev_err(s->card->dev,
+                       "%s: unknown S/PDIF input rate (bits = 0x%x)\n",
                           s->card_name, rate_bits);
                return 0;
                break;
@@ -1790,7 +1795,8 @@ static int snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652)
            snd_hammerfall_get_buffer(rme9652->pci, &rme9652->playback_dma_buf, RME9652_DMA_AREA_BYTES) < 0) {
                if (rme9652->capture_dma_buf.area)
                        snd_dma_free_pages(&rme9652->capture_dma_buf);
-               printk(KERN_ERR "%s: no buffers available\n", rme9652->card_name);
+               dev_err(rme9652->card->dev,
+                       "%s: no buffers available\n", rme9652->card_name);
                return -ENOMEM;
        }
 
@@ -2468,13 +2474,14 @@ static int snd_rme9652_create(struct snd_card *card,
        rme9652->port = pci_resource_start(pci, 0);
        rme9652->iobase = ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
        if (rme9652->iobase == NULL) {
-               snd_printk(KERN_ERR "unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
+               dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n",
+                       rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
                return -EBUSY;
        }
        
        if (request_irq(pci->irq, snd_rme9652_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, rme9652)) {
-               snd_printk(KERN_ERR "unable to request IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to request IRQ %d\n", pci->irq);
                return -EBUSY;
        }
        rme9652->irq = pci->irq;
@@ -2587,8 +2594,8 @@ static int snd_rme9652_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_rme9652), &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_rme9652), &card);
 
        if (err < 0)
                return err;
@@ -2597,7 +2604,6 @@ static int snd_rme9652_probe(struct pci_dev *pci,
        card->private_free = snd_rme9652_card_free;
        rme9652->dev = dev;
        rme9652->pci = pci;
-       snd_card_set_dev(card, &pci->dev);
 
        if ((err = snd_rme9652_create(card, rme9652, precise_ptr[dev])) < 0) {
                snd_card_free(card);
index e413b4e2c81952101294d993dba70aee9c1a14fb..6b26b93e001d89fa4c80fe3e6e52e1392b1f2c27 100644 (file)
@@ -1404,8 +1404,6 @@ static int sis_chip_create(struct snd_card *card,
        if (rc)
                goto error_out_cleanup;
 
-       snd_card_set_dev(card, &pci->dev);
-
        return 0;
 
 error_out_cleanup:
@@ -1440,7 +1438,8 @@ static int snd_sis7019_probe(struct pci_dev *pci,
        if (!codecs)
                codecs = SIS_PRIMARY_CODEC_PRESENT;
 
-       rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card);
+       rc = snd_card_new(&pci->dev, index, id, THIS_MODULE,
+                         sizeof(*sis), &card);
        if (rc < 0)
                goto error_out;
 
index 2a46bf98af30f054a20109ada2a17115de05b127..2044dc74207161b6d8951aa7faddcfb3c317f2be 100644 (file)
@@ -273,7 +273,7 @@ static inline void snd_sonicvibes_setdmaa(struct sonicvibes * sonic,
        outl(count, sonic->dmaa_port + SV_DMA_COUNT0);
        outb(0x18, sonic->dmaa_port + SV_DMA_MODE);
 #if 0
-       printk(KERN_DEBUG "program dmaa: addr = 0x%x, paddr = 0x%x\n",
+       dev_dbg(sonic->card->dev, "program dmaa: addr = 0x%x, paddr = 0x%x\n",
               addr, inl(sonic->dmaa_port + SV_DMA_ADDR0));
 #endif
 }
@@ -289,7 +289,7 @@ static inline void snd_sonicvibes_setdmac(struct sonicvibes * sonic,
        outl(count, sonic->dmac_port + SV_DMA_COUNT0);
        outb(0x14, sonic->dmac_port + SV_DMA_MODE);
 #if 0
-       printk(KERN_DEBUG "program dmac: addr = 0x%x, paddr = 0x%x\n",
+       dev_dbg(sonic->card->dev, "program dmac: addr = 0x%x, paddr = 0x%x\n",
               addr, inl(sonic->dmac_port + SV_DMA_ADDR0));
 #endif
 }
@@ -357,105 +357,105 @@ static unsigned char snd_sonicvibes_in(struct sonicvibes * sonic, unsigned char
 #if 0
 static void snd_sonicvibes_debug(struct sonicvibes * sonic)
 {
-       printk(KERN_DEBUG
-              "SV REGS:          INDEX = 0x%02x  ", inb(SV_REG(sonic, INDEX)));
-       printk("                 STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS)));
-       printk(KERN_DEBUG
-              "  0x00: left input      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x00));
-       printk("  0x20: synth rate low  = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20));
-       printk(KERN_DEBUG
-              "  0x01: right input     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x01));
-       printk("  0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21));
-       printk(KERN_DEBUG
-              "  0x02: left AUX1       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x02));
-       printk("  0x22: ADC clock       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22));
-       printk(KERN_DEBUG
-              "  0x03: right AUX1      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x03));
-       printk("  0x23: ADC alt rate    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23));
-       printk(KERN_DEBUG
-              "  0x04: left CD         = 0x%02x  ", snd_sonicvibes_in(sonic, 0x04));
-       printk("  0x24: ADC pll M       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24));
-       printk(KERN_DEBUG
-              "  0x05: right CD        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x05));
-       printk("  0x25: ADC pll N       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25));
-       printk(KERN_DEBUG
-              "  0x06: left line       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x06));
-       printk("  0x26: Synth pll M     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26));
-       printk(KERN_DEBUG
-              "  0x07: right line      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x07));
-       printk("  0x27: Synth pll N     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27));
-       printk(KERN_DEBUG
-              "  0x08: MIC             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x08));
-       printk("  0x28: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28));
-       printk(KERN_DEBUG
-              "  0x09: Game port       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x09));
-       printk("  0x29: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29));
-       printk(KERN_DEBUG
-              "  0x0a: left synth      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0a));
-       printk("  0x2a: MPU401          = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a));
-       printk(KERN_DEBUG
-              "  0x0b: right synth     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0b));
-       printk("  0x2b: drive ctrl      = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b));
-       printk(KERN_DEBUG
-              "  0x0c: left AUX2       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0c));
-       printk("  0x2c: SRS space       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c));
-       printk(KERN_DEBUG
-              "  0x0d: right AUX2      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0d));
-       printk("  0x2d: SRS center      = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d));
-       printk(KERN_DEBUG
-              "  0x0e: left analog     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0e));
-       printk("  0x2e: wave source     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e));
-       printk(KERN_DEBUG
-              "  0x0f: right analog    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0f));
-       printk("  0x2f: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f));
-       printk(KERN_DEBUG
-              "  0x10: left PCM        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x10));
-       printk("  0x30: analog power    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30));
-       printk(KERN_DEBUG
-              "  0x11: right PCM       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x11));
-       printk("  0x31: analog power    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31));
-       printk(KERN_DEBUG
-              "  0x12: DMA data format = 0x%02x  ", snd_sonicvibes_in(sonic, 0x12));
-       printk("  0x32: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32));
-       printk(KERN_DEBUG
-              "  0x13: P/C enable      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x13));
-       printk("  0x33: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33));
-       printk(KERN_DEBUG
-              "  0x14: U/D button      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x14));
-       printk("  0x34: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34));
-       printk(KERN_DEBUG
-              "  0x15: revision        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x15));
-       printk("  0x35: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35));
-       printk(KERN_DEBUG
-              "  0x16: ADC output ctrl = 0x%02x  ", snd_sonicvibes_in(sonic, 0x16));
-       printk("  0x36: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36));
-       printk(KERN_DEBUG
-              "  0x17: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x17));
-       printk("  0x37: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37));
-       printk(KERN_DEBUG
-              "  0x18: DMA A upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x18));
-       printk("  0x38: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38));
-       printk(KERN_DEBUG
-              "  0x19: DMA A lower cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x19));
-       printk("  0x39: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39));
-       printk(KERN_DEBUG
-              "  0x1a: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1a));
-       printk("  0x3a: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a));
-       printk(KERN_DEBUG
-              "  0x1b: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1b));
-       printk("  0x3b: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b));
-       printk(KERN_DEBUG
-              "  0x1c: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1c));
-       printk("  0x3c: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c));
-       printk(KERN_DEBUG
-              "  0x1d: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1d));
-       printk("  0x3d: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d));
-       printk(KERN_DEBUG
-              "  0x1e: PCM rate low    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1e));
-       printk("  0x3e: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e));
-       printk(KERN_DEBUG
-              "  0x1f: PCM rate high   = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1f));
-       printk("  0x3f: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f));
+       dev_dbg(sonic->card->dev,
+               "SV REGS:          INDEX = 0x%02x                   STATUS = 0x%02x\n",
+               inb(SV_REG(sonic, INDEX)), inb(SV_REG(sonic, STATUS)));
+       dev_dbg(sonic->card->dev,
+               "  0x00: left input      = 0x%02x    0x20: synth rate low  = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x00), snd_sonicvibes_in(sonic, 0x20));
+       dev_dbg(sonic->card->dev,
+               "  0x01: right input     = 0x%02x    0x21: synth rate high = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x01), snd_sonicvibes_in(sonic, 0x21));
+       dev_dbg(sonic->card->dev,
+               "  0x02: left AUX1       = 0x%02x    0x22: ADC clock       = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x02), snd_sonicvibes_in(sonic, 0x22));
+       dev_dbg(sonic->card->dev,
+               "  0x03: right AUX1      = 0x%02x    0x23: ADC alt rate    = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x03), snd_sonicvibes_in(sonic, 0x23));
+       dev_dbg(sonic->card->dev,
+               "  0x04: left CD         = 0x%02x    0x24: ADC pll M       = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x04), snd_sonicvibes_in(sonic, 0x24));
+       dev_dbg(sonic->card->dev,
+               "  0x05: right CD        = 0x%02x    0x25: ADC pll N       = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x05), snd_sonicvibes_in(sonic, 0x25));
+       dev_dbg(sonic->card->dev,
+               "  0x06: left line       = 0x%02x    0x26: Synth pll M     = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x06), snd_sonicvibes_in(sonic, 0x26));
+       dev_dbg(sonic->card->dev,
+               "  0x07: right line      = 0x%02x    0x27: Synth pll N     = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x07), snd_sonicvibes_in(sonic, 0x27));
+       dev_dbg(sonic->card->dev,
+               "  0x08: MIC             = 0x%02x    0x28: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x08), snd_sonicvibes_in(sonic, 0x28));
+       dev_dbg(sonic->card->dev,
+               "  0x09: Game port       = 0x%02x    0x29: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x09), snd_sonicvibes_in(sonic, 0x29));
+       dev_dbg(sonic->card->dev,
+               "  0x0a: left synth      = 0x%02x    0x2a: MPU401          = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x0a), snd_sonicvibes_in(sonic, 0x2a));
+       dev_dbg(sonic->card->dev,
+               "  0x0b: right synth     = 0x%02x    0x2b: drive ctrl      = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x0b), snd_sonicvibes_in(sonic, 0x2b));
+       dev_dbg(sonic->card->dev,
+               "  0x0c: left AUX2       = 0x%02x    0x2c: SRS space       = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x0c), snd_sonicvibes_in(sonic, 0x2c));
+       dev_dbg(sonic->card->dev,
+               "  0x0d: right AUX2      = 0x%02x    0x2d: SRS center      = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x0d), snd_sonicvibes_in(sonic, 0x2d));
+       dev_dbg(sonic->card->dev,
+               "  0x0e: left analog     = 0x%02x    0x2e: wave source     = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x0e), snd_sonicvibes_in(sonic, 0x2e));
+       dev_dbg(sonic->card->dev,
+               "  0x0f: right analog    = 0x%02x    0x2f: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x0f), snd_sonicvibes_in(sonic, 0x2f));
+       dev_dbg(sonic->card->dev,
+               "  0x10: left PCM        = 0x%02x    0x30: analog power    = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x10), snd_sonicvibes_in(sonic, 0x30));
+       dev_dbg(sonic->card->dev,
+               "  0x11: right PCM       = 0x%02x    0x31: analog power    = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x11), snd_sonicvibes_in(sonic, 0x31));
+       dev_dbg(sonic->card->dev,
+               "  0x12: DMA data format = 0x%02x    0x32: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x12), snd_sonicvibes_in(sonic, 0x32));
+       dev_dbg(sonic->card->dev,
+               "  0x13: P/C enable      = 0x%02x    0x33: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x13), snd_sonicvibes_in(sonic, 0x33));
+       dev_dbg(sonic->card->dev,
+               "  0x14: U/D button      = 0x%02x    0x34: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x14), snd_sonicvibes_in(sonic, 0x34));
+       dev_dbg(sonic->card->dev,
+               "  0x15: revision        = 0x%02x    0x35: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x15), snd_sonicvibes_in(sonic, 0x35));
+       dev_dbg(sonic->card->dev,
+               "  0x16: ADC output ctrl = 0x%02x    0x36: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x16), snd_sonicvibes_in(sonic, 0x36));
+       dev_dbg(sonic->card->dev,
+               "  0x17: ---             = 0x%02x    0x37: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x17), snd_sonicvibes_in(sonic, 0x37));
+       dev_dbg(sonic->card->dev,
+               "  0x18: DMA A upper cnt = 0x%02x    0x38: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x18), snd_sonicvibes_in(sonic, 0x38));
+       dev_dbg(sonic->card->dev,
+               "  0x19: DMA A lower cnt = 0x%02x    0x39: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x19), snd_sonicvibes_in(sonic, 0x39));
+       dev_dbg(sonic->card->dev,
+               "  0x1a: ---             = 0x%02x    0x3a: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x1a), snd_sonicvibes_in(sonic, 0x3a));
+       dev_dbg(sonic->card->dev,
+               "  0x1b: ---             = 0x%02x    0x3b: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x1b), snd_sonicvibes_in(sonic, 0x3b));
+       dev_dbg(sonic->card->dev,
+               "  0x1c: DMA C upper cnt = 0x%02x    0x3c: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x1c), snd_sonicvibes_in(sonic, 0x3c));
+       dev_dbg(sonic->card->dev,
+               "  0x1d: DMA C upper cnt = 0x%02x    0x3d: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x1d), snd_sonicvibes_in(sonic, 0x3d));
+       dev_dbg(sonic->card->dev,
+               "  0x1e: PCM rate low    = 0x%02x    0x3e: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x1e), snd_sonicvibes_in(sonic, 0x3e));
+       dev_dbg(sonic->card->dev,
+               "  0x1f: PCM rate high   = 0x%02x    0x3f: ---             = 0x%02x\n",
+               snd_sonicvibes_in(sonic, 0x1f), snd_sonicvibes_in(sonic, 0x3f));
 }
 
 #endif
@@ -511,8 +511,10 @@ static void snd_sonicvibes_pll(unsigned int rate,
        *res_m = m;
        *res_n = n;
 #if 0
-       printk(KERN_DEBUG "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
-       printk(KERN_DEBUG "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
+       dev_dbg(sonic->card->dev,
+               "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
+       dev_dbg(sonic->card->dev,
+               "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
 #endif
 }
 
@@ -624,7 +626,8 @@ static irqreturn_t snd_sonicvibes_interrupt(int irq, void *dev_id)
                return IRQ_NONE;
        if (status == 0xff) {   /* failure */
                outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK));
-               snd_printk(KERN_ERR "IRQ failure - interrupts disabled!!\n");
+               dev_err(sonic->card->dev,
+                       "IRQ failure - interrupts disabled!!\n");
                return IRQ_HANDLED;
        }
        if (sonic->pcm) {
@@ -1198,7 +1201,8 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
 
        sonic->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "sonicvibes: cannot allocate memory for gameport\n");
+               dev_err(sonic->card->dev,
+                       "sonicvibes: cannot allocate memory for gameport\n");
                return -ENOMEM;
        }
 
@@ -1267,7 +1271,8 @@ static int snd_sonicvibes_create(struct snd_card *card,
        /* check, if we can restrict PCI DMA transfers to 24 bits */
         if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 24bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                 return -ENXIO;
         }
@@ -1296,7 +1301,7 @@ static int snd_sonicvibes_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_sonicvibes_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, sonic)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_sonicvibes_free(sonic);
                return -EBUSY;
        }
@@ -1310,24 +1315,32 @@ static int snd_sonicvibes_create(struct snd_card *card,
        if (!dmaa) {
                dmaa = dmaio;
                dmaio += 0x10;
-               snd_printk(KERN_INFO "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", dmaa);
+               dev_info(card->dev,
+                        "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n",
+                        dmaa);
        }
        if (!dmac) {
                dmac = dmaio;
                dmaio += 0x10;
-               snd_printk(KERN_INFO "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", dmac);
+               dev_info(card->dev,
+                        "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n",
+                        dmac);
        }
        pci_write_config_dword(pci, 0x40, dmaa);
        pci_write_config_dword(pci, 0x48, dmac);
 
        if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) {
                snd_sonicvibes_free(sonic);
-               snd_printk(KERN_ERR "unable to grab DDMA-A port at 0x%x-0x%x\n", dmaa, dmaa + 0x10 - 1);
+               dev_err(card->dev,
+                       "unable to grab DDMA-A port at 0x%x-0x%x\n",
+                       dmaa, dmaa + 0x10 - 1);
                return -EBUSY;
        }
        if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) {
                snd_sonicvibes_free(sonic);
-               snd_printk(KERN_ERR "unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1);
+               dev_err(card->dev,
+                       "unable to grab DDMA-C port at 0x%x-0x%x\n",
+                       dmac, dmac + 0x10 - 1);
                return -EBUSY;
        }
 
@@ -1392,8 +1405,6 @@ static int snd_sonicvibes_create(struct snd_card *card,
 
        snd_sonicvibes_proc_init(sonic);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rsonic = sonic;
        return 0;
 }
@@ -1459,7 +1470,8 @@ static int snd_sonic_probe(struct pci_dev *pci,
                return -ENOENT;
        }
  
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
        for (idx = 0; idx < 5; idx++) {
index b3b588bc94c37720dd20026589b39ae342a9890d..d852458caf386f651614a375ceac3c0bd27f96cd 100644 (file)
@@ -89,7 +89,8 @@ static int snd_trident_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
index fb0e1586a6f87cc25bbce39a64744e1fea468de5..1272c18a2544364a7d81a1e0d57a10b5c1f36f04 100644 (file)
@@ -69,40 +69,40 @@ static void snd_trident_print_voice_regs(struct snd_trident *trident, int voice)
 {
        unsigned int val, tmp;
 
-       printk(KERN_DEBUG "Trident voice %i:\n", voice);
+       dev_dbg(trident->card->dev, "Trident voice %i:\n", voice);
        outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR));
        val = inl(TRID_REG(trident, CH_LBA));
-       printk(KERN_DEBUG "LBA: 0x%x\n", val);
+       dev_dbg(trident->card->dev, "LBA: 0x%x\n", val);
        val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
-       printk(KERN_DEBUG "GVSel: %i\n", val >> 31);
-       printk(KERN_DEBUG "Pan: 0x%x\n", (val >> 24) & 0x7f);
-       printk(KERN_DEBUG "Vol: 0x%x\n", (val >> 16) & 0xff);
-       printk(KERN_DEBUG "CTRL: 0x%x\n", (val >> 12) & 0x0f);
-       printk(KERN_DEBUG "EC: 0x%x\n", val & 0x0fff);
+       dev_dbg(trident->card->dev, "GVSel: %i\n", val >> 31);
+       dev_dbg(trident->card->dev, "Pan: 0x%x\n", (val >> 24) & 0x7f);
+       dev_dbg(trident->card->dev, "Vol: 0x%x\n", (val >> 16) & 0xff);
+       dev_dbg(trident->card->dev, "CTRL: 0x%x\n", (val >> 12) & 0x0f);
+       dev_dbg(trident->card->dev, "EC: 0x%x\n", val & 0x0fff);
        if (trident->device != TRIDENT_DEVICE_ID_NX) {
                val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS));
-               printk(KERN_DEBUG "CSO: 0x%x\n", val >> 16);
-               printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff);
-               printk(KERN_DEBUG "FMS: 0x%x\n", val & 0x0f);
+               dev_dbg(trident->card->dev, "CSO: 0x%x\n", val >> 16);
+               dev_dbg(trident->card->dev, "Alpha: 0x%x\n", (val >> 4) & 0x0fff);
+               dev_dbg(trident->card->dev, "FMS: 0x%x\n", val & 0x0f);
                val = inl(TRID_REG(trident, CH_DX_ESO_DELTA));
-               printk(KERN_DEBUG "ESO: 0x%x\n", val >> 16);
-               printk(KERN_DEBUG "Delta: 0x%x\n", val & 0xffff);
+               dev_dbg(trident->card->dev, "ESO: 0x%x\n", val >> 16);
+               dev_dbg(trident->card->dev, "Delta: 0x%x\n", val & 0xffff);
                val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL));
        } else {                // TRIDENT_DEVICE_ID_NX
                val = inl(TRID_REG(trident, CH_NX_DELTA_CSO));
                tmp = (val >> 24) & 0xff;
-               printk(KERN_DEBUG "CSO: 0x%x\n", val & 0x00ffffff);
+               dev_dbg(trident->card->dev, "CSO: 0x%x\n", val & 0x00ffffff);
                val = inl(TRID_REG(trident, CH_NX_DELTA_ESO));
                tmp |= (val >> 16) & 0xff00;
-               printk(KERN_DEBUG "Delta: 0x%x\n", tmp);
-               printk(KERN_DEBUG "ESO: 0x%x\n", val & 0x00ffffff);
+               dev_dbg(trident->card->dev, "Delta: 0x%x\n", tmp);
+               dev_dbg(trident->card->dev, "ESO: 0x%x\n", val & 0x00ffffff);
                val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL));
-               printk(KERN_DEBUG "Alpha: 0x%x\n", val >> 20);
-               printk(KERN_DEBUG "FMS: 0x%x\n", (val >> 16) & 0x0f);
+               dev_dbg(trident->card->dev, "Alpha: 0x%x\n", val >> 20);
+               dev_dbg(trident->card->dev, "FMS: 0x%x\n", (val >> 16) & 0x0f);
        }
-       printk(KERN_DEBUG "FMC: 0x%x\n", (val >> 14) & 3);
-       printk(KERN_DEBUG "RVol: 0x%x\n", (val >> 7) & 0x7f);
-       printk(KERN_DEBUG "CVol: 0x%x\n", val & 0x7f);
+       dev_dbg(trident->card->dev, "FMC: 0x%x\n", (val >> 14) & 3);
+       dev_dbg(trident->card->dev, "RVol: 0x%x\n", (val >> 7) & 0x7f);
+       dev_dbg(trident->card->dev, "CVol: 0x%x\n", val & 0x7f);
 }
 #endif
 
@@ -156,7 +156,8 @@ static unsigned short snd_trident_codec_read(struct snd_ac97 *ac97, unsigned sho
        }
 
        if (count == 0 && !trident->ac97_detect) {
-               snd_printk(KERN_ERR "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n",
+               dev_err(trident->card->dev,
+                       "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n",
                           reg, data);
                data = 0;
        }
@@ -497,16 +498,16 @@ void snd_trident_write_voice_regs(struct snd_trident * trident,
        outl(regs[4], TRID_REG(trident, CH_START + 16));
 
 #if 0
-       printk(KERN_DEBUG "written %i channel:\n", voice->number);
-       printk(KERN_DEBUG "  regs[0] = 0x%x/0x%x\n",
+       dev_dbg(trident->card->dev, "written %i channel:\n", voice->number);
+       dev_dbg(trident->card->dev, "  regs[0] = 0x%x/0x%x\n",
               regs[0], inl(TRID_REG(trident, CH_START + 0)));
-       printk(KERN_DEBUG "  regs[1] = 0x%x/0x%x\n",
+       dev_dbg(trident->card->dev, "  regs[1] = 0x%x/0x%x\n",
               regs[1], inl(TRID_REG(trident, CH_START + 4)));
-       printk(KERN_DEBUG "  regs[2] = 0x%x/0x%x\n",
+       dev_dbg(trident->card->dev, "  regs[2] = 0x%x/0x%x\n",
               regs[2], inl(TRID_REG(trident, CH_START + 8)));
-       printk(KERN_DEBUG "  regs[3] = 0x%x/0x%x\n",
+       dev_dbg(trident->card->dev, "  regs[3] = 0x%x/0x%x\n",
               regs[3], inl(TRID_REG(trident, CH_START + 12)));
-       printk(KERN_DEBUG "  regs[4] = 0x%x/0x%x\n",
+       dev_dbg(trident->card->dev, "  regs[4] = 0x%x/0x%x\n",
               regs[4], inl(TRID_REG(trident, CH_START + 16)));
 #endif
 }
@@ -589,7 +590,7 @@ static void snd_trident_write_vol_reg(struct snd_trident * trident,
                outb(voice->Vol >> 2, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 2));
                break;
        case TRIDENT_DEVICE_ID_SI7018:
-               /* printk(KERN_DEBUG "voice->Vol = 0x%x\n", voice->Vol); */
+               /* dev_dbg(trident->card->dev, "voice->Vol = 0x%x\n", voice->Vol); */
                outw((voice->CTRL << 12) | voice->Vol,
                     TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
                break;
@@ -3013,13 +3014,15 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
                _ac97.num = 1;
                err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97_sec);
                if (err < 0)
-                       snd_printk(KERN_ERR "SI7018: the secondary codec - invalid access\n");
+                       dev_err(trident->card->dev,
+                               "SI7018: the secondary codec - invalid access\n");
 #if 0  // only for my testing purpose --jk
                {
                        struct snd_ac97 *mc97;
                        err = snd_ac97_modem(trident->card, &_ac97, &mc97);
                        if (err < 0)
-                               snd_printk(KERN_ERR "snd_ac97_modem returned error %i\n", err);
+                               dev_err(trident->card->dev,
+                                       "snd_ac97_modem returned error %i\n", err);
                }
 #endif
        }
@@ -3197,7 +3200,8 @@ int snd_trident_create_gameport(struct snd_trident *chip)
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "trident: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                return -ENOMEM;
        }
 
@@ -3270,7 +3274,8 @@ static int snd_trident_sis_reset(struct snd_trident *trident)
                        goto __si7018_ok;
                do_delay(trident);
        } while (time_after_eq(end_time, jiffies));
-       snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL)));
+       dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n",
+               inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL)));
        if (r-- > 0) {
                end_time = jiffies + HZ;
                do {
@@ -3367,7 +3372,7 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident)
 
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
                                2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) {
-               snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n");
+               dev_err(trident->card->dev, "unable to allocate TLB buffer\n");
                return -ENOMEM;
        }
        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)
        /* allocate shadow TLB page table (virtual addresses) */
        trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
        if (trident->tlb.shadow_entries == NULL) {
-               snd_printk(KERN_ERR "trident: unable to allocate shadow TLB entries\n");
+               dev_err(trident->card->dev,
+                       "unable to allocate shadow TLB entries\n");
                return -ENOMEM;
        }
        /* allocate and setup silent page and initialise TLB entries */
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
                                SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) {
-               snd_printk(KERN_ERR "trident: unable to allocate silent page\n");
+               dev_err(trident->card->dev, "unable to allocate silent page\n");
                return -ENOMEM;
        }
        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)
                        goto __dx_ok;
                do_delay(trident);
        } while (time_after_eq(end_time, jiffies));
-       snd_printk(KERN_ERR "AC'97 codec ready error\n");
+       dev_err(trident->card->dev, "AC'97 codec ready error\n");
        return -EIO;
 
  __dx_ok:
@@ -3477,7 +3483,8 @@ static int snd_trident_4d_nx_init(struct snd_trident *trident)
                        goto __nx_ok;
                do_delay(trident);
        } while (time_after_eq(end_time, jiffies));
-       snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)));
+       dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n",
+               inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)));
        return -EIO;
 
  __nx_ok:
@@ -3562,7 +3569,8 @@ int snd_trident_create(struct snd_card *card,
        /* check, if we can restrict PCI DMA transfers to 30 bits */
        if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 ||
            pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
-               snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n");
+               dev_err(card->dev,
+                       "architecture does not support 30bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
        }
@@ -3600,7 +3608,7 @@ int snd_trident_create(struct snd_card *card,
 
        if (request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, trident)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_trident_free(trident);
                return -EBUSY;
        }
@@ -3664,7 +3672,6 @@ int snd_trident_create(struct snd_card *card,
        snd_trident_enable_eso(trident);
 
        snd_trident_proc_init(trident);
-       snd_card_set_dev(card, &pci->dev);
        *rtrident = trident;
        return 0;
 }
@@ -3950,8 +3957,7 @@ static int snd_trident_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "trident: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index 5ae6f042c586f61e94127ac91979e5e5c0407df8..95b98f537b67f27b1f7600c59ea2a72f3ce23bd7 100644 (file)
@@ -459,7 +459,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
                        unsigned int addr;
 
                        if (idx >= VIA_TABLE_SIZE) {
-                               snd_printk(KERN_ERR "via82xx: too much table size!\n");
+                               dev_err(&pci->dev, "too much table size!\n");
                                return -EINVAL;
                        }
                        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
                        } else
                                flag = 0; /* period continues to the next */
                        /*
-                       printk(KERN_DEBUG "via: tbl %d: at %d  size %d "
-                              "(rest %d)\n", idx, ofs, r, rest);
+                       dev_dbg(&pci->dev,
+                               "tbl %d: at %d  size %d (rest %d)\n",
+                               idx, ofs, r, rest);
                        */
                        ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
                        dev->idx_table[idx].offset = ofs;
@@ -528,7 +529,7 @@ static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary)
                if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY))
                        return val & 0xffff;
        }
-       snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n",
+       dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n",
                   secondary, snd_via82xx_codec_xread(chip));
        return -EIO;
 }
@@ -587,7 +588,8 @@ static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned sho
        xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
        while (1) {
                if (again++ > 3) {
-                       snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n",
+                       dev_err(chip->card->dev,
+                               "codec_read: codec %i is not valid [0x%x]\n",
                                   ac97->num, snd_via82xx_codec_xread(chip));
                        return 0xffff;
                }
@@ -777,7 +779,9 @@ static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
                                     viadev->lastpos < viadev->bufsize2))
 
-static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx,
+static inline unsigned int calc_linear_pos(struct via82xx *chip,
+                                          struct viadev *viadev,
+                                          unsigned int idx,
                                           unsigned int count)
 {
        unsigned int size, base, res;
@@ -790,7 +794,8 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
 
        /* check the validity of the calculated position */
        if (size < count) {
-               snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
+               dev_dbg(chip->card->dev,
+                       "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
                           (int)size, (int)count);
                res = viadev->lastpos;
        } else {
@@ -807,9 +812,9 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
                }
                if (check_invalid_pos(viadev, res)) {
 #ifdef POINTER_DEBUG
-                       printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, "
-                              "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, "
-                              "count = 0x%x\n", idx, viadev->tbl_entries,
+                       dev_dbg(chip->card->dev,
+                               "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n",
+                               idx, viadev->tbl_entries,
                               viadev->lastpos, viadev->bufsize2,
                               viadev->idx_table[idx].offset,
                               viadev->idx_table[idx].size, count);
@@ -817,8 +822,8 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
                        /* count register returns full size when end of buffer is reached */
                        res = base + size;
                        if (check_invalid_pos(viadev, res)) {
-                               snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), "
-                                          "using last valid pointer\n");
+                               dev_dbg(chip->card->dev,
+                                       "invalid via82xx_cur_ptr (2), using last valid pointer\n");
                                res = viadev->lastpos;
                        }
                }
@@ -850,7 +855,7 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
                idx = 0;
        else /* CURR_PTR holds the address + 8 */
                idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries;
-       res = calc_linear_pos(viadev, idx, count);
+       res = calc_linear_pos(chip, viadev, idx, count);
        viadev->lastpos = res; /* remember the last position */
        spin_unlock(&chip->reg_lock);
 
@@ -889,13 +894,14 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *subst
                idx = count >> 24;
                if (idx >= viadev->tbl_entries) {
 #ifdef POINTER_DEBUG
-                       printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx,
+                       dev_dbg(chip->card->dev,
+                               "fail: invalid idx = %i/%i\n", idx,
                               viadev->tbl_entries);
 #endif
                        res = viadev->lastpos;
                } else {
                        count &= 0xffffff;
-                       res = calc_linear_pos(viadev, idx, count);
+                       res = calc_linear_pos(chip, viadev, idx, count);
                }
        } else {
                res = viadev->hwptr_done;
@@ -1940,14 +1946,15 @@ static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legac
 
        r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport");
        if (!r) {
-               printk(KERN_WARNING "via82xx: cannot reserve joystick port %#x\n",
+               dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n",
                       JOYSTICK_ADDR);
                return -EBUSY;
        }
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                release_and_free_resource(r);
                return -ENOMEM;
        }
@@ -2016,7 +2023,8 @@ static int snd_via8233_init_misc(struct via82xx *chip)
                strcpy(sid.name, "PCM Playback Volume");
                sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
                if (! snd_ctl_find_id(chip->card, &sid)) {
-                       snd_printd(KERN_INFO "Using DXS as PCM Playback\n");
+                       dev_info(chip->card->dev,
+                                "Using DXS as PCM Playback\n");
                        err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip));
                        if (err < 0)
                                return err;
@@ -2102,8 +2110,9 @@ static int snd_via686_init_misc(struct via82xx *chip)
                                        mpu_port, MPU401_INFO_INTEGRATED |
                                        MPU401_INFO_IRQ_HOOK, -1,
                                        &chip->rmidi) < 0) {
-                       printk(KERN_WARNING "unable to initialize MPU-401"
-                              " at 0x%lx, skipping\n", mpu_port);
+                       dev_warn(chip->card->dev,
+                                "unable to initialize MPU-401 at 0x%lx, skipping\n",
+                                mpu_port);
                        legacy &= ~VIA_FUNC_ENABLE_MIDI;
                } else {
                        legacy &= ~VIA_FUNC_MIDI_IRQMASK;       /* enable MIDI interrupt */
@@ -2203,7 +2212,8 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
        } while (time_before(jiffies, end_time));
 
        if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
-               snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val);
+               dev_err(chip->card->dev,
+                       "AC'97 codec is not ready [0x%x]\n", val);
 
 #if 0 /* FIXME: we don't support the second codec yet so skip the detection now.. */
        snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
@@ -2303,8 +2313,7 @@ static int snd_via82xx_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "via82xx: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2417,7 +2426,7 @@ static int snd_via82xx_create(struct snd_card *card,
                        snd_via8233_interrupt : snd_via686_interrupt,
                        IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_via82xx_free(chip);
                return -EBUSY;
        }
@@ -2441,8 +2450,6 @@ static int snd_via82xx_create(struct snd_card *card,
         * We call pci_set_master here because it does not hurt. */
        pci_set_master(pci);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_via = chip;
        return 0;
 }
@@ -2516,7 +2523,7 @@ static int check_dxs_list(struct pci_dev *pci, int revision)
 
        w = snd_pci_quirk_lookup(pci, dxs_whitelist);
        if (w) {
-               snd_printdd(KERN_INFO "via82xx: DXS white list for %s found\n",
+               dev_dbg(&pci->dev, "DXS white list for %s found\n",
                            snd_pci_quirk_name(w));
                return w->value;
        }
@@ -2528,10 +2535,10 @@ static int check_dxs_list(struct pci_dev *pci, int revision)
        /*
         * not detected, try 48k rate only to be sure.
         */
-       printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate.\n");
-       printk(KERN_INFO "         Please try dxs_support=5 option\n");
-       printk(KERN_INFO "         and report if it works on your machine.\n");
-       printk(KERN_INFO "         For more details, read ALSA-Configuration.txt.\n");
+       dev_info(&pci->dev, "Assuming DXS channels with 48k fixed sample rate.\n");
+       dev_info(&pci->dev, "         Please try dxs_support=5 option\n");
+       dev_info(&pci->dev, "         and report if it works on your machine.\n");
+       dev_info(&pci->dev, "         For more details, read ALSA-Configuration.txt.\n");
        return VIA_DXS_48K;
 };
 
@@ -2544,7 +2551,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
        unsigned int i;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -2584,7 +2591,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
                        strcpy(card->driver, "VIA8233");
                break;
        default:
-               snd_printk(KERN_ERR "invalid card type %d\n", card_type);
+               dev_err(card->dev, "invalid card type %d\n", card_type);
                err = -EINVAL;
                goto __error;
        }
index ca190283cbd7745f50d4ec4ffeaf74726ea3afc1..46a0526b1d7902ab81e4a29d7fb2ce1506410f67 100644 (file)
@@ -312,7 +312,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
                        unsigned int addr;
 
                        if (idx >= VIA_TABLE_SIZE) {
-                               snd_printk(KERN_ERR "via82xx: too much table size!\n");
+                               dev_err(&pci->dev, "too much table size!\n");
                                return -EINVAL;
                        }
                        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
                        } else
                                flag = 0; /* period continues to the next */
                        /*
-                       printk(KERN_DEBUG "via: tbl %d: at %d  size %d "
-                              "(rest %d)\n", idx, ofs, r, rest);
+                       dev_dbg(&pci->dev,
+                               "tbl %d: at %d  size %d (rest %d)\n",
+                               idx, ofs, r, rest);
                        */
                        ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
                        dev->idx_table[idx].offset = ofs;
@@ -382,7 +383,7 @@ static int snd_via82xx_codec_ready(struct via82xx_modem *chip, int secondary)
                if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY))
                        return val & 0xffff;
        }
-       snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n",
+       dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n",
                   secondary, snd_via82xx_codec_xread(chip));
        return -EIO;
 }
@@ -443,7 +444,8 @@ static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned sho
        xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
        while (1) {
                if (again++ > 3) {
-                       snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n",
+                       dev_err(chip->card->dev,
+                               "codec_read: codec %i is not valid [0x%x]\n",
                                   ac97->num, snd_via82xx_codec_xread(chip));
                        return 0xffff;
                }
@@ -560,7 +562,9 @@ static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
                                     viadev->lastpos < viadev->bufsize2))
 
-static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx,
+static inline unsigned int calc_linear_pos(struct via82xx_modem *chip,
+                                          struct viadev *viadev,
+                                          unsigned int idx,
                                           unsigned int count)
 {
        unsigned int size, res;
@@ -570,20 +574,21 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
 
        /* check the validity of the calculated position */
        if (size < count) {
-               snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
+               dev_err(chip->card->dev,
+                       "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
                           (int)size, (int)count);
                res = viadev->lastpos;
        } else if (check_invalid_pos(viadev, res)) {
 #ifdef POINTER_DEBUG
-               printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, "
-                      "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, "
-                      "count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos,
+               dev_dbg(chip->card->dev,
+                       "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n",
+                       idx, viadev->tbl_entries, viadev->lastpos,
                       viadev->bufsize2, viadev->idx_table[idx].offset,
                       viadev->idx_table[idx].size, count);
 #endif
                if (count && size < count) {
-                       snd_printd(KERN_ERR "invalid via82xx_cur_ptr, "
-                                  "using last valid pointer\n");
+                       dev_dbg(chip->card->dev,
+                               "invalid via82xx_cur_ptr, using last valid pointer\n");
                        res = viadev->lastpos;
                } else {
                        if (! count)
@@ -595,8 +600,8 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
                                 */
                                res = viadev->idx_table[idx].offset + size;
                        if (check_invalid_pos(viadev, res)) {
-                               snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), "
-                                          "using last valid pointer\n");
+                               dev_dbg(chip->card->dev,
+                                       "invalid via82xx_cur_ptr (2), using last valid pointer\n");
                                res = viadev->lastpos;
                        }
                }
@@ -632,7 +637,7 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
        else /* CURR_PTR holds the address + 8 */
                idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) %
                        viadev->tbl_entries;
-       res = calc_linear_pos(viadev, idx, count);
+       res = calc_linear_pos(chip, viadev, idx, count);
        spin_unlock(&chip->reg_lock);
 
        return bytes_to_frames(substream->runtime, res);
@@ -991,7 +996,8 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
        } while (time_before(jiffies, end_time));
 
        if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
-               snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val);
+               dev_err(chip->card->dev,
+                       "AC'97 codec is not ready [0x%x]\n", val);
 
        snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
                                 VIA_REG_AC97_SECONDARY_VALID |
@@ -1054,8 +1060,7 @@ static int snd_via82xx_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "via82xx-modem: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -1137,7 +1142,7 @@ static int snd_via82xx_create(struct snd_card *card,
        chip->port = pci_resource_start(pci, 0);
        if (request_irq(pci->irq, snd_via82xx_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_via82xx_free(chip);
                return -EBUSY;
        }
@@ -1161,8 +1166,6 @@ static int snd_via82xx_create(struct snd_card *card,
         * We call pci_set_master here because it does not hurt. */
        pci_set_master(pci);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *r_via = chip;
        return 0;
 }
@@ -1177,7 +1180,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
        unsigned int i;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -1188,7 +1191,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
                sprintf(card->shortname, "VIA 82XX modem");
                break;
        default:
-               snd_printk(KERN_ERR "invalid card type %d\n", card_type);
+               dev_err(card->dev, "invalid card type %d\n", card_type);
                err = -EINVAL;
                goto __error;
        }
index ab8a9b1bfb8e21933290e86be80a4f8a6459313b..ff9074d22607a7a640105d304c784aca644989b1 100644 (file)
@@ -170,7 +170,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
 
        if (request_irq(pci->irq, snd_vx_irq_handler, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_vx222_free(chip);
                return -EBUSY;
        }
@@ -181,8 +181,6 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
                return err;
        }
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = vx;
        return 0;
 }
@@ -204,7 +202,8 @@ static int snd_vx222_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -229,7 +228,7 @@ static int snd_vx222_probe(struct pci_dev *pci,
 
        sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i",
                card->shortname, vx->port[0], vx->port[1], vx->core.irq);
-       snd_printdd("%s at 0x%lx & 0x%lx, irq %i\n",
+       dev_dbg(card->dev, "%s at 0x%lx & 0x%lx, irq %i\n",
                    card->shortname, vx->port[0], vx->port[1], vx->core.irq);
 
 #ifdef SND_VX_FW_LOADER
@@ -280,8 +279,7 @@ static int snd_vx222_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "vx222: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
index a69e774d0b138f46d373cab95bb78858e04c1f11..2d1570273e99eb6d77bfcf03868c488af4554388 100644 (file)
@@ -108,7 +108,7 @@ static void vx2_outb(struct vx_core *chip, int offset, unsigned char val)
 {
        outb(val, vx2_reg_addr(chip, offset));
        /*
-       printk(KERN_DEBUG "outb: %x -> %x\n", val, vx2_reg_addr(chip, offset));
+       dev_dbg(chip->card->dev, "outb: %x -> %x\n", val, vx2_reg_addr(chip, offset));
        */
 }
 
@@ -129,7 +129,7 @@ static unsigned int vx2_inl(struct vx_core *chip, int offset)
 static void vx2_outl(struct vx_core *chip, int offset, unsigned int val)
 {
        /*
-       printk(KERN_DEBUG "outl: %x -> %x\n", val, vx2_reg_addr(chip, offset));
+       dev_dbg(chip->card->dev, "outl: %x -> %x\n", val, vx2_reg_addr(chip, offset));
        */
        outl(val, vx2_reg_addr(chip, offset));
 }
@@ -173,7 +173,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
        struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
        unsigned int data;
 
-       snd_printdd("testing xilinx...\n");
+       dev_dbg(_chip->card->dev, "testing xilinx...\n");
        /* This test uses several write/read sequences on TEST0 and TEST1 bits
         * to figure out whever or not the xilinx was correctly loaded
         */
@@ -183,7 +183,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
        vx_inl(chip, ISR);
        data = vx_inl(chip, STATUS);
        if ((data & VX_STATUS_VAL_TEST0_MASK) == VX_STATUS_VAL_TEST0_MASK) {
-               snd_printdd("bad!\n");
+               dev_dbg(_chip->card->dev, "bad!\n");
                return -ENODEV;
        }
 
@@ -192,7 +192,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
        vx_inl(chip, ISR);
        data = vx_inl(chip, STATUS);
        if (! (data & VX_STATUS_VAL_TEST0_MASK)) {
-               snd_printdd("bad! #2\n");
+               dev_dbg(_chip->card->dev, "bad! #2\n");
                return -ENODEV;
        }
 
@@ -203,7 +203,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
                vx_inl(chip, ISR);
                data = vx_inl(chip, STATUS);
                if ((data & VX_STATUS_VAL_TEST1_MASK) == VX_STATUS_VAL_TEST1_MASK) {
-                       snd_printdd("bad! #3\n");
+                       dev_dbg(_chip->card->dev, "bad! #3\n");
                        return -ENODEV;
                }
 
@@ -212,11 +212,11 @@ static int vx2_test_xilinx(struct vx_core *_chip)
                vx_inl(chip, ISR);
                data = vx_inl(chip, STATUS);
                if (! (data & VX_STATUS_VAL_TEST1_MASK)) {
-                       snd_printdd("bad! #4\n");
+                       dev_dbg(_chip->card->dev, "bad! #4\n");
                        return -ENODEV;
                }
        }
-       snd_printdd("ok, xilinx fine.\n");
+       dev_dbg(_chip->card->dev, "ok, xilinx fine.\n");
        return 0;
 }
 
@@ -397,7 +397,8 @@ static int vx2_load_xilinx_binary(struct vx_core *chip, const struct firmware *x
                i = vx_inl(chip, GPIOC);
                if (i & 0x0100)
                        return 0;
-               snd_printk(KERN_ERR "vx222: xilinx test failed after load, GPIOC=0x%x\n", i);
+               dev_err(chip->card->dev,
+                       "xilinx test failed after load, GPIOC=0x%x\n", i);
                return -EINVAL;
        }
 
index e8932b2e4a5dcce73f4a2417933d90cf618079cb..82eed164b27582324ce5dbc40588e32cd07302a4 100644 (file)
@@ -106,7 +106,8 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
                                        break;
                        }
                        if (!r) {
-                               printk(KERN_ERR "ymfpci: no gameport ports available\n");
+                               dev_err(chip->card->dev,
+                                       "no gameport ports available\n");
                                return -EBUSY;
                        }
                }
@@ -116,19 +117,22 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
                case 0x204: legacy_ctrl2 |= 2 << 6; break;
                case 0x205: legacy_ctrl2 |= 3 << 6; break;
                default:
-                       printk(KERN_ERR "ymfpci: invalid joystick port %#x", io_port);
+                       dev_err(chip->card->dev,
+                               "invalid joystick port %#x", io_port);
                        return -EINVAL;
                }
        }
 
        if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) {
-               printk(KERN_ERR "ymfpci: joystick port %#x is in use.\n", io_port);
+               dev_err(chip->card->dev,
+                       "joystick port %#x is in use.\n", io_port);
                return -EBUSY;
        }
 
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
-               printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n");
+               dev_err(chip->card->dev,
+                       "cannot allocate memory for gameport\n");
                release_and_free_resource(r);
                return -ENOMEM;
        }
@@ -187,7 +191,8 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+                          0, &card);
        if (err < 0)
                return err;
 
@@ -313,7 +318,9 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
                                               MPU401_INFO_INTEGRATED |
                                               MPU401_INFO_IRQ_HOOK,
                                               -1, &chip->rawmidi)) < 0) {
-                       printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]);
+                       dev_warn(card->dev,
+                                "cannot initialize MPU401 at 0x%lx, skipping...\n",
+                                mpu_port[dev]);
                        legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */
                        pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
                }
@@ -323,12 +330,14 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
                                           fm_port[dev],
                                           fm_port[dev] + 2,
                                           OPL3_HW_OPL3, 1, &opl3)) < 0) {
-                       printk(KERN_WARNING "ymfpci: cannot initialize FM OPL3 at 0x%lx, skipping...\n", fm_port[dev]);
+                       dev_warn(card->dev,
+                                "cannot initialize FM OPL3 at 0x%lx, skipping...\n",
+                                fm_port[dev]);
                        legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
                        pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
                } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
                        snd_card_free(card);
-                       snd_printk(KERN_ERR "cannot create opl3 hwdep\n");
+                       dev_err(card->dev, "cannot create opl3 hwdep\n");
                        return err;
                }
        }
index d591c154fc58fc4a9aeb3a5407e500b24d7e4996..81c916a5eb96a09ba4f4cb8cec1f75339f9f2dca 100644 (file)
@@ -86,7 +86,9 @@ static int snd_ymfpci_codec_ready(struct snd_ymfpci *chip, int secondary)
                        return 0;
                schedule_timeout_uninterruptible(1);
        } while (time_before(jiffies, end_time));
-       snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg));
+       dev_err(chip->card->dev,
+               "codec_ready: codec %i is not ready [0x%x]\n",
+               secondary, snd_ymfpci_readw(chip, reg));
        return -EBUSY;
 }
 
@@ -319,7 +321,7 @@ static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_
                ypcm->last_pos = pos;
                if (ypcm->period_pos >= ypcm->period_size) {
                        /*
-                       printk(KERN_DEBUG
+                       dev_dbg(chip->card->dev,
                               "done - active_bank = 0x%x, start = 0x%x\n",
                               chip->active_bank,
                               voice->bank[chip->active_bank].start);
@@ -372,7 +374,7 @@ static void snd_ymfpci_pcm_capture_interrupt(struct snd_pcm_substream *substream
                if (ypcm->period_pos >= ypcm->period_size) {
                        ypcm->period_pos %= ypcm->period_size;
                        /*
-                       printk(KERN_DEBUG
+                       dev_dbg(chip->card->dev,
                               "done - active_bank = 0x%x, start = 0x%x\n",
                               chip->active_bank,
                               voice->bank[chip->active_bank].start);
@@ -2067,7 +2069,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
                               &chip->pci->dev);
        if (err >= 0) {
                if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) {
-                       snd_printk(KERN_ERR "DSP microcode has wrong size\n");
+                       dev_err(chip->card->dev,
+                               "DSP microcode has wrong size\n");
                        err = -EINVAL;
                }
        }
@@ -2082,8 +2085,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
                               &chip->pci->dev);
        if (err >= 0) {
                if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) {
-                       snd_printk(KERN_ERR "controller microcode"
-                                  " has wrong size\n");
+                       dev_err(chip->card->dev,
+                               "controller microcode has wrong size\n");
                        err = -EINVAL;
                }
        }
@@ -2360,8 +2363,7 @@ static int snd_ymfpci_resume(struct device *dev)
        pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
        if (pci_enable_device(pci) < 0) {
-               printk(KERN_ERR "ymfpci: pci_enable_device failed, "
-                      "disabling device\n");
+               dev_err(dev, "pci_enable_device failed, disabling device\n");
                snd_card_disconnect(card);
                return -EIO;
        }
@@ -2433,13 +2435,15 @@ int snd_ymfpci_create(struct snd_card *card,
        chip->src441_used = -1;
 
        if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) {
-               snd_printk(KERN_ERR "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1);
+               dev_err(chip->card->dev,
+                       "unable to grab memory region 0x%lx-0x%lx\n",
+                       chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1);
                snd_ymfpci_free(chip);
                return -EBUSY;
        }
        if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
                snd_ymfpci_free(chip);
                return -EBUSY;
        }
@@ -2453,7 +2457,7 @@ int snd_ymfpci_create(struct snd_card *card,
 
        err = snd_ymfpci_request_firmware(chip);
        if (err < 0) {
-               snd_printk(KERN_ERR "firmware request failed: %d\n", err);
+               dev_err(chip->card->dev, "firmware request failed: %d\n", err);
                snd_ymfpci_free(chip);
                return err;
        }
@@ -2487,8 +2491,6 @@ int snd_ymfpci_create(struct snd_card *card,
 
        snd_ymfpci_proc_init(card, chip);
 
-       snd_card_set_dev(card, &pci->dev);
-
        *rchip = chip;
        return 0;
 }
index 8f489de5c4c6101567263c1deaa1b6bc5c0db080..56bda124cd4acfda66a3865761c2ffa1208009f7 100644 (file)
@@ -112,7 +112,8 @@ static int snd_pdacf_probe(struct pcmcia_device *link)
                return -ENODEV; /* disabled explicitly */
 
        /* ok, create a card instance */
-       err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card);
+       err = snd_card_new(&link->dev, index[i], id[i], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
                snd_printk(KERN_ERR "pdacf: cannot create a card instance\n");
                return err;
@@ -131,8 +132,6 @@ static int snd_pdacf_probe(struct pcmcia_device *link)
                return err;
        }
 
-       snd_card_set_dev(card, &link->dev);
-
        pdacf->index = i;
        card_list[i] = card;
 
index d4db7ecaa6bf5c1aec13a0fdcbd12778c521af35..786e7e139c9eeae713a57ab334ea08bd1c6ce6f1 100644 (file)
@@ -238,7 +238,6 @@ static int vxpocket_config(struct pcmcia_device *link)
                goto failed;
 
        chip->dev = &link->dev;
-       snd_card_set_dev(chip->card, chip->dev);
 
        if (snd_vxpocket_assign_resources(chip, link->resource[0]->start,
                                                link->irq) < 0)
@@ -307,7 +306,8 @@ static int vxpocket_probe(struct pcmcia_device *p_dev)
                return -ENODEV; /* disabled explicitly */
 
        /* ok, create a card instance */
-       err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card);
+       err = snd_card_new(&p_dev->dev, index[i], id[i], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
                snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n");
                return err;
index 8abb521b4814b413a9423edf48bf2d7e41c08e2e..350a7c8f86dd4ef83b464cb994acdcba0b202727 100644 (file)
@@ -58,7 +58,7 @@ static int snd_pmac_probe(struct platform_device *devptr)
        char *name_ext;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
@@ -122,8 +122,6 @@ static int snd_pmac_probe(struct platform_device *devptr)
        if (enable_beep)
                snd_pmac_attach_beep(chip);
 
-       snd_card_set_dev(card, &devptr->dev);
-
        if ((err = snd_card_register(card)) < 0)
                goto __error;
 
index ebb76f2d90d790175cbb35b93ffa1213f258a299..58f292a87f98fcc7eae969b4676b7feb487e4dfa 100644 (file)
@@ -984,7 +984,8 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
        }
 
        /* create card instance */
-       ret = snd_card_create(index, id, THIS_MODULE, 0, &the_card.card);
+       ret = snd_card_new(&dev->core, index, id, THIS_MODULE,
+                          0, &the_card.card);
        if (ret < 0)
                goto clean_irq;
 
@@ -1052,7 +1053,6 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
        snd_ps3_init_avsetting(&the_card);
 
        /* register the card */
-       snd_card_set_dev(the_card.card, &dev->core);
        ret = snd_card_register(the_card.card);
        if (ret < 0)
                goto clean_dma_map;
index 78a369785a9ecf3b3e8d1a72e6b536e6a8ddb89a..47849eaf266d5c1e2ba17ddd50edf4dda6381d92 100644 (file)
@@ -608,8 +608,8 @@ static int snd_aica_probe(struct platform_device *devptr)
        dreamcastcard = kmalloc(sizeof(struct snd_card_aica), GFP_KERNEL);
        if (unlikely(!dreamcastcard))
                return -ENOMEM;
-       err = snd_card_create(index, SND_AICA_DRIVER, THIS_MODULE, 0,
-                             &dreamcastcard->card);
+       err = snd_card_new(&devptr->dev, index, SND_AICA_DRIVER,
+                          THIS_MODULE, 0, &dreamcastcard->card);
        if (unlikely(err < 0)) {
                kfree(dreamcastcard);
                return err;
@@ -624,7 +624,6 @@ static int snd_aica_probe(struct platform_device *devptr)
        err = snd_aicapcmchip(dreamcastcard, 0);
        if (unlikely(err < 0))
                goto freedreamcast;
-       snd_card_set_dev(dreamcastcard->card, &devptr->dev);
        dreamcastcard->timer.data = 0;
        dreamcastcard->channel = NULL;
        /* Add basic controls */
index 7c9422c4fc0f99097c0b3b6197a1dc0ff8165099..d1fb74dabbd11f4fd8019cf79c7ca9c3749c2f88 100644 (file)
@@ -396,7 +396,7 @@ static int snd_sh_dac_probe(struct platform_device *devptr)
        struct snd_card *card;
        int err;
 
-       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card);
        if (err < 0) {
                        snd_printk(KERN_ERR "cannot allocate the card\n");
                        return err;
index caebd63531125924179c083f396a6114ba82c916..051c006281f5c2c003583f7104c9ec02dc886dfc 100644 (file)
@@ -1656,7 +1656,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
        }
 
        /* card bind complete so register a sound card */
-       ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+       ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
                        card->owner, 0, &card->snd_card);
        if (ret < 0) {
                dev_err(card->dev,
@@ -1664,7 +1664,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
                        card->name, ret);
                goto base_error;
        }
-       card->snd_card->dev = card->dev;
 
        card->dapm.bias_level = SND_SOC_BIAS_OFF;
        card->dapm.dev = card->dev;
index 174d21fb56e2e326246231b30ce589a90919a9ff..4a85e14334726e43f513a95a0e85e4fd4c5dd2cd 100644 (file)
@@ -1019,8 +1019,8 @@ static int amd7930_sbus_probe(struct platform_device *op)
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev_num], id[dev_num], THIS_MODULE, 0,
-                             &card);
+       err = snd_card_new(&op->dev, index[dev_num], id[dev_num],
+                          THIS_MODULE, 0, &card);
        if (err < 0)
                return err;
 
index dbb1b625eb2f59b5fd536fc33c0679b054095652..4e91bcaa36649943b430058d434dff5310c88cc3 100644 (file)
@@ -1565,7 +1565,8 @@ static int snd_cs4231_mixer(struct snd_card *card)
 
 static int dev;
 
-static int cs4231_attach_begin(struct snd_card **rcard)
+static int cs4231_attach_begin(struct platform_device *op,
+                              struct snd_card **rcard)
 {
        struct snd_card *card;
        struct snd_cs4231 *chip;
@@ -1581,8 +1582,8 @@ static int cs4231_attach_begin(struct snd_card **rcard)
                return -ENOENT;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_cs4231), &card);
+       err = snd_card_new(&op->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_cs4231), &card);
        if (err < 0)
                return err;
 
@@ -1869,7 +1870,7 @@ static int cs4231_sbus_probe(struct platform_device *op)
        struct snd_card *card;
        int err;
 
-       err = cs4231_attach_begin(&card);
+       err = cs4231_attach_begin(op, &card);
        if (err)
                return err;
 
@@ -2060,7 +2061,7 @@ static int cs4231_ebus_probe(struct platform_device *op)
        struct snd_card *card;
        int err;
 
-       err = cs4231_attach_begin(&card);
+       err = cs4231_attach_begin(op, &card);
        if (err)
                return err;
 
index eee7afcae37510db454f132c65f01ba5c34f776e..be1b1aa96b7ea2bd44d8ab0021a86eacb48a10e8 100644 (file)
@@ -2615,8 +2615,8 @@ static int dbri_probe(struct platform_device *op)
                return -ENODEV;
        }
 
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct snd_dbri), &card);
+       err = snd_card_new(&op->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct snd_dbri), &card);
        if (err < 0)
                return err;
 
index 25c38afaee4900463692c93b4182db82f93b36bd..39522367897caedb4be23f1f92579d31a4d1fe38 100644 (file)
@@ -927,8 +927,6 @@ static int snd_at73c213_dev_init(struct snd_card *card,
        if (retval)
                goto out_snd_dev;
 
-       snd_card_set_dev(card, &spi->dev);
-
        goto out;
 
 out_snd_dev:
@@ -966,8 +964,8 @@ static int snd_at73c213_probe(struct spi_device *spi)
 
        /* Allocate "card" using some unused identifiers. */
        snprintf(id, sizeof id, "at73c213_%d", board->ssc_id);
-       retval = snd_card_create(-1, id, THIS_MODULE,
-                                sizeof(struct snd_at73c213), &card);
+       retval = snd_card_new(&spi->dev, -1, id, THIS_MODULE,
+                             sizeof(struct snd_at73c213), &card);
        if (retval < 0)
                goto out;
 
index 66edc4a7917f9bd08604f85ed98bc988d8e5d9f3..dcddfc354ba683c65a5266a0c448d625371d21b7 100644 (file)
@@ -106,7 +106,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
        }
        if (regidx < 0) {
                mutex_unlock(&register_mutex);
-               snd_printk(KERN_ERR PREFIX "too many cards registered.\n");
+               dev_err(&intf->dev, "too many cards registered.\n");
                return -ENODEV;
        }
        devices[regidx] = device;
@@ -121,20 +121,19 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
 
        /* if we are here, card can be registered in alsa. */
        if (usb_set_interface(device, 0, 0) != 0) {
-               snd_printk(KERN_ERR PREFIX "can't set first interface.\n");
+               dev_err(&intf->dev, "can't set first interface.\n");
                return -EIO;
        }
-       ret = snd_card_create(index[regidx], id[regidx], THIS_MODULE,
-                       sizeof(struct sfire_chip), &card);
+       ret = snd_card_new(&intf->dev, index[regidx], id[regidx],
+                          THIS_MODULE, sizeof(struct sfire_chip), &card);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "cannot create alsa card.\n");
+               dev_err(&intf->dev, "cannot create alsa card.\n");
                return ret;
        }
        strcpy(card->driver, "6FireUSB");
        strcpy(card->shortname, "TerraTec DMX6FireUSB");
        sprintf(card->longname, "%s at %d:%d", card->shortname,
                        device->bus->busnum, device->devnum);
-       snd_card_set_dev(card, &intf->dev);
 
        chip = card->private_data;
        chips[regidx] = chip;
@@ -169,7 +168,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
 
        ret = snd_card_register(card);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "cannot register card.");
+               dev_err(&intf->dev, "cannot register card.");
                usb6fire_chip_destroy(chip);
                return ret;
        }
index 23452ee617e11a5d304fffbd0da3e7bea805e0dc..161215d78d9520a98026574489095b47e6c95f85 100644 (file)
@@ -51,7 +51,7 @@ static void usb6fire_comm_receiver_handler(struct urb *urb)
                urb->status = 0;
                urb->actual_length = 0;
                if (usb_submit_urb(urb, GFP_ATOMIC) < 0)
-                       snd_printk(KERN_WARNING PREFIX
+                       dev_warn(&urb->dev->dev,
                                        "comm data receiver aborted.\n");
        }
 }
@@ -179,7 +179,7 @@ int usb6fire_comm_init(struct sfire_chip *chip)
        if (ret < 0) {
                kfree(rt->receiver_buffer);
                kfree(rt);
-               snd_printk(KERN_ERR PREFIX "cannot create comm data receiver.");
+               dev_err(&chip->dev->dev, "cannot create comm data receiver.");
                return ret;
        }
        chip->comm = rt;
index f6434c245720416f7fae946e62979a43f4b66333..184e3987ac24b2205709146d4bd8db7be8ed12bd 100644 (file)
@@ -194,7 +194,8 @@ static int usb6fire_control_output_vol_put(struct snd_kcontrol *kcontrol,
        int changed = 0;
 
        if (ch > 4) {
-               snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
+               dev_err(&rt->chip->dev->dev,
+                       "Invalid channel in volume control.");
                return -EINVAL;
        }
 
@@ -222,7 +223,8 @@ static int usb6fire_control_output_vol_get(struct snd_kcontrol *kcontrol,
        unsigned int ch = kcontrol->private_value;
 
        if (ch > 4) {
-               snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
+               dev_err(&rt->chip->dev->dev,
+                       "Invalid channel in volume control.");
                return -EINVAL;
        }
 
@@ -240,7 +242,8 @@ static int usb6fire_control_output_mute_put(struct snd_kcontrol *kcontrol,
        u8 value = 0;
 
        if (ch > 4) {
-               snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
+               dev_err(&rt->chip->dev->dev,
+                       "Invalid channel in volume control.");
                return -EINVAL;
        }
 
@@ -265,7 +268,8 @@ static int usb6fire_control_output_mute_get(struct snd_kcontrol *kcontrol,
        u8 value = rt->output_mute >> ch;
 
        if (ch > 4) {
-               snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
+               dev_err(&rt->chip->dev->dev,
+                       "Invalid channel in volume control.");
                return -EINVAL;
        }
 
@@ -594,14 +598,14 @@ int usb6fire_control_init(struct sfire_chip *chip)
        ret = usb6fire_control_add_virtual(rt, chip->card,
                "Master Playback Volume", vol_elements);
        if (ret) {
-               snd_printk(KERN_ERR PREFIX "cannot add control.\n");
+               dev_err(&chip->dev->dev, "cannot add control.\n");
                kfree(rt);
                return ret;
        }
        ret = usb6fire_control_add_virtual(rt, chip->card,
                "Master Playback Switch", mute_elements);
        if (ret) {
-               snd_printk(KERN_ERR PREFIX "cannot add control.\n");
+               dev_err(&chip->dev->dev, "cannot add control.\n");
                kfree(rt);
                return ret;
        }
@@ -611,7 +615,7 @@ int usb6fire_control_init(struct sfire_chip *chip)
                ret = snd_ctl_add(chip->card, snd_ctl_new1(&elements[i], rt));
                if (ret < 0) {
                        kfree(rt);
-                       snd_printk(KERN_ERR PREFIX "cannot add control.\n");
+                       dev_err(&chip->dev->dev, "cannot add control.\n");
                        return ret;
                }
                i++;
index 780bf3f62d2800f3a8f9da7ffc8d011d0a6c3bd2..3b02e54b8f6db7e6e467edb9b4b8c2981c4dc8f1 100644 (file)
@@ -219,16 +219,16 @@ static int usb6fire_fw_ezusb_upload(
        ret = request_firmware(&fw, fwname, &device->dev);
        if (ret < 0) {
                kfree(rec);
-               snd_printk(KERN_ERR PREFIX "error requesting ezusb "
-                               "firmware %s.\n", fwname);
+               dev_err(&intf->dev,
+                       "error requesting ezusb firmware %s.\n", fwname);
                return ret;
        }
        ret = usb6fire_fw_ihex_init(fw, rec);
        if (ret < 0) {
                kfree(rec);
                release_firmware(fw);
-               snd_printk(KERN_ERR PREFIX "error validating ezusb "
-                               "firmware %s.\n", fwname);
+               dev_err(&intf->dev,
+                       "error validating ezusb firmware %s.\n", fwname);
                return ret;
        }
        /* upload firmware image */
@@ -237,8 +237,9 @@ static int usb6fire_fw_ezusb_upload(
        if (ret < 0) {
                kfree(rec);
                release_firmware(fw);
-               snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
-                               "firmware %s: begin message.\n", fwname);
+               dev_err(&intf->dev,
+                       "unable to upload ezusb firmware %s: begin message.\n",
+                       fwname);
                return ret;
        }
 
@@ -248,8 +249,9 @@ static int usb6fire_fw_ezusb_upload(
                if (ret < 0) {
                        kfree(rec);
                        release_firmware(fw);
-                       snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
-                                       "firmware %s: data urb.\n", fwname);
+                       dev_err(&intf->dev,
+                               "unable to upload ezusb firmware %s: data urb.\n",
+                               fwname);
                        return ret;
                }
        }
@@ -260,8 +262,9 @@ static int usb6fire_fw_ezusb_upload(
                ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr,
                                postdata, postlen);
                if (ret < 0) {
-                       snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
-                                       "firmware %s: post urb.\n", fwname);
+                       dev_err(&intf->dev,
+                               "unable to upload ezusb firmware %s: post urb.\n",
+                               fwname);
                        return ret;
                }
        }
@@ -269,8 +272,9 @@ static int usb6fire_fw_ezusb_upload(
        data = 0x00; /* resume ezusb cpu */
        ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
-                               "firmware %s: end message.\n", fwname);
+               dev_err(&intf->dev,
+                       "unable to upload ezusb firmware %s: end message.\n",
+                       fwname);
                return ret;
        }
        return 0;
@@ -292,7 +296,7 @@ static int usb6fire_fw_fpga_upload(
 
        ret = request_firmware(&fw, fwname, &device->dev);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "unable to get fpga firmware %s.\n",
+               dev_err(&intf->dev, "unable to get fpga firmware %s.\n",
                                fwname);
                kfree(buffer);
                return -EIO;
@@ -305,8 +309,8 @@ static int usb6fire_fw_fpga_upload(
        if (ret < 0) {
                kfree(buffer);
                release_firmware(fw);
-               snd_printk(KERN_ERR PREFIX "unable to upload fpga firmware: "
-                               "begin urb.\n");
+               dev_err(&intf->dev,
+                       "unable to upload fpga firmware: begin urb.\n");
                return ret;
        }
 
@@ -318,8 +322,8 @@ static int usb6fire_fw_fpga_upload(
                if (ret < 0) {
                        release_firmware(fw);
                        kfree(buffer);
-                       snd_printk(KERN_ERR PREFIX "unable to upload fpga "
-                                       "firmware: fw urb.\n");
+                       dev_err(&intf->dev,
+                               "unable to upload fpga firmware: fw urb.\n");
                        return ret;
                }
        }
@@ -328,8 +332,8 @@ static int usb6fire_fw_fpga_upload(
 
        ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "unable to upload fpga firmware: "
-                               "end urb.\n");
+               dev_err(&intf->dev,
+                       "unable to upload fpga firmware: end urb.\n");
                return ret;
        }
        return 0;
@@ -338,7 +342,7 @@ static int usb6fire_fw_fpga_upload(
 /* check, if the firmware version the devices has currently loaded
  * is known by this driver. 'version' needs to have 4 bytes version
  * info data. */
-static int usb6fire_fw_check(u8 *version)
+static int usb6fire_fw_check(struct usb_interface *intf, const u8 *version)
 {
        int i;
 
@@ -346,7 +350,7 @@ static int usb6fire_fw_check(u8 *version)
                if (!memcmp(version, known_fw_versions + i, 2))
                        return 0;
 
-       snd_printk(KERN_ERR PREFIX "invalid fimware version in device: %4ph. "
+       dev_err(&intf->dev, "invalid fimware version in device: %4ph. "
                        "please reconnect to power. if this failure "
                        "still happens, check your firmware installation.",
                        version);
@@ -364,16 +368,16 @@ int usb6fire_fw_init(struct usb_interface *intf)
 
        ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "unable to receive device "
-                               "firmware state.\n");
+               dev_err(&intf->dev,
+                       "unable to receive device firmware state.\n");
                return ret;
        }
        if (buffer[0] != 0xeb || buffer[1] != 0xaa || buffer[2] != 0x55) {
-               snd_printk(KERN_ERR PREFIX "unknown device firmware state "
-                               "received from device: ");
+               dev_err(&intf->dev,
+                       "unknown device firmware state received from device:");
                for (i = 0; i < 8; i++)
-                       snd_printk("%02x ", buffer[i]);
-               snd_printk("\n");
+                       printk(KERN_CONT "%02x ", buffer[i]);
+               printk(KERN_CONT "\n");
                return -EIO;
        }
        /* do we need fpga loader ezusb firmware? */
@@ -386,7 +390,7 @@ int usb6fire_fw_init(struct usb_interface *intf)
        }
        /* do we need fpga firmware and application ezusb firmware? */
        else if (buffer[3] == 0x02) {
-               ret = usb6fire_fw_check(buffer + 4);
+               ret = usb6fire_fw_check(intf, buffer + 4);
                if (ret < 0)
                        return ret;
                ret = usb6fire_fw_fpga_upload(intf, "6fire/dmx6firecf.bin");
@@ -402,14 +406,14 @@ int usb6fire_fw_init(struct usb_interface *intf)
        }
        /* all fw loaded? */
        else if (buffer[3] == 0x03)
-               return usb6fire_fw_check(buffer + 4);
+               return usb6fire_fw_check(intf, buffer + 4);
        /* unknown data? */
        else {
-               snd_printk(KERN_ERR PREFIX "unknown device firmware state "
-                               "received from device: ");
+               dev_err(&intf->dev,
+                       "unknown device firmware state received from device: ");
                for (i = 0; i < 8; i++)
-                       snd_printk("%02x ", buffer[i]);
-               snd_printk("\n");
+                       printk(KERN_CONT "%02x ", buffer[i]);
+               printk(KERN_CONT "\n");
                return -EIO;
        }
        return 0;
index f3dd7266c391c7f17dae6220ed094f548a1d4507..3d410969553e2da2748b0587416fb5a8e8b41aab 100644 (file)
@@ -41,8 +41,9 @@ static void usb6fire_midi_out_handler(struct urb *urb)
 
                        ret = usb_submit_urb(urb, GFP_ATOMIC);
                        if (ret < 0)
-                               snd_printk(KERN_ERR PREFIX "midi out urb "
-                                               "submit failed: %d\n", ret);
+                               dev_err(&urb->dev->dev,
+                                       "midi out urb submit failed: %d\n",
+                                       ret);
                } else /* no more data to transmit */
                        rt->out = NULL;
        }
@@ -94,8 +95,9 @@ static void usb6fire_midi_out_trigger(
 
                        ret = usb_submit_urb(urb, GFP_ATOMIC);
                        if (ret < 0)
-                               snd_printk(KERN_ERR PREFIX "midi out urb "
-                                               "submit failed: %d\n", ret);
+                               dev_err(&urb->dev->dev,
+                                       "midi out urb submit failed: %d\n",
+                                       ret);
                        else
                                rt->out = alsa_sub;
                }
@@ -181,7 +183,7 @@ int usb6fire_midi_init(struct sfire_chip *chip)
        if (ret < 0) {
                kfree(rt->out_buffer);
                kfree(rt);
-               snd_printk(KERN_ERR PREFIX "unable to create midi.\n");
+               dev_err(&chip->dev->dev, "unable to create midi.\n");
                return ret;
        }
        rt->instance->private_data = rt;
index b5eb97fdc842f79893adc8d359c4e519df82d700..ba40489b2de4fd26ab69ca8d9fc619f36c6e6493 100644 (file)
@@ -79,32 +79,35 @@ static int usb6fire_pcm_set_rate(struct pcm_runtime *rt)
        ctrl_rt->usb_streaming = false;
        ret = ctrl_rt->update_streaming(ctrl_rt);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "error stopping streaming while "
-                               "setting samplerate %d.\n", rates[rt->rate]);
+               dev_err(&rt->chip->dev->dev,
+                       "error stopping streaming while setting samplerate %d.\n",
+                       rates[rt->rate]);
                return ret;
        }
 
        ret = ctrl_rt->set_rate(ctrl_rt, rt->rate);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "error setting samplerate %d.\n",
-                               rates[rt->rate]);
+               dev_err(&rt->chip->dev->dev,
+                       "error setting samplerate %d.\n",
+                       rates[rt->rate]);
                return ret;
        }
 
        ret = ctrl_rt->set_channels(ctrl_rt, OUT_N_CHANNELS, IN_N_CHANNELS,
                        false, false);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "error initializing channels "
-                               "while setting samplerate %d.\n",
-                               rates[rt->rate]);
+               dev_err(&rt->chip->dev->dev,
+                       "error initializing channels while setting samplerate %d.\n",
+                       rates[rt->rate]);
                return ret;
        }
 
        ctrl_rt->usb_streaming = true;
        ret = ctrl_rt->update_streaming(ctrl_rt);
        if (ret < 0) {
-               snd_printk(KERN_ERR PREFIX "error starting streaming while "
-                               "setting samplerate %d.\n", rates[rt->rate]);
+               dev_err(&rt->chip->dev->dev,
+                       "error starting streaming while setting samplerate %d.\n",
+                       rates[rt->rate]);
                return ret;
        }
 
@@ -124,7 +127,7 @@ static struct pcm_substream *usb6fire_pcm_get_substream(
                return &rt->playback;
        else if (alsa_sub->stream == SNDRV_PCM_STREAM_CAPTURE)
                return &rt->capture;
-       snd_printk(KERN_ERR PREFIX "error getting pcm substream slot.\n");
+       dev_err(&rt->chip->dev->dev, "error getting pcm substream slot.\n");
        return NULL;
 }
 
@@ -257,7 +260,7 @@ static void usb6fire_pcm_playback(struct pcm_substream *sub,
        else if (alsa_rt->format == SNDRV_PCM_FORMAT_S24_LE)
                dest = (u32 *) (urb->buffer);
        else {
-               snd_printk(KERN_ERR PREFIX "Unknown sample format.");
+               dev_err(&rt->chip->dev->dev, "Unknown sample format.");
                return;
        }
 
@@ -307,8 +310,8 @@ static void usb6fire_pcm_in_urb_handler(struct urb *usb_urb)
                }
 
        if (rt->stream_state == STREAM_DISABLED) {
-               snd_printk(KERN_ERR PREFIX "internal error: "
-                               "stream disabled in in-urb handler.\n");
+               dev_err(&rt->chip->dev->dev,
+                       "internal error: stream disabled in in-urb handler.\n");
                return;
        }
 
@@ -410,7 +413,7 @@ static int usb6fire_pcm_open(struct snd_pcm_substream *alsa_sub)
 
        if (!sub) {
                mutex_unlock(&rt->stream_mutex);
-               snd_printk(KERN_ERR PREFIX "invalid stream type.\n");
+               dev_err(&rt->chip->dev->dev, "invalid stream type.\n");
                return -EINVAL;
        }
 
@@ -481,8 +484,9 @@ static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub)
                                break;
                if (rt->rate == ARRAY_SIZE(rates)) {
                        mutex_unlock(&rt->stream_mutex);
-                       snd_printk("invalid rate %d in prepare.\n",
-                                       alsa_rt->rate);
+                       dev_err(&rt->chip->dev->dev,
+                               "invalid rate %d in prepare.\n",
+                               alsa_rt->rate);
                        return -EINVAL;
                }
 
@@ -494,8 +498,8 @@ static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub)
                ret = usb6fire_pcm_stream_start(rt);
                if (ret) {
                        mutex_unlock(&rt->stream_mutex);
-                       snd_printk(KERN_ERR PREFIX
-                                       "could not start pcm stream.\n");
+                       dev_err(&rt->chip->dev->dev,
+                               "could not start pcm stream.\n");
                        return ret;
                }
        }
@@ -650,7 +654,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
        if (ret < 0) {
                usb6fire_pcm_buffers_destroy(rt);
                kfree(rt);
-               snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n");
+               dev_err(&chip->dev->dev, "cannot create pcm instance.\n");
                return ret;
        }
 
@@ -662,8 +666,8 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
        if (ret) {
                usb6fire_pcm_buffers_destroy(rt);
                kfree(rt);
-               snd_printk(KERN_ERR PREFIX
-                               "error preallocating pcm buffers.\n");
+               dev_err(&chip->dev->dev,
+                       "error preallocating pcm buffers.\n");
                return ret;
        }
        rt->instance = pcm;
index bc55f708a696d11a3302e87557fa8dfef15ac5f0..b871ba407e4ec8aa710c5f79a99f2e52fb7741b7 100644 (file)
@@ -418,8 +418,9 @@ static int create_card(struct usb_device *usb_dev,
        if (devnum >= SNDRV_CARDS)
                return -ENODEV;
 
-       err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
-                             sizeof(struct snd_usb_caiaqdev), &card);
+       err = snd_card_new(&intf->dev,
+                          index[devnum], id[devnum], THIS_MODULE,
+                          sizeof(struct snd_usb_caiaqdev), &card);
        if (err < 0)
                return err;
 
@@ -429,7 +430,6 @@ static int create_card(struct usb_device *usb_dev,
        cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
                                  le16_to_cpu(usb_dev->descriptor.idProduct));
        spin_lock_init(&cdev->spinlock);
-       snd_card_set_dev(card, &intf->dev);
 
        *cardp = card;
        return 0;
index d979050e6a6afbc7daf9b65f666c2de10dbb6269..893d5a1afc3ce6bf854a61ef0c3f4f54cc552d0d 100644 (file)
@@ -139,8 +139,8 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
        struct usb_interface *iface = usb_ifnum_to_if(dev, interface);
 
        if (!iface) {
-               snd_printk(KERN_ERR "%d:%u:%d : does not exist\n",
-                          dev->devnum, ctrlif, interface);
+               dev_err(&dev->dev, "%u:%d : does not exist\n",
+                       ctrlif, interface);
                return -EINVAL;
        }
 
@@ -165,8 +165,8 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
        }
 
        if (usb_interface_claimed(iface)) {
-               snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n",
-                                               dev->devnum, ctrlif, interface);
+               dev_dbg(&dev->dev, "%d:%d: skipping, already claimed\n",
+                       ctrlif, interface);
                return -EINVAL;
        }
 
@@ -176,8 +176,9 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
                int err = snd_usbmidi_create(chip->card, iface,
                                             &chip->midi_list, NULL);
                if (err < 0) {
-                       snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n",
-                                               dev->devnum, ctrlif, interface);
+                       dev_err(&dev->dev,
+                               "%u:%d: cannot create sequencer device\n",
+                               ctrlif, interface);
                        return -EINVAL;
                }
                usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
@@ -188,14 +189,15 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
        if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
             altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
            altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) {
-               snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n",
-                                       dev->devnum, ctrlif, interface, altsd->bInterfaceClass);
+               dev_dbg(&dev->dev,
+                       "%u:%d: skipping non-supported interface %d\n",
+                       ctrlif, interface, altsd->bInterfaceClass);
                /* skip non-supported classes */
                return -EINVAL;
        }
 
        if (snd_usb_get_speed(dev) == USB_SPEED_LOW) {
-               snd_printk(KERN_ERR "low speed audio streaming not supported\n");
+               dev_err(&dev->dev, "low speed audio streaming not supported\n");
                return -EINVAL;
        }
 
@@ -228,26 +230,27 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
        protocol = altsd->bInterfaceProtocol;
 
        if (!control_header) {
-               snd_printk(KERN_ERR "cannot find UAC_HEADER\n");
+               dev_err(&dev->dev, "cannot find UAC_HEADER\n");
                return -EINVAL;
        }
 
        switch (protocol) {
        default:
-               snd_printdd(KERN_WARNING "unknown interface protocol %#02x, assuming v1\n",
-                           protocol);
+               dev_warn(&dev->dev,
+                        "unknown interface protocol %#02x, assuming v1\n",
+                        protocol);
                /* fall through */
 
        case UAC_VERSION_1: {
                struct uac1_ac_header_descriptor *h1 = control_header;
 
                if (!h1->bInCollection) {
-                       snd_printk(KERN_INFO "skipping empty audio interface (v1)\n");
+                       dev_info(&dev->dev, "skipping empty audio interface (v1)\n");
                        return -EINVAL;
                }
 
                if (h1->bLength < sizeof(*h1) + h1->bInCollection) {
-                       snd_printk(KERN_ERR "invalid UAC_HEADER (v1)\n");
+                       dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n");
                        return -EINVAL;
                }
 
@@ -277,7 +280,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
                }
 
                if (!assoc) {
-                       snd_printk(KERN_ERR "Audio class v2 interfaces need an interface association\n");
+                       dev_err(&dev->dev, "Audio class v2 interfaces need an interface association\n");
                        return -EINVAL;
                }
 
@@ -328,7 +331,8 @@ static void remove_trailing_spaces(char *str)
 /*
  * create a chip instance and set its names.
  */
-static int snd_usb_audio_create(struct usb_device *dev, int idx,
+static int snd_usb_audio_create(struct usb_interface *intf,
+                               struct usb_device *dev, int idx,
                                const struct snd_usb_audio_quirk *quirk,
                                struct snd_usb_audio **rchip)
 {
@@ -350,13 +354,14 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
        case USB_SPEED_SUPER:
                break;
        default:
-               snd_printk(KERN_ERR "unknown device speed %d\n", snd_usb_get_speed(dev));
+               dev_err(&dev->dev, "unknown device speed %d\n", snd_usb_get_speed(dev));
                return -ENXIO;
        }
 
-       err = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card);
+       err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
+                          0, &card);
        if (err < 0) {
-               snd_printk(KERN_ERR "cannot create card instance %d\n", idx);
+               dev_err(&dev->dev, "cannot create card instance %d\n", idx);
                return err;
        }
 
@@ -497,7 +502,7 @@ snd_usb_audio_probe(struct usb_device *dev,
        for (i = 0; i < SNDRV_CARDS; i++) {
                if (usb_chip[i] && usb_chip[i]->dev == dev) {
                        if (usb_chip[i]->shutdown) {
-                               snd_printk(KERN_ERR "USB device is in the shutdown state, cannot create a card instance\n");
+                               dev_err(&dev->dev, "USB device is in the shutdown state, cannot create a card instance\n");
                                goto __error;
                        }
                        chip = usb_chip[i];
@@ -513,15 +518,15 @@ snd_usb_audio_probe(struct usb_device *dev,
                        if (enable[i] && ! usb_chip[i] &&
                            (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
                            (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
-                               if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) {
+                               if (snd_usb_audio_create(intf, dev, i, quirk,
+                                                        &chip) < 0) {
                                        goto __error;
                                }
-                               snd_card_set_dev(chip->card, &intf->dev);
                                chip->pm_intf = intf;
                                break;
                        }
                if (!chip) {
-                       printk(KERN_ERR "no available usb audio device\n");
+                       dev_err(&dev->dev, "no available usb audio device\n");
                        goto __error;
                }
        }
@@ -691,12 +696,12 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
        }
 
        list_for_each_entry(mixer, &chip->mixer_list, list)
-               snd_usb_mixer_inactivate(mixer);
+               snd_usb_mixer_suspend(mixer);
 
        return 0;
 }
 
-static int usb_audio_resume(struct usb_interface *intf)
+static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
 {
        struct snd_usb_audio *chip = usb_get_intfdata(intf);
        struct usb_mixer_interface *mixer;
@@ -711,7 +716,7 @@ static int usb_audio_resume(struct usb_interface *intf)
         * we just notify and restart the mixers
         */
        list_for_each_entry(mixer, &chip->mixer_list, list) {
-               err = snd_usb_mixer_activate(mixer);
+               err = snd_usb_mixer_resume(mixer, reset_resume);
                if (err < 0)
                        goto err_out;
        }
@@ -723,9 +728,20 @@ static int usb_audio_resume(struct usb_interface *intf)
 err_out:
        return err;
 }
+
+static int usb_audio_resume(struct usb_interface *intf)
+{
+       return __usb_audio_resume(intf, false);
+}
+
+static int usb_audio_reset_resume(struct usb_interface *intf)
+{
+       return __usb_audio_resume(intf, true);
+}
 #else
 #define usb_audio_suspend      NULL
 #define usb_audio_resume       NULL
+#define usb_audio_reset_resume NULL
 #endif         /* CONFIG_PM */
 
 static struct usb_device_id usb_audio_ids [] = {
@@ -747,6 +763,7 @@ static struct usb_driver usb_audio_driver = {
        .disconnect =   usb_audio_disconnect,
        .suspend =      usb_audio_suspend,
        .resume =       usb_audio_resume,
+       .reset_resume = usb_audio_reset_resume,
        .id_table =     usb_audio_ids,
        .supports_autosuspend = 1,
 };
index 86f80c60b21f91202c8c17c40d7981c3d7f873f8..03fed6611d9e83d489e2ab66d94320c84eed4c18 100644 (file)
@@ -115,9 +115,9 @@ static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_i
                return ret;
 
        if (ret != sizeof(pin)) {
-               snd_printk(KERN_ERR
-                       "usb-audio:%d: setting selector (id %d) unexpected length %d\n",
-                       chip->dev->devnum, selector_id, ret);
+               usb_audio_err(chip,
+                       "setting selector (id %d) unexpected length %d\n",
+                       selector_id, ret);
                return -EINVAL;
        }
 
@@ -126,9 +126,9 @@ static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_i
                return ret;
 
        if (ret != pin) {
-               snd_printk(KERN_ERR
-                       "usb-audio:%d: setting selector (id %d) to %x failed (current: %d)\n",
-                       chip->dev->devnum, selector_id, pin, ret);
+               usb_audio_err(chip,
+                       "setting selector (id %d) to %x failed (current: %d)\n",
+                       selector_id, pin, ret);
                return -EINVAL;
        }
 
@@ -158,7 +158,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
                              &data, sizeof(data));
 
        if (err < 0) {
-               snd_printk(KERN_WARNING "%s(): cannot get clock validity for id %d\n",
+               dev_warn(&dev->dev,
+                        "%s(): cannot get clock validity for id %d\n",
                           __func__, source_id);
                return 0;
        }
@@ -177,9 +178,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
        entity_id &= 0xff;
 
        if (test_and_set_bit(entity_id, visited)) {
-               snd_printk(KERN_WARNING
-                       "%s(): recursive clock topology detected, id %d.\n",
-                       __func__, entity_id);
+               usb_audio_warn(chip,
+                        "%s(): recursive clock topology detected, id %d.\n",
+                        __func__, entity_id);
                return -EINVAL;
        }
 
@@ -188,8 +189,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
        if (source) {
                entity_id = source->bClockID;
                if (validate && !uac_clock_source_is_valid(chip, entity_id)) {
-                       snd_printk(KERN_ERR "usb-audio:%d: clock source %d is not valid, cannot use\n",
-                                  chip->dev->devnum, entity_id);
+                       usb_audio_err(chip,
+                               "clock source %d is not valid, cannot use\n",
+                               entity_id);
                        return -ENXIO;
                }
                return entity_id;
@@ -208,7 +210,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
                /* Selector values are one-based */
 
                if (ret > selector->bNrInPins || ret < 1) {
-                       snd_printk(KERN_ERR
+                       usb_audio_err(chip,
                                "%s(): selector reported illegal value, id %d, ret %d\n",
                                __func__, selector->bClockID, ret);
 
@@ -237,9 +239,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
                        if (err < 0)
                                continue;
 
-                       snd_printk(KERN_INFO
-                               "usb-audio:%d: found and selected valid clock source %d\n",
-                               chip->dev->devnum, ret);
+                       usb_audio_info(chip,
+                                "found and selected valid clock source %d\n",
+                                ret);
                        return ret;
                }
 
@@ -296,8 +298,8 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
                                   USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
                                   UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
                                   data, sizeof(data))) < 0) {
-               snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
-                          dev->devnum, iface, fmt->altsetting, rate, ep);
+               dev_err(&dev->dev, "%d:%d: cannot set freq %d to ep %#x\n",
+                       iface, fmt->altsetting, rate, ep);
                return err;
        }
 
@@ -305,14 +307,14 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
                                   USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
                                   UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
                                   data, sizeof(data))) < 0) {
-               snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
-                          dev->devnum, iface, fmt->altsetting, ep);
+               dev_err(&dev->dev, "%d:%d: cannot get freq at ep %#x\n",
+                       iface, fmt->altsetting, ep);
                return 0; /* some devices don't support reading */
        }
 
        crate = data[0] | (data[1] << 8) | (data[2] << 16);
        if (crate != rate) {
-               snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate);
+               dev_warn(&dev->dev, "current rate %d is different from the runtime rate %d\n", crate, rate);
                // runtime->rate = crate;
        }
 
@@ -332,8 +334,8 @@ static int get_sample_rate_v2(struct snd_usb_audio *chip, int iface,
                              snd_usb_ctrl_intf(chip) | (clock << 8),
                              &data, sizeof(data));
        if (err < 0) {
-               snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2): err %d\n",
-                          dev->devnum, iface, altsetting, err);
+               dev_warn(&dev->dev, "%d:%d: cannot get freq (v2): err %d\n",
+                        iface, altsetting, err);
                return 0;
        }
 
@@ -369,8 +371,9 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
                                      snd_usb_ctrl_intf(chip) | (clock << 8),
                                      &data, sizeof(data));
                if (err < 0) {
-                       snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2): err %d\n",
-                                  dev->devnum, iface, fmt->altsetting, rate, err);
+                       usb_audio_err(chip,
+                               "%d:%d: cannot set freq %d (v2): err %d\n",
+                               iface, fmt->altsetting, rate, err);
                        return err;
                }
 
@@ -381,14 +384,14 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
 
        if (cur_rate != rate) {
                if (!writeable) {
-                       snd_printk(KERN_WARNING
-                                  "%d:%d:%d: freq mismatch (RO clock): req %d, clock runs @%d\n",
-                                  dev->devnum, iface, fmt->altsetting, rate, cur_rate);
+                       usb_audio_warn(chip,
+                                "%d:%d: freq mismatch (RO clock): req %d, clock runs @%d\n",
+                                iface, fmt->altsetting, rate, cur_rate);
                        return -ENXIO;
                }
-               snd_printd(KERN_WARNING
-                          "current rate %d is different from the runtime rate %d\n",
-                          cur_rate, rate);
+               usb_audio_dbg(chip,
+                       "current rate %d is different from the runtime rate %d\n",
+                       cur_rate, rate);
        }
 
        /* Some devices doesn't respond to sample rate changes while the
index 83aabea259d7113d82d94d870bd04ebffd64b633..e70a87e0d9fe6402765afa0741b9f974b1259bec 100644 (file)
@@ -333,8 +333,9 @@ static void queue_pending_output_urbs(struct snd_usb_endpoint *ep)
 
                err = usb_submit_urb(ctx->urb, GFP_ATOMIC);
                if (err < 0)
-                       snd_printk(KERN_ERR "Unable to submit urb #%d: %d (urb %p)\n",
-                                  ctx->index, err, ctx->urb);
+                       usb_audio_err(ep->chip,
+                               "Unable to submit urb #%d: %d (urb %p)\n",
+                               ctx->index, err, ctx->urb);
                else
                        set_bit(ctx->index, &ep->active_mask);
        }
@@ -387,7 +388,7 @@ static void snd_complete_urb(struct urb *urb)
        if (err == 0)
                return;
 
-       snd_printk(KERN_ERR "cannot submit urb (err = %d)\n", err);
+       usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err);
        //snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
 
 exit_clear:
@@ -426,13 +427,14 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
                if (ep->ep_num == ep_num &&
                    ep->iface == alts->desc.bInterfaceNumber &&
                    ep->altsetting == alts->desc.bAlternateSetting) {
-                       snd_printdd(KERN_DEBUG "Re-using EP %x in iface %d,%d @%p\n",
+                       usb_audio_dbg(ep->chip,
+                                     "Re-using EP %x in iface %d,%d @%p\n",
                                        ep_num, ep->iface, ep->altsetting, ep);
                        goto __exit_unlock;
                }
        }
 
-       snd_printdd(KERN_DEBUG "Creating new %s %s endpoint #%x\n",
+       usb_audio_dbg(chip, "Creating new %s %s endpoint #%x\n",
                    is_playback ? "playback" : "capture",
                    type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync",
                    ep_num);
@@ -496,8 +498,9 @@ static int wait_clear_urbs(struct snd_usb_endpoint *ep)
        } while (time_before(jiffies, end_time));
 
        if (alive)
-               snd_printk(KERN_ERR "timeout: still %d active urbs on EP #%x\n",
-                                       alive, ep->ep_num);
+               usb_audio_err(ep->chip,
+                       "timeout: still %d active urbs on EP #%x\n",
+                       alive, ep->ep_num);
        clear_bit(EP_FLAG_STOPPING, &ep->flags);
 
        return 0;
@@ -794,8 +797,9 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
        int err;
 
        if (ep->use_count != 0) {
-               snd_printk(KERN_WARNING "Unable to change format on ep #%x: already in use\n",
-                          ep->ep_num);
+               usb_audio_warn(ep->chip,
+                        "Unable to change format on ep #%x: already in use\n",
+                        ep->ep_num);
                return -EBUSY;
        }
 
@@ -830,8 +834,9 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
                err = -EINVAL;
        }
 
-       snd_printdd(KERN_DEBUG "Setting params for ep #%x (type %d, %d urbs), ret=%d\n",
-                  ep->ep_num, ep->type, ep->nurbs, err);
+       usb_audio_dbg(ep->chip,
+               "Setting params for ep #%x (type %d, %d urbs), ret=%d\n",
+               ep->ep_num, ep->type, ep->nurbs, err);
 
        return err;
 }
@@ -906,8 +911,9 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
 
                err = usb_submit_urb(urb, GFP_ATOMIC);
                if (err < 0) {
-                       snd_printk(KERN_ERR "cannot submit urb %d, error %d: %s\n",
-                                  i, err, usb_error_string(err));
+                       usb_audio_err(ep->chip,
+                               "cannot submit urb %d, error %d: %s\n",
+                               i, err, usb_error_string(err));
                        goto __error;
                }
                set_bit(i, &ep->active_mask);
index d244fd3703d8382c85989b6934611e418600c728..8bcc87cf5667efbebc164e000f07cae23fc2a4c2 100644 (file)
@@ -74,8 +74,8 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
        if ((pcm_formats == 0) &&
            (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) {
                /* some devices don't define this correctly... */
-               snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n",
-                           chip->dev->devnum, fp->iface, fp->altsetting);
+               usb_audio_info(chip, "%u:%d : format type 0 is detected, processed as PCM\n",
+                       fp->iface, fp->altsetting);
                format = 1 << UAC_FORMAT_TYPE_I_PCM;
        }
        if (format & (1 << UAC_FORMAT_TYPE_I_PCM)) {
@@ -83,9 +83,9 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
                    sample_width == 24 && sample_bytes == 2)
                        sample_bytes = 3;
                else if (sample_width > sample_bytes * 8) {
-                       snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n",
-                                  chip->dev->devnum, fp->iface, fp->altsetting,
-                                  sample_width, sample_bytes);
+                       usb_audio_info(chip, "%u:%d : sample bitwidth %d in over sample bytes %d\n",
+                                fp->iface, fp->altsetting,
+                                sample_width, sample_bytes);
                }
                /* check the format byte size */
                switch (sample_bytes) {
@@ -108,9 +108,10 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
                        pcm_formats |= SNDRV_PCM_FMTBIT_S32_LE;
                        break;
                default:
-                       snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n",
-                                  chip->dev->devnum, fp->iface, fp->altsetting,
-                                  sample_width, sample_bytes);
+                       usb_audio_info(chip,
+                                "%u:%d : unsupported sample bitwidth %d in %d bytes\n",
+                                fp->iface, fp->altsetting,
+                                sample_width, sample_bytes);
                        break;
                }
        }
@@ -132,8 +133,9 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
                pcm_formats |= SNDRV_PCM_FMTBIT_MU_LAW;
        }
        if (format & ~0x3f) {
-               snd_printk(KERN_INFO "%d:%u:%d : unsupported format bits %#x\n",
-                          chip->dev->devnum, fp->iface, fp->altsetting, format);
+               usb_audio_info(chip,
+                        "%u:%d : unsupported format bits %#x\n",
+                        fp->iface, fp->altsetting, format);
        }
 
        pcm_formats |= snd_usb_interface_dsd_format_quirks(chip, fp, sample_bytes);
@@ -158,8 +160,9 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
        int nr_rates = fmt[offset];
 
        if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) {
-               snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n",
-                                  chip->dev->devnum, fp->iface, fp->altsetting);
+               usb_audio_err(chip,
+                       "%u:%d : invalid UAC_FORMAT_TYPE desc\n",
+                       fp->iface, fp->altsetting);
                return -EINVAL;
        }
 
@@ -171,7 +174,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
 
                fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
                if (fp->rate_table == NULL) {
-                       snd_printk(KERN_ERR "cannot malloc\n");
+                       usb_audio_err(chip, "cannot malloc\n");
                        return -ENOMEM;
                }
 
@@ -222,7 +225,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
  * get to know how many sample rates we have to expect.
  * Then fp->rate_table can be allocated and filled.
  */
-static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
+static int parse_uac2_sample_rate_range(struct snd_usb_audio *chip,
+                                       struct audioformat *fp, int nr_triplets,
                                        const unsigned char *data)
 {
        int i, nr_rates = 0;
@@ -261,7 +265,7 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
 
                        nr_rates++;
                        if (nr_rates >= MAX_NR_RATES) {
-                               snd_printk(KERN_ERR "invalid uac2 rates\n");
+                               usb_audio_err(chip, "invalid uac2 rates\n");
                                break;
                        }
 
@@ -287,7 +291,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
        int clock = snd_usb_clock_find_source(chip, fp->clock, false);
 
        if (clock < 0) {
-               snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n",
+               dev_err(&dev->dev,
+                       "%s(): unable to find clock source (clock %d)\n",
                                __func__, clock);
                goto err;
        }
@@ -300,7 +305,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
                              tmp, sizeof(tmp));
 
        if (ret < 0) {
-               snd_printk(KERN_ERR "%s(): unable to retrieve number of sample rates (clock %d)\n",
+               dev_err(&dev->dev,
+                       "%s(): unable to retrieve number of sample rates (clock %d)\n",
                                __func__, clock);
                goto err;
        }
@@ -321,7 +327,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
                              data, data_size);
 
        if (ret < 0) {
-               snd_printk(KERN_ERR "%s(): unable to retrieve sample rate range (clock %d)\n",
+               dev_err(&dev->dev,
+                       "%s(): unable to retrieve sample rate range (clock %d)\n",
                                __func__, clock);
                ret = -EINVAL;
                goto err_free;
@@ -332,7 +339,7 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
         * will have to deal with. */
        kfree(fp->rate_table);
        fp->rate_table = NULL;
-       fp->nr_rates = parse_uac2_sample_rate_range(fp, nr_triplets, data);
+       fp->nr_rates = parse_uac2_sample_rate_range(chip, fp, nr_triplets, data);
 
        if (fp->nr_rates == 0) {
                /* SNDRV_PCM_RATE_CONTINUOUS */
@@ -348,7 +355,7 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
 
        /* Call the triplet parser again, but this time, fp->rate_table is
         * allocated, so the rates will be stored */
-       parse_uac2_sample_rate_range(fp, nr_triplets, data);
+       parse_uac2_sample_rate_range(chip, fp, nr_triplets, data);
 
 err_free:
        kfree(data);
@@ -408,8 +415,9 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
        }
 
        if (fp->channels < 1) {
-               snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n",
-                          chip->dev->devnum, fp->iface, fp->altsetting, fp->channels);
+               usb_audio_err(chip,
+                       "%u:%d : invalid channels %d\n",
+                       fp->iface, fp->altsetting, fp->channels);
                return -EINVAL;
        }
 
@@ -435,8 +443,9 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
                fp->formats = SNDRV_PCM_FMTBIT_MPEG;
                break;
        default:
-               snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected.  processed as MPEG.\n",
-                          chip->dev->devnum, fp->iface, fp->altsetting, format);
+               usb_audio_info(chip,
+                        "%u:%d : unknown format tag %#x is detected.  processed as MPEG.\n",
+                        fp->iface, fp->altsetting, format);
                fp->formats = SNDRV_PCM_FMTBIT_MPEG;
                break;
        }
@@ -449,7 +458,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
                struct uac_format_type_ii_discrete_descriptor *fmt = _fmt;
                brate = le16_to_cpu(fmt->wMaxBitRate);
                framesize = le16_to_cpu(fmt->wSamplesPerFrame);
-               snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
+               usb_audio_info(chip, "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
                fp->frame_size = framesize;
                ret = parse_audio_format_rates_v1(chip, fp, _fmt, 8); /* fmt[8..] sample rates */
                break;
@@ -458,7 +467,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
                struct uac_format_type_ii_ext_descriptor *fmt = _fmt;
                brate = le16_to_cpu(fmt->wMaxBitRate);
                framesize = le16_to_cpu(fmt->wSamplesPerFrame);
-               snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
+               usb_audio_info(chip, "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
                fp->frame_size = framesize;
                ret = parse_audio_format_rates_v2(chip, fp);
                break;
@@ -484,9 +493,10 @@ int snd_usb_parse_audio_format(struct snd_usb_audio *chip,
                err = parse_audio_format_ii(chip, fp, format, fmt);
                break;
        default:
-               snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n",
-                          chip->dev->devnum, fp->iface, fp->altsetting,
-                          fmt->bFormatType);
+               usb_audio_info(chip,
+                        "%u:%d : format type %d is not supported yet\n",
+                        fp->iface, fp->altsetting,
+                        fmt->bFormatType);
                return -ENOTSUPP;
        }
        fp->fmt_type = fmt->bFormatType;
index b0dcb3924ce5139df00803072ac36ec4aa460888..2670d646bda91c2f26af878fc177eec1f772007c 100644 (file)
@@ -64,7 +64,8 @@ struct hiface_vendor_quirk {
        u8 extra_freq;
 };
 
-static int hiface_chip_create(struct usb_device *device, int idx,
+static int hiface_chip_create(struct usb_interface *intf,
+                             struct usb_device *device, int idx,
                              const struct hiface_vendor_quirk *quirk,
                              struct hiface_chip **rchip)
 {
@@ -76,7 +77,8 @@ static int hiface_chip_create(struct usb_device *device, int idx,
        *rchip = NULL;
 
        /* if we are here, card can be registered in alsa. */
-       ret = snd_card_create(index[idx], id[idx], THIS_MODULE, sizeof(*chip), &card);
+       ret = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
+                          sizeof(*chip), &card);
        if (ret < 0) {
                dev_err(&device->dev, "cannot create alsa card.\n");
                return ret;
@@ -132,12 +134,10 @@ static int hiface_chip_probe(struct usb_interface *intf,
                goto err;
        }
 
-       ret = hiface_chip_create(device, i, quirk, &chip);
+       ret = hiface_chip_create(intf, device, i, quirk, &chip);
        if (ret < 0)
                goto err;
 
-       snd_card_set_dev(chip->card, &intf->dev);
-
        ret = hiface_pcm_init(chip, quirk ? quirk->extra_freq : 0);
        if (ret < 0)
                goto err_chip_destroy;
index b901f468b67ada579739828b382e165713de324e..9da74d2e8eeec5f40cfbfc80d892f72e79cc4e04 100644 (file)
@@ -191,16 +191,16 @@ static int snd_usbmidi_submit_urb(struct urb* urb, gfp_t flags)
 {
        int err = usb_submit_urb(urb, flags);
        if (err < 0 && err != -ENODEV)
-               snd_printk(KERN_ERR "usb_submit_urb: %d\n", err);
+               dev_err(&urb->dev->dev, "usb_submit_urb: %d\n", err);
        return err;
 }
 
 /*
  * Error handling for URB completion functions.
  */
-static int snd_usbmidi_urb_error(int status)
+static int snd_usbmidi_urb_error(const struct urb *urb)
 {
-       switch (status) {
+       switch (urb->status) {
        /* manually unlinked, or device gone */
        case -ENOENT:
        case -ECONNRESET:
@@ -213,7 +213,7 @@ static int snd_usbmidi_urb_error(int status)
        case -EILSEQ:
                return -EIO;
        default:
-               snd_printk(KERN_ERR "urb status %d\n", status);
+               dev_err(&urb->dev->dev, "urb status %d\n", urb->status);
                return 0; /* continue */
        }
 }
@@ -227,7 +227,7 @@ static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint* ep, int port
        struct usbmidi_in_port* port = &ep->ports[portidx];
 
        if (!port->substream) {
-               snd_printd("unexpected port %d!\n", portidx);
+               dev_dbg(&ep->umidi->dev->dev, "unexpected port %d!\n", portidx);
                return;
        }
        if (!test_bit(port->substream->number, &ep->umidi->input_triggered))
@@ -259,7 +259,7 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb)
                ep->umidi->usb_protocol_ops->input(ep, urb->transfer_buffer,
                                                   urb->actual_length);
        } else {
-               int err = snd_usbmidi_urb_error(urb->status);
+               int err = snd_usbmidi_urb_error(urb);
                if (err < 0) {
                        if (err != -ENODEV) {
                                ep->error_resubmit = 1;
@@ -289,7 +289,7 @@ static void snd_usbmidi_out_urb_complete(struct urb* urb)
        }
        spin_unlock(&ep->buffer_lock);
        if (urb->status < 0) {
-               int err = snd_usbmidi_urb_error(urb->status);
+               int err = snd_usbmidi_urb_error(urb);
                if (err < 0) {
                        if (err != -ENODEV)
                                mod_timer(&ep->umidi->error_timer,
@@ -1668,7 +1668,7 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi,
 
        struct snd_rawmidi_substream *substream = snd_usbmidi_find_substream(umidi, stream, number);
        if (!substream) {
-               snd_printd(KERN_ERR "substream %d:%d not found\n", stream, number);
+               dev_err(&umidi->dev->dev, "substream %d:%d not found\n", stream, number);
                return;
        }
 
@@ -1717,7 +1717,7 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi,
                        }
                }
        }
-       snd_printdd(KERN_INFO "created %d output and %d input ports\n",
+       dev_dbg(&umidi->dev->dev, "created %d output and %d input ports\n",
                    out_ports, in_ports);
        return 0;
 }
@@ -1747,10 +1747,11 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
            ms_header->bLength >= 7 &&
            ms_header->bDescriptorType == USB_DT_CS_INTERFACE &&
            ms_header->bDescriptorSubtype == UAC_HEADER)
-               snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n",
+               dev_dbg(&umidi->dev->dev, "MIDIStreaming version %02x.%02x\n",
                            ms_header->bcdMSC[1], ms_header->bcdMSC[0]);
        else
-               snd_printk(KERN_WARNING "MIDIStreaming interface descriptor not found\n");
+               dev_warn(&umidi->dev->dev,
+                        "MIDIStreaming interface descriptor not found\n");
 
        epidx = 0;
        for (i = 0; i < intfd->bNumEndpoints; ++i) {
@@ -1767,7 +1768,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
                if (usb_endpoint_dir_out(ep)) {
                        if (endpoints[epidx].out_ep) {
                                if (++epidx >= MIDI_MAX_ENDPOINTS) {
-                                       snd_printk(KERN_WARNING "too many endpoints\n");
+                                       dev_warn(&umidi->dev->dev,
+                                                "too many endpoints\n");
                                        break;
                                }
                        }
@@ -1782,12 +1784,13 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
                                 */
                                endpoints[epidx].out_interval = 1;
                        endpoints[epidx].out_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1;
-                       snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n",
+                       dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n",
                                    ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
                } else {
                        if (endpoints[epidx].in_ep) {
                                if (++epidx >= MIDI_MAX_ENDPOINTS) {
-                                       snd_printk(KERN_WARNING "too many endpoints\n");
+                                       dev_warn(&umidi->dev->dev,
+                                                "too many endpoints\n");
                                        break;
                                }
                        }
@@ -1797,7 +1800,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
                        else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW)
                                endpoints[epidx].in_interval = 1;
                        endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1;
-                       snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n",
+                       dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n",
                                    ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
                }
        }
@@ -1865,7 +1868,7 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi)
            (get_endpoint(hostif, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
                return;
 
-       snd_printdd(KERN_INFO "switching to altsetting %d with int ep\n",
+       dev_dbg(&umidi->dev->dev, "switching to altsetting %d with int ep\n",
                    intfd->bAlternateSetting);
        usb_set_interface(umidi->dev, intfd->bInterfaceNumber,
                          intfd->bAlternateSetting);
@@ -2047,25 +2050,25 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
         * input bulk endpoints (at indices 1 and 3) which aren't used.
         */
        if (intfd->bNumEndpoints < (endpoint->out_cables > 0x0001 ? 5 : 3)) {
-               snd_printdd(KERN_ERR "not enough endpoints\n");
+               dev_dbg(&umidi->dev->dev, "not enough endpoints\n");
                return -ENOENT;
        }
 
        epd = get_endpoint(hostif, 0);
        if (!usb_endpoint_dir_in(epd) || !usb_endpoint_xfer_int(epd)) {
-               snd_printdd(KERN_ERR "endpoint[0] isn't interrupt\n");
+               dev_dbg(&umidi->dev->dev, "endpoint[0] isn't interrupt\n");
                return -ENXIO;
        }
        epd = get_endpoint(hostif, 2);
        if (!usb_endpoint_dir_out(epd) || !usb_endpoint_xfer_bulk(epd)) {
-               snd_printdd(KERN_ERR "endpoint[2] isn't bulk output\n");
+               dev_dbg(&umidi->dev->dev, "endpoint[2] isn't bulk output\n");
                return -ENXIO;
        }
        if (endpoint->out_cables > 0x0001) {
                epd = get_endpoint(hostif, 4);
                if (!usb_endpoint_dir_out(epd) ||
                    !usb_endpoint_xfer_bulk(epd)) {
-                       snd_printdd(KERN_ERR "endpoint[4] isn't bulk output\n");
+                       dev_dbg(&umidi->dev->dev, "endpoint[4] isn't bulk output\n");
                        return -ENXIO;
                }
        }
@@ -2289,7 +2292,7 @@ int snd_usbmidi_create(struct snd_card *card,
                err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
                break;
        default:
-               snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
+               dev_err(&umidi->dev->dev, "invalid quirk type %d\n", quirk->type);
                err = -ENXIO;
                break;
        }
index 509315937f25a7ea7ef389b373b2ac3fd37651a5..a1bab149df4d06ab1ba9fb4c725c19974841eb5d 100644 (file)
@@ -1243,8 +1243,9 @@ static int ua101_probe(struct usb_interface *interface,
                mutex_unlock(&devices_mutex);
                return -ENOENT;
        }
-       err = snd_card_create(index[card_index], id[card_index], THIS_MODULE,
-                             sizeof(*ua), &card);
+       err = snd_card_new(&interface->dev,
+                          index[card_index], id[card_index], THIS_MODULE,
+                          sizeof(*ua), &card);
        if (err < 0) {
                mutex_unlock(&devices_mutex);
                return err;
@@ -1283,8 +1284,6 @@ static int ua101_probe(struct usb_interface *interface,
                }
        }
 
-       snd_card_set_dev(card, &interface->dev);
-
        err = detect_usb_format(ua);
        if (err < 0)
                goto probe_error;
index 1bed780e21d96945d1cf913ce23fe31409df0cc4..d40a2850e2709f3a60100f707eb650a398fb73f3 100644 (file)
@@ -305,8 +305,9 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
                        goto out;
                }
        }
-       snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
-                   request, validx, idx, cval->val_type);
+       usb_audio_dbg(chip,
+               "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
+               request, validx, idx, cval->val_type);
        err = -EINVAL;
 
  out:
@@ -351,8 +352,9 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
 
        if (ret < 0) {
 error:
-               snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
-                          request, validx, idx, cval->val_type);
+               usb_audio_err(chip,
+                       "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
+                       request, validx, idx, cval->val_type);
                return ret;
        }
 
@@ -413,7 +415,8 @@ static int get_cur_mix_value(struct usb_mixer_elem_info *cval,
        err = get_cur_mix_raw(cval, channel, value);
        if (err < 0) {
                if (!cval->mixer->ignore_ctl_error)
-                       snd_printd(KERN_ERR "cannot get current value for control %d ch %d: err = %d\n",
+                       usb_audio_dbg(cval->mixer->chip,
+                               "cannot get current value for control %d ch %d: err = %d\n",
                                   cval->control, channel, err);
                return err;
        }
@@ -444,7 +447,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
 
                /* FIXME */
                if (request != UAC_SET_CUR) {
-                       snd_printdd(KERN_WARNING "RANGE setting not yet supported\n");
+                       usb_audio_dbg(chip, "RANGE setting not yet supported\n");
                        return -EINVAL;
                }
 
@@ -470,7 +473,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
                        goto out;
                }
        }
-       snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n",
+       usb_audio_dbg(chip, "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n",
                    request, validx, idx, cval->val_type, buf[0], buf[1]);
        err = -EINVAL;
 
@@ -494,7 +497,8 @@ static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
                cval->ch_readonly & (1 << (channel - 1));
 
        if (read_only) {
-               snd_printdd(KERN_INFO "%s(): channel %d of control %d is read_only\n",
+               usb_audio_dbg(cval->mixer->chip,
+                             "%s(): channel %d of control %d is read_only\n",
                            __func__, channel, cval->control);
                return 0;
        }
@@ -560,7 +564,7 @@ int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
        while (snd_ctl_find_id(mixer->chip->card, &kctl->id))
                kctl->id.index++;
        if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
-               snd_printd(KERN_ERR "cannot add control (err = %d)\n", err);
+               usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n", err);
                return err;
        }
        cval->elem_id = &kctl->id;
@@ -807,7 +811,8 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
 static void volume_control_quirks(struct usb_mixer_elem_info *cval,
                                  struct snd_kcontrol *kctl)
 {
-       switch (cval->mixer->chip->usb_id) {
+       struct snd_usb_audio *chip = cval->mixer->chip;
+       switch (chip->usb_id) {
        case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
        case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */
                if (strcmp(kctl->id.name, "Effect Duration") == 0) {
@@ -839,8 +844,8 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
        case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
        case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
                if (strcmp(kctl->id.name, "Effect Duration") == 0) {
-                       snd_printk(KERN_INFO
-                               "usb-audio: set quirk for FTU Effect Duration\n");
+                       usb_audio_info(chip,
+                                      "set quirk for FTU Effect Duration\n");
                        cval->min = 0x0000;
                        cval->max = 0x7f00;
                        cval->res = 0x0100;
@@ -848,8 +853,8 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
                }
                if (strcmp(kctl->id.name, "Effect Volume") == 0 ||
                    strcmp(kctl->id.name, "Effect Feedback Volume") == 0) {
-                       snd_printk(KERN_INFO
-                               "usb-audio: set quirks for FTU Effect Feedback/Volume\n");
+                       usb_audio_info(chip,
+                                      "set quirks for FTU Effect Feedback/Volume\n");
                        cval->min = 0x00;
                        cval->max = 0x7f;
                        break;
@@ -867,7 +872,7 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
         */
                if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
                    cval->min == -15616) {
-                       snd_printk(KERN_INFO
+                       usb_audio_info(chip,
                                 "set volume quirk for UDA1321/N101 chip\n");
                        cval->max = -256;
                }
@@ -875,7 +880,7 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
 
        case USB_ID(0x046d, 0x09a4):
                if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
-                       snd_printk(KERN_INFO
+                       usb_audio_info(chip,
                                "set volume quirk for QuickCam E3500\n");
                        cval->min = 6080;
                        cval->max = 8768;
@@ -896,7 +901,7 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
         * Proboly there is some logitech magic behind this number --fishor
         */
                if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
-                       snd_printk(KERN_INFO
+                       usb_audio_info(chip,
                                "set resolution quirk: cval->res = 384\n");
                        cval->res = 384;
                }
@@ -932,7 +937,8 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
                }
                if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 ||
                    get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) {
-                       snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n",
+                       usb_audio_err(cval->mixer->chip,
+                                     "%d:%d: cannot get min/max values for control %d (id %d)\n",
                                   cval->id, snd_usb_ctrl_intf(cval->mixer->chip), cval->control, cval->id);
                        return -EINVAL;
                }
@@ -1196,7 +1202,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
 
        cval = kzalloc(sizeof(*cval), GFP_KERNEL);
        if (! cval) {
-               snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+               usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                return;
        }
        cval->mixer = state->mixer;
@@ -1225,7 +1231,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
                kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);
 
        if (! kctl) {
-               snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+               usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                kfree(cval);
                return;
        }
@@ -1299,16 +1305,16 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
         * devices. It will definitively catch all buggy Logitech devices.
         */
        if (range > 384) {
-               snd_printk(KERN_WARNING "usb_audio: Warning! Unlikely big "
+               usb_audio_warn(state->chip, "Warning! Unlikely big "
                           "volume range (=%u), cval->res is probably wrong.",
                           range);
-               snd_printk(KERN_WARNING "usb_audio: [%d] FU [%s] ch = %d, "
+               usb_audio_warn(state->chip, "[%d] FU [%s] ch = %d, "
                           "val = %d/%d/%d", cval->id,
                           kctl->id.name, cval->channels,
                           cval->min, cval->max, cval->res);
        }
 
-       snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
+       usb_audio_dbg(state->chip, "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
                    cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
        snd_usb_mixer_add_control(state->mixer, kctl);
 }
@@ -1332,16 +1338,17 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
        if (state->mixer->protocol == UAC_VERSION_1) {
                csize = hdr->bControlSize;
                if (!csize) {
-                       snd_printdd(KERN_ERR "usbaudio: unit %u: "
-                                   "invalid bControlSize == 0\n", unitid);
+                       usb_audio_dbg(state->chip,
+                                     "unit %u: invalid bControlSize == 0\n",
+                                     unitid);
                        return -EINVAL;
                }
                channels = (hdr->bLength - 7) / csize - 1;
                bmaControls = hdr->bmaControls;
                if (hdr->bLength < 7 + csize) {
-                       snd_printk(KERN_ERR "usbaudio: unit %u: "
-                                  "invalid UAC_FEATURE_UNIT descriptor\n",
-                                  unitid);
+                       usb_audio_err(state->chip,
+                                     "unit %u: invalid UAC_FEATURE_UNIT descriptor\n",
+                                     unitid);
                        return -EINVAL;
                }
        } else {
@@ -1350,9 +1357,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
                channels = (hdr->bLength - 6) / 4 - 1;
                bmaControls = ftr->bmaControls;
                if (hdr->bLength < 6 + csize) {
-                       snd_printk(KERN_ERR "usbaudio: unit %u: "
-                                  "invalid UAC_FEATURE_UNIT descriptor\n",
-                                  unitid);
+                       usb_audio_err(state->chip,
+                                     "unit %u: invalid UAC_FEATURE_UNIT descriptor\n",
+                                     unitid);
                        return -EINVAL;
                }
        }
@@ -1370,14 +1377,14 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
        /* master configuration quirks */
        switch (state->chip->usb_id) {
        case USB_ID(0x08bb, 0x2702):
-               snd_printk(KERN_INFO
-                          "usbmixer: master volume quirk for PCM2702 chip\n");
+               usb_audio_info(state->chip,
+                              "usbmixer: master volume quirk for PCM2702 chip\n");
                /* disable non-functional volume control */
                master_bits &= ~UAC_CONTROL_BIT(UAC_FU_VOLUME);
                break;
        case USB_ID(0x1130, 0xf211):
-               snd_printk(KERN_INFO
-                          "usbmixer: volume control quirk for Tenx TP6911 Audio Headset\n");
+               usb_audio_info(state->chip,
+                              "usbmixer: volume control quirk for Tenx TP6911 Audio Headset\n");
                /* disable non-functional volume control */
                channels = 0;
                break;
@@ -1479,7 +1486,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
 
        kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);
        if (! kctl) {
-               snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+               usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                kfree(cval);
                return;
        }
@@ -1492,7 +1499,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
                len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1);
        append_ctl_name(kctl, " Volume");
 
-       snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n",
+       usb_audio_dbg(state->chip, "[%d] MU [%s] ch = %d, val = %d/%d\n",
                    cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
        snd_usb_mixer_add_control(state->mixer, kctl);
 }
@@ -1509,12 +1516,12 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, void *r
        int pin, ich, err;
 
        if (desc->bLength < 11 || ! (input_pins = desc->bNrInPins) || ! (num_outs = uac_mixer_unit_bNrChannels(desc))) {
-               snd_printk(KERN_ERR "invalid MIXER UNIT descriptor %d\n", unitid);
+               usb_audio_err(state->chip, "invalid MIXER UNIT descriptor %d\n", unitid);
                return -EINVAL;
        }
        /* no bmControls field (e.g. Maya44) -> ignore */
        if (desc->bLength <= 10 + input_pins) {
-               snd_printdd(KERN_INFO "MU %d has no bmControls field\n", unitid);
+               usb_audio_dbg(state->chip, "MU %d has no bmControls field\n", unitid);
                return 0;
        }
 
@@ -1713,7 +1720,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
 
        if (desc->bLength < 13 || desc->bLength < 13 + num_ins ||
            desc->bLength < num_ins + uac_processing_unit_bControlSize(desc, state->mixer->protocol)) {
-               snd_printk(KERN_ERR "invalid %s descriptor (id %d)\n", name, unitid);
+               usb_audio_err(state->chip, "invalid %s descriptor (id %d)\n", name, unitid);
                return -EINVAL;
        }
 
@@ -1739,7 +1746,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
                        continue;
                cval = kzalloc(sizeof(*cval), GFP_KERNEL);
                if (! cval) {
-                       snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+                       usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                        return -ENOMEM;
                }
                cval->mixer = state->mixer;
@@ -1771,7 +1778,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
 
                kctl = snd_ctl_new1(&mixer_procunit_ctl, cval);
                if (! kctl) {
-                       snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+                       usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                        kfree(cval);
                        return -ENOMEM;
                }
@@ -1793,7 +1800,8 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
                append_ctl_name(kctl, " ");
                append_ctl_name(kctl, valinfo->suffix);
 
-               snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n",
+               usb_audio_dbg(state->chip,
+                       "[%d] PU [%s] ch = %d, val = %d/%d\n",
                            cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
                if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0)
                        return err;
@@ -1918,7 +1926,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
        char **namelist;
 
        if (!desc->bNrInPins || desc->bLength < 5 + desc->bNrInPins) {
-               snd_printk(KERN_ERR "invalid SELECTOR UNIT descriptor %d\n", unitid);
+               usb_audio_err(state->chip,
+                       "invalid SELECTOR UNIT descriptor %d\n", unitid);
                return -EINVAL;
        }
 
@@ -1936,7 +1945,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
 
        cval = kzalloc(sizeof(*cval), GFP_KERNEL);
        if (! cval) {
-               snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+               usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                return -ENOMEM;
        }
        cval->mixer = state->mixer;
@@ -1955,7 +1964,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
 
        namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
        if (! namelist) {
-               snd_printk(KERN_ERR "cannot malloc\n");
+               usb_audio_err(state->chip, "cannot malloc\n");
                kfree(cval);
                return -ENOMEM;
        }
@@ -1965,7 +1974,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
                len = 0;
                namelist[i] = kmalloc(MAX_ITEM_NAME_LEN, GFP_KERNEL);
                if (! namelist[i]) {
-                       snd_printk(KERN_ERR "cannot malloc\n");
+                       usb_audio_err(state->chip, "cannot malloc\n");
                        while (i--)
                                kfree(namelist[i]);
                        kfree(namelist);
@@ -1982,7 +1991,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
 
        kctl = snd_ctl_new1(&mixer_selectunit_ctl, cval);
        if (! kctl) {
-               snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+               usb_audio_err(state->chip, "cannot malloc kcontrol\n");
                kfree(namelist);
                kfree(cval);
                return -ENOMEM;
@@ -2010,7 +2019,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
                        append_ctl_name(kctl, " Playback Source");
        }
 
-       snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n",
+       usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
                    cval->id, kctl->id.name, desc->bNrInPins);
        if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0)
                return err;
@@ -2032,7 +2041,7 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
 
        p1 = find_audio_control_unit(state, unitid);
        if (!p1) {
-               snd_printk(KERN_ERR "usbaudio: unit %d not found!\n", unitid);
+               usb_audio_err(state->chip, "unit %d not found!\n", unitid);
                return -EINVAL;
        }
 
@@ -2062,7 +2071,8 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
        case UAC2_EXTENSION_UNIT_V2:
                return parse_audio_extension_unit(state, unitid, p1);
        default:
-               snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]);
+               usb_audio_err(state->chip,
+                       "unit %u: unexpected type 0x%02x\n", unitid, p1[2]);
                return -EINVAL;
        }
 }
@@ -2210,8 +2220,9 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer,
        __u8 channel = value & 0xff;
 
        if (channel >= MAX_CHANNELS) {
-               snd_printk(KERN_DEBUG "%s(): bogus channel number %d\n",
-                               __func__, channel);
+               usb_audio_dbg(mixer->chip,
+                       "%s(): bogus channel number %d\n",
+                       __func__, channel);
                return;
        }
 
@@ -2240,8 +2251,9 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer,
                        break;
 
                default:
-                       snd_printk(KERN_DEBUG "unknown attribute %d in interrupt\n",
-                                               attribute);
+                       usb_audio_dbg(mixer->chip,
+                               "unknown attribute %d in interrupt\n",
+                               attribute);
                        break;
                } /* switch */
        }
@@ -2262,7 +2274,7 @@ static void snd_usb_mixer_interrupt(struct urb *urb)
                for (status = urb->transfer_buffer;
                     len >= sizeof(*status);
                     len -= sizeof(*status), status++) {
-                       snd_printd(KERN_DEBUG "status interrupt: %02x %02x\n",
+                       dev_dbg(&urb->dev->dev, "status interrupt: %02x %02x\n",
                                                status->bStatusType,
                                                status->bOriginator);
 
@@ -2300,26 +2312,6 @@ requeue:
        }
 }
 
-/* stop any bus activity of a mixer */
-void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer)
-{
-       usb_kill_urb(mixer->urb);
-       usb_kill_urb(mixer->rc_urb);
-}
-
-int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
-{
-       int err;
-
-       if (mixer->urb) {
-               err = usb_submit_urb(mixer->urb, GFP_NOIO);
-               if (err < 0)
-                       return err;
-       }
-
-       return 0;
-}
-
 /* create the handler for the optional status interrupt endpoint */
 static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer)
 {
@@ -2394,7 +2386,7 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
 
        snd_usb_mixer_apply_create_quirk(mixer);
 
-       err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops);
+       err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops);
        if (err < 0)
                goto _error;
 
@@ -2418,3 +2410,82 @@ void snd_usb_mixer_disconnect(struct list_head *p)
        usb_kill_urb(mixer->urb);
        usb_kill_urb(mixer->rc_urb);
 }
+
+#ifdef CONFIG_PM
+/* stop any bus activity of a mixer */
+static void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer)
+{
+       usb_kill_urb(mixer->urb);
+       usb_kill_urb(mixer->rc_urb);
+}
+
+static int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
+{
+       int err;
+
+       if (mixer->urb) {
+               err = usb_submit_urb(mixer->urb, GFP_NOIO);
+               if (err < 0)
+                       return err;
+       }
+
+       return 0;
+}
+
+int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer)
+{
+       snd_usb_mixer_inactivate(mixer);
+       return 0;
+}
+
+static int restore_mixer_value(struct usb_mixer_elem_info *cval)
+{
+       int c, err, idx;
+
+       if (cval->cmask) {
+               idx = 0;
+               for (c = 0; c < MAX_CHANNELS; c++) {
+                       if (!(cval->cmask & (1 << c)))
+                               continue;
+                       if (cval->cached & (1 << c)) {
+                               err = set_cur_mix_value(cval, c + 1, idx,
+                                                       cval->cache_val[idx]);
+                               if (err < 0)
+                                       return err;
+                       }
+                       idx++;
+               }
+       } else {
+               /* master */
+               if (cval->cached) {
+                       err = set_cur_mix_value(cval, 0, 0, *cval->cache_val);
+                       if (err < 0)
+                               return err;
+               }
+       }
+
+       return 0;
+}
+
+int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume)
+{
+       struct usb_mixer_elem_info *cval;
+       int id, err;
+
+       /* FIXME: any mixer quirks? */
+
+       if (reset_resume) {
+               /* restore cached mixer values */
+               for (id = 0; id < MAX_ID_ELEMS; id++) {
+                       for (cval = mixer->id_elems[id]; cval;
+                            cval = cval->next_id_elem) {
+                               err = restore_mixer_value(cval);
+                               if (err < 0)
+                                       return err;
+                       }
+               }
+       }
+
+       return snd_usb_mixer_activate(mixer);
+}
+#endif
index aab80df201bdde8f6015d9b2451abb0c24efddb7..73b1f649447bdb8de4fdc18e9e0ce89407f10d6c 100644 (file)
@@ -63,8 +63,6 @@ void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid);
 
 int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
                                int request, int validx, int value_set);
-void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer);
-int snd_usb_mixer_activate(struct usb_mixer_interface *mixer);
 
 int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
                              struct snd_kcontrol *kctl);
@@ -72,4 +70,9 @@ int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
 int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
                          unsigned int size, unsigned int __user *_tlv);
 
+#ifdef CONFIG_PM
+int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer);
+int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume);
+#endif
+
 #endif /* __USBMIXER_H */
index f4b12c216f1cd55c2db4396746a5abc9f20ed302..f119a41ed9a94986cc1ec1ccd99b1aac3c400260 100644 (file)
@@ -600,8 +600,8 @@ static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
        up_read(&mixer->chip->shutdown_rwsem);
 
        if (ret < 0) {
-               snd_printk(KERN_ERR
-                          "unable to issue vendor read request (ret = %d)", ret);
+               dev_err(&dev->dev,
+                       "unable to issue vendor read request (ret = %d)", ret);
                return ret;
        }
 
@@ -631,8 +631,8 @@ static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
        up_read(&mixer->chip->shutdown_rwsem);
 
        if (ret < 0) {
-               snd_printk(KERN_ERR
-                          "unable to issue vendor write request (ret = %d)", ret);
+               dev_err(&dev->dev,
+                       "unable to issue vendor write request (ret = %d)", ret);
                return ret;
        }
 
@@ -1699,7 +1699,7 @@ void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
                        snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
                break;
        default:
-               snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
+               usb_audio_dbg(mixer->chip, "memory change in unknown unit %d\n", unitid);
                break;
        }
 }
index ca3256d6fde3d1206ffe3fc7313305561438f611..49de5c1284f6c7d4df3cecaa227316fa8dbd830a 100644 (file)
@@ -166,8 +166,8 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface,
                                   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
                                   UAC_EP_CS_ATTR_PITCH_CONTROL << 8, ep,
                                   data, sizeof(data))) < 0) {
-               snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n",
-                          dev->devnum, iface, ep);
+               usb_audio_err(chip, "%d:%d: cannot set enable PITCH\n",
+                             iface, ep);
                return err;
        }
 
@@ -187,8 +187,8 @@ static int init_pitch_v2(struct snd_usb_audio *chip, int iface,
                                   USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
                                   UAC2_EP_CS_PITCH << 8, 0,
                                   data, sizeof(data))) < 0) {
-               snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH (v2)\n",
-                          dev->devnum, iface, fmt->altsetting);
+               usb_audio_err(chip, "%d:%d: cannot set enable PITCH (v2)\n",
+                             iface, fmt->altsetting);
                return err;
        }
 
@@ -226,7 +226,7 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
        if (!test_and_set_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) {
                struct snd_usb_endpoint *ep = subs->data_endpoint;
 
-               snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep);
+               dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep);
 
                ep->data_subs = subs;
                err = snd_usb_endpoint_start(ep, can_sleep);
@@ -247,16 +247,15 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
                                                subs->sync_endpoint->altsetting);
                        if (err < 0) {
                                clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
-                               snd_printk(KERN_ERR
-                                          "%d:%d:%d: cannot set interface (%d)\n",
-                                          subs->dev->devnum,
+                               dev_err(&subs->dev->dev,
+                                          "%d:%d: cannot set interface (%d)\n",
                                           subs->sync_endpoint->iface,
                                           subs->sync_endpoint->altsetting, err);
                                return -EIO;
                        }
                }
 
-               snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep);
+               dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep);
 
                ep->sync_slave = subs->data_endpoint;
                err = snd_usb_endpoint_start(ep, can_sleep);
@@ -410,8 +409,9 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
        if ((get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC ||
            (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE &&
             get_endpoint(alts, 1)->bSynchAddress != 0)) {
-               snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n",
-                          dev->devnum, fmt->iface, fmt->altsetting,
+               dev_err(&dev->dev,
+                       "%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n",
+                          fmt->iface, fmt->altsetting,
                           get_endpoint(alts, 1)->bmAttributes,
                           get_endpoint(alts, 1)->bLength,
                           get_endpoint(alts, 1)->bSynchAddress);
@@ -421,8 +421,9 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
        if (get_endpoint(alts, 0)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE &&
            ((is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) ||
             (!is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN)))) {
-               snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n",
-                          dev->devnum, fmt->iface, fmt->altsetting,
+               dev_err(&dev->dev,
+                       "%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n",
+                          fmt->iface, fmt->altsetting,
                           is_playback, ep, get_endpoint(alts, 0)->bSynchAddress);
                return -EINVAL;
        }
@@ -469,8 +470,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
        if (subs->interface >= 0 && subs->interface != fmt->iface) {
                err = usb_set_interface(subs->dev, subs->interface, 0);
                if (err < 0) {
-                       snd_printk(KERN_ERR "%d:%d:%d: return to setting 0 failed (%d)\n",
-                               dev->devnum, fmt->iface, fmt->altsetting, err);
+                       dev_err(&dev->dev,
+                               "%d:%d: return to setting 0 failed (%d)\n",
+                               fmt->iface, fmt->altsetting, err);
                        return -EIO;
                }
                subs->interface = -1;
@@ -482,12 +484,13 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
            subs->altset_idx != fmt->altset_idx) {
                err = usb_set_interface(dev, fmt->iface, fmt->altsetting);
                if (err < 0) {
-                       snd_printk(KERN_ERR "%d:%d:%d: usb_set_interface failed (%d)\n",
-                                  dev->devnum, fmt->iface, fmt->altsetting, err);
+                       dev_err(&dev->dev,
+                               "%d:%d: usb_set_interface failed (%d)\n",
+                               fmt->iface, fmt->altsetting, err);
                        return -EIO;
                }
-               snd_printdd(KERN_INFO "setting usb interface %d:%d\n",
-                               fmt->iface, fmt->altsetting);
+               dev_dbg(&dev->dev, "setting usb interface %d:%d\n",
+                       fmt->iface, fmt->altsetting);
                subs->interface = fmt->iface;
                subs->altset_idx = fmt->altset_idx;
 
@@ -523,20 +526,23 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
  * - Requested PCM format is not supported.
  * - Requested sample rate is not supported.
  */
-static int match_endpoint_audioformats(struct audioformat *fp,
-       struct audioformat *match, int rate,
-       snd_pcm_format_t pcm_format)
+static int match_endpoint_audioformats(struct snd_usb_substream *subs,
+                                      struct audioformat *fp,
+                                      struct audioformat *match, int rate,
+                                      snd_pcm_format_t pcm_format)
 {
        int i;
        int score = 0;
 
        if (fp->channels < 1) {
-               snd_printdd("%s: (fmt @%p) no channels\n", __func__, fp);
+               dev_dbg(&subs->dev->dev,
+                       "%s: (fmt @%p) no channels\n", __func__, fp);
                return 0;
        }
 
        if (!(fp->formats & pcm_format_to_bits(pcm_format))) {
-               snd_printdd("%s: (fmt @%p) no match for format %d\n", __func__,
+               dev_dbg(&subs->dev->dev,
+                       "%s: (fmt @%p) no match for format %d\n", __func__,
                        fp, pcm_format);
                return 0;
        }
@@ -548,7 +554,8 @@ static int match_endpoint_audioformats(struct audioformat *fp,
                }
        }
        if (!score) {
-               snd_printdd("%s: (fmt @%p) no match for rate %d\n", __func__,
+               dev_dbg(&subs->dev->dev,
+                       "%s: (fmt @%p) no match for rate %d\n", __func__,
                        fp, rate);
                return 0;
        }
@@ -556,7 +563,8 @@ static int match_endpoint_audioformats(struct audioformat *fp,
        if (fp->channels == match->channels)
                score++;
 
-       snd_printdd("%s: (fmt @%p) score %d\n", __func__, fp, score);
+       dev_dbg(&subs->dev->dev,
+               "%s: (fmt @%p) score %d\n", __func__, fp, score);
 
        return score;
 }
@@ -587,7 +595,8 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs)
 
        /* Try to find the best matching audioformat. */
        list_for_each_entry(fp, &sync_subs->fmt_list, list) {
-               int score = match_endpoint_audioformats(fp, subs->cur_audiofmt,
+               int score = match_endpoint_audioformats(subs,
+                                                       fp, subs->cur_audiofmt,
                        subs->cur_rate, subs->pcm_format);
 
                if (score > cur_score) {
@@ -597,7 +606,8 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs)
        }
 
        if (unlikely(sync_fp == NULL)) {
-               snd_printk(KERN_ERR "%s: no valid audioformat for sync ep %x found\n",
+               dev_err(&subs->dev->dev,
+                       "%s: no valid audioformat for sync ep %x found\n",
                        __func__, sync_subs->ep_num);
                return -EINVAL;
        }
@@ -609,7 +619,8 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs)
        if (sync_fp->channels != subs->channels) {
                sync_period_bytes = (subs->period_bytes / subs->channels) *
                        sync_fp->channels;
-               snd_printdd("%s: adjusted sync ep period bytes (%d -> %d)\n",
+               dev_dbg(&subs->dev->dev,
+                       "%s: adjusted sync ep period bytes (%d -> %d)\n",
                        __func__, subs->period_bytes, sync_period_bytes);
        }
 
@@ -685,7 +696,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
 
        fmt = find_format(subs);
        if (!fmt) {
-               snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n",
+               dev_dbg(&subs->dev->dev,
+                       "cannot set format: format = %#x, rate = %d, channels = %d\n",
                           subs->pcm_format, subs->cur_rate, subs->channels);
                return -EINVAL;
        }
@@ -742,7 +754,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
        int ret;
 
        if (! subs->cur_audiofmt) {
-               snd_printk(KERN_ERR "usbaudio: no format is specified!\n");
+               dev_err(&subs->dev->dev, "no format is specified!\n");
                return -ENXIO;
        }
 
@@ -1235,7 +1247,8 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
        for (i = 0; i < urb->number_of_packets; i++) {
                cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj;
                if (urb->iso_frame_desc[i].status && printk_ratelimit()) {
-                       snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status);
+                       dev_dbg(&subs->dev->dev, "frame %d active: %d\n",
+                               i, urb->iso_frame_desc[i].status);
                        // continue;
                }
                bytes = urb->iso_frame_desc[i].actual_length;
@@ -1245,7 +1258,8 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
                if (bytes % (runtime->sample_bits >> 3) != 0) {
                        int oldbytes = bytes;
                        bytes = frames * stride;
-                       snd_printdd(KERN_ERR "Corrected urb data len. %d->%d\n",
+                       dev_warn(&subs->dev->dev,
+                                "Corrected urb data len. %d->%d\n",
                                                        oldbytes, bytes);
                }
                /* update the current pointer */
@@ -1488,7 +1502,8 @@ static void retire_playback_urb(struct snd_usb_substream *subs,
         * on two reads of a counter updated every ms.
         */
        if (abs(est_delay - subs->last_delay) * 1000 > runtime->rate * 2)
-               snd_printk(KERN_DEBUG "delay: estimated %d, actual %d\n",
+               dev_dbg(&subs->dev->dev,
+                       "delay: estimated %d, actual %d\n",
                        est_delay, subs->last_delay);
 
        if (!subs->running) {
index 89730707614c3686be440a7d763700e375cd1f81..7c57f2268dd70a67c04c6addc2cf80c281121cda 100644 (file)
@@ -110,7 +110,7 @@ static int create_standard_audio_quirk(struct snd_usb_audio *chip,
        altsd = get_iface_desc(alts);
        err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber);
        if (err < 0) {
-               snd_printk(KERN_ERR "cannot setup if %d: error %d\n",
+               usb_audio_err(chip, "cannot setup if %d: error %d\n",
                           altsd->bInterfaceNumber, err);
                return err;
        }
@@ -135,7 +135,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
 
        fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL);
        if (!fp) {
-               snd_printk(KERN_ERR "cannot memdup\n");
+               usb_audio_err(chip, "cannot memdup\n");
                return -ENOMEM;
        }
        if (fp->nr_rates > MAX_NR_RATES) {
@@ -464,7 +464,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
                fp->rate_max = fp->rate_min = 96000;
                break;
        default:
-               snd_printk(KERN_ERR "unknown sample rate\n");
+               usb_audio_err(chip, "unknown sample rate\n");
                kfree(fp);
                return -ENXIO;
        }
@@ -536,7 +536,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
        if (quirk->type < QUIRK_TYPE_COUNT) {
                return quirk_funcs[quirk->type](chip, iface, driver, quirk);
        } else {
-               snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
+               usb_audio_err(chip, "invalid quirk type %d\n", quirk->type);
                return -ENXIO;
        }
 }
@@ -555,18 +555,21 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac
 
        if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
            le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) {
-               snd_printdd("sending Extigy boot sequence...\n");
+               dev_dbg(&dev->dev, "sending Extigy boot sequence...\n");
                /* Send message to force it to reconnect with full interface. */
                err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0),
                                      0x10, 0x43, 0x0001, 0x000a, NULL, 0);
-               if (err < 0) snd_printdd("error sending boot message: %d\n", err);
+               if (err < 0)
+                       dev_dbg(&dev->dev, "error sending boot message: %d\n", err);
                err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
                                &dev->descriptor, sizeof(dev->descriptor));
                config = dev->actconfig;
-               if (err < 0) snd_printdd("error usb_get_descriptor: %d\n", err);
+               if (err < 0)
+                       dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
                err = usb_reset_configuration(dev);
-               if (err < 0) snd_printdd("error usb_reset_configuration: %d\n", err);
-               snd_printdd("extigy_boot: new boot length = %d\n",
+               if (err < 0)
+                       dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
+               dev_dbg(&dev->dev, "extigy_boot: new boot length = %d\n",
                            le16_to_cpu(get_cfg_desc(config)->wTotalLength));
                return -ENODEV; /* quit this anyway */
        }
@@ -594,7 +597,7 @@ static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
        int err;
 
        if (dev->actconfig->desc.bConfigurationValue == 1) {
-               snd_printk(KERN_INFO "usb-audio: "
+               dev_info(&dev->dev,
                           "Fast Track Pro switching to config #2\n");
                /* This function has to be available by the usb core module.
                 * if it is not avialable the boot quirk has to be left out
@@ -603,14 +606,15 @@ static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
                 */
                err = usb_driver_set_configuration(dev, 2);
                if (err < 0)
-                       snd_printdd("error usb_driver_set_configuration: %d\n",
-                                   err);
+                       dev_dbg(&dev->dev,
+                               "error usb_driver_set_configuration: %d\n",
+                               err);
                /* Always return an error, so that we stop creating a device
                   that will just be destroyed and recreated with a new
                   configuration */
                return -ENODEV;
        } else
-               snd_printk(KERN_INFO "usb-audio: Fast Track Pro config OK\n");
+               dev_info(&dev->dev, "Fast Track Pro config OK\n");
 
        return 0;
 }
@@ -779,11 +783,11 @@ static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
        fwsize = le16_to_cpu(get_cfg_desc(config)->wTotalLength);
 
        if (fwsize != MBOX2_FIRMWARE_SIZE) {
-               snd_printk(KERN_ERR "usb-audio: Invalid firmware size=%d.\n", fwsize);
+               dev_err(&dev->dev, "Invalid firmware size=%d.\n", fwsize);
                return -ENODEV;
        }
 
-       snd_printd("usb-audio: Sending Digidesign Mbox 2 boot sequence...\n");
+       dev_dbg(&dev->dev, "Sending Digidesign Mbox 2 boot sequence...\n");
 
        count = 0;
        bootresponse[0] = MBOX2_BOOT_LOADING;
@@ -794,32 +798,32 @@ static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
                        0x85, 0xc0, 0x0001, 0x0000, &bootresponse, 0x0012);
                if (bootresponse[0] == MBOX2_BOOT_READY)
                        break;
-               snd_printd("usb-audio: device not ready, resending boot sequence...\n");
+               dev_dbg(&dev->dev, "device not ready, resending boot sequence...\n");
                count++;
        }
 
        if (bootresponse[0] != MBOX2_BOOT_READY) {
-               snd_printk(KERN_ERR "usb-audio: Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]);
+               dev_err(&dev->dev, "Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]);
                return -ENODEV;
        }
 
-       snd_printdd("usb-audio: device initialised!\n");
+       dev_dbg(&dev->dev, "device initialised!\n");
 
        err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
                &dev->descriptor, sizeof(dev->descriptor));
        config = dev->actconfig;
        if (err < 0)
-               snd_printd("error usb_get_descriptor: %d\n", err);
+               dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
 
        err = usb_reset_configuration(dev);
        if (err < 0)
-               snd_printd("error usb_reset_configuration: %d\n", err);
-       snd_printdd("mbox2_boot: new boot length = %d\n",
+               dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
+       dev_dbg(&dev->dev, "mbox2_boot: new boot length = %d\n",
                le16_to_cpu(get_cfg_desc(config)->wTotalLength));
 
        mbox2_setup_48_24_magic(dev);
 
-       snd_printk(KERN_INFO "usb-audio: Digidesign Mbox 2: 24bit 48kHz");
+       dev_info(&dev->dev, "Digidesign Mbox 2: 24bit 48kHz");
 
        return 0; /* Successful boot */
 }
@@ -865,7 +869,7 @@ static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
                                return 1; /* skip this altsetting */
                }
        }
-       snd_printdd(KERN_INFO
+       usb_audio_dbg(chip,
                    "using altsetting %d for interface %d config %d\n",
                    altno, iface, chip->setup);
        return 0; /* keep this altsetting */
@@ -932,7 +936,7 @@ static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
                        return 1;
        }
 
-       snd_printdd(KERN_INFO
+       usb_audio_dbg(chip,
                    "using altsetting %d for interface %d config %d\n",
                    altno, iface, chip->setup);
        return 0; /* keep this altsetting */
index 2fb71be5e100b0973c0993dbb8ed4da3f35c5cf2..310a3822d2b72b51586a9ee06954ef08667bbeb8 100644 (file)
@@ -411,10 +411,9 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
 
        if (!csep || csep->bLength < 7 ||
            csep->bDescriptorSubtype != UAC_EP_GENERAL) {
-               snd_printk(KERN_WARNING "%d:%u:%d : no or invalid"
-                          " class specific endpoint descriptor\n",
-                          chip->dev->devnum, iface_no,
-                          altsd->bAlternateSetting);
+               usb_audio_warn(chip,
+                              "%u:%d : no or invalid class specific endpoint descriptor\n",
+                              iface_no, altsd->bAlternateSetting);
                return 0;
        }
 
@@ -533,8 +532,8 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
                /* get audio formats */
                switch (protocol) {
                default:
-                       snd_printdd(KERN_WARNING "%d:%u:%d: unknown interface protocol %#02x, assuming v1\n",
-                                   dev->devnum, iface_no, altno, protocol);
+                       dev_dbg(&dev->dev, "%u:%d: unknown interface protocol %#02x, assuming v1\n",
+                               iface_no, altno, protocol);
                        protocol = UAC_VERSION_1;
                        /* fall through */
 
@@ -544,14 +543,16 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
                        struct uac_input_terminal_descriptor *iterm;
 
                        if (!as) {
-                               snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n",
-                                          dev->devnum, iface_no, altno);
+                               dev_err(&dev->dev,
+                                       "%u:%d : UAC_AS_GENERAL descriptor not found\n",
+                                       iface_no, altno);
                                continue;
                        }
 
                        if (as->bLength < sizeof(*as)) {
-                               snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n",
-                                          dev->devnum, iface_no, altno);
+                               dev_err(&dev->dev,
+                                       "%u:%d : invalid UAC_AS_GENERAL desc\n",
+                                       iface_no, altno);
                                continue;
                        }
 
@@ -574,14 +575,16 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
                                snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
 
                        if (!as) {
-                               snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n",
-                                          dev->devnum, iface_no, altno);
+                               dev_err(&dev->dev,
+                                       "%u:%d : UAC_AS_GENERAL descriptor not found\n",
+                                       iface_no, altno);
                                continue;
                        }
 
                        if (as->bLength < sizeof(*as)) {
-                               snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n",
-                                          dev->devnum, iface_no, altno);
+                               dev_err(&dev->dev,
+                                       "%u:%d : invalid UAC_AS_GENERAL desc\n",
+                                       iface_no, altno);
                                continue;
                        }
 
@@ -607,8 +610,9 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
                                break;
                        }
 
-                       snd_printk(KERN_ERR "%d:%u:%d : bogus bTerminalLink %d\n",
-                                  dev->devnum, iface_no, altno, as->bTerminalLink);
+                       dev_err(&dev->dev,
+                               "%u:%d : bogus bTerminalLink %d\n",
+                               iface_no, altno, as->bTerminalLink);
                        continue;
                }
                }
@@ -616,14 +620,16 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
                /* get format type */
                fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_FORMAT_TYPE);
                if (!fmt) {
-                       snd_printk(KERN_ERR "%d:%u:%d : no UAC_FORMAT_TYPE desc\n",
-                                  dev->devnum, iface_no, altno);
+                       dev_err(&dev->dev,
+                               "%u:%d : no UAC_FORMAT_TYPE desc\n",
+                               iface_no, altno);
                        continue;
                }
                if (((protocol == UAC_VERSION_1) && (fmt->bLength < 8)) ||
                    ((protocol == UAC_VERSION_2) && (fmt->bLength < 6))) {
-                       snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n",
-                                  dev->devnum, iface_no, altno);
+                       dev_err(&dev->dev,
+                               "%u:%d : invalid UAC_FORMAT_TYPE desc\n",
+                               iface_no, altno);
                        continue;
                }
 
@@ -644,7 +650,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
 
                fp = kzalloc(sizeof(*fp), GFP_KERNEL);
                if (! fp) {
-                       snd_printk(KERN_ERR "cannot malloc\n");
+                       dev_err(&dev->dev, "cannot malloc\n");
                        return -ENOMEM;
                }
 
@@ -707,7 +713,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
                        chconfig = 0;
                fp->chmap = convert_chmap(fp->channels, chconfig, protocol);
 
-               snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint);
+               dev_dbg(&dev->dev, "%u:%d: add audio endpoint %#x\n", iface_no, altno, fp->endpoint);
                err = snd_usb_add_audio_stream(chip, stream, fp);
                if (err < 0) {
                        kfree(fp->rate_table);
index 5d2fe0530745a175c24a9034416a29477be96062..25c4c7e217de603c1f02c5c714833e6f29d92c3b 100644 (file)
@@ -60,6 +60,15 @@ struct snd_usb_audio {
        struct usb_host_interface *ctrl_intf;   /* the audio control interface */
 };
 
+#define usb_audio_err(chip, fmt, args...) \
+       dev_err(&(chip)->dev->dev, fmt, ##args)
+#define usb_audio_warn(chip, fmt, args...) \
+       dev_warn(&(chip)->dev->dev, fmt, ##args)
+#define usb_audio_info(chip, fmt, args...) \
+       dev_info(&(chip)->dev->dev, fmt, ##args)
+#define usb_audio_dbg(chip, fmt, args...) \
+       dev_dbg(&(chip)->dev->dev, fmt, ##args)
+
 /*
  * Information about devices with broken descriptors
  */
index 999550bbad40e66f259d9ed2b044ed478e377d72..cf5dc33f4a6d6d582bea62d239f23b4e08bf750a 100644 (file)
@@ -535,7 +535,9 @@ static void snd_us122l_free(struct snd_card *card)
                snd_us122l_card_used[index] = 0;
 }
 
-static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
+static int usx2y_create_card(struct usb_device *device,
+                            struct usb_interface *intf,
+                            struct snd_card **cardp)
 {
        int             dev;
        struct snd_card *card;
@@ -546,8 +548,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
                        break;
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct us122l), &card);
+       err = snd_card_new(&intf->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct us122l), &card);
        if (err < 0)
                return err;
        snd_us122l_card_used[US122L(card)->card_index = dev] = 1;
@@ -578,11 +580,10 @@ static int us122l_usb_probe(struct usb_interface *intf,
        struct snd_card *card;
        int err;
 
-       err = usx2y_create_card(device, &card);
+       err = usx2y_create_card(device, intf, &card);
        if (err < 0)
                return err;
 
-       snd_card_set_dev(card, &intf->dev);
        if (!us122l_create_card(card)) {
                snd_card_free(card);
                return -EINVAL;
index 5a51b18c50fe9230faabb923219c281b45a47970..91e0e2a4808c99f8d9193342908343875f745fdd 100644 (file)
@@ -332,7 +332,9 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = {
        { /* terminator */ }
 };
 
-static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
+static int usX2Y_create_card(struct usb_device *device,
+                            struct usb_interface *intf,
+                            struct snd_card **cardp)
 {
        int             dev;
        struct snd_card *       card;
@@ -343,15 +345,15 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
                        break;
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
-       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
-                             sizeof(struct usX2Ydev), &card);
+       err = snd_card_new(&intf->dev, index[dev], id[dev], THIS_MODULE,
+                          sizeof(struct usX2Ydev), &card);
        if (err < 0)
                return err;
        snd_usX2Y_card_used[usX2Y(card)->card_index = dev] = 1;
        card->private_free = snd_usX2Y_card_private_free;
        usX2Y(card)->dev = device;
        init_waitqueue_head(&usX2Y(card)->prepare_wait_queue);
-       mutex_init(&usX2Y(card)->prepare_mutex);
+       mutex_init(&usX2Y(card)->pcm_mutex);
        INIT_LIST_HEAD(&usX2Y(card)->midi_list);
        strcpy(card->driver, "USB "NAME_ALLCAPS"");
        sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
@@ -382,10 +384,9 @@ static int usX2Y_usb_probe(struct usb_device *device,
             le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428))
                return -EINVAL;
 
-       err = usX2Y_create_card(device, &card);
+       err = usX2Y_create_card(device, intf, &card);
        if (err < 0)
                return err;
-       snd_card_set_dev(card, &intf->dev);
        if ((err = usX2Y_hwdep_new(card, device)) < 0  ||
            (err = snd_card_register(card)) < 0) {
                snd_card_free(card);
index e43c0a86441ae600c2725356e1cbf3c27ecb81a3..6ae6b08069389a77b1a68e01b6d78a9b48998e75 100644 (file)
@@ -36,7 +36,7 @@ struct usX2Ydev {
        unsigned int            rate,
                                format;
        int                     chip_status;
-       struct mutex            prepare_mutex;
+       struct mutex            pcm_mutex;
        struct us428ctls_sharedmem      *us428ctls_sharedmem;
        int                     wait_iso_frame;
        wait_queue_head_t       us428ctls_wait_queue_head;
index 6234a51625b1b6a556f252c2fea3a150db1bdbc1..a63330dd1407e721285285a559c8b90adddd74c5 100644 (file)
@@ -752,36 +752,44 @@ static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream,
        unsigned int            rate = params_rate(hw_params);
        snd_pcm_format_t        format = params_format(hw_params);
        struct snd_card *card = substream->pstr->pcm->card;
-       struct list_head *list;
+       struct usX2Ydev *dev = usX2Y(card);
+       int i;
 
+       mutex_lock(&usX2Y(card)->pcm_mutex);
        snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params);
-       // all pcm substreams off one usX2Y have to operate at the same rate & format
-       list_for_each(list, &card->devices) {
-               struct snd_device *dev;
-               struct snd_pcm *pcm;
-               int s;
-               dev = snd_device(list);
-               if (dev->type != SNDRV_DEV_PCM)
+       /* all pcm substreams off one usX2Y have to operate at the same
+        * rate & format
+        */
+       for (i = 0; i < dev->pcm_devs * 2; i++) {
+               struct snd_usX2Y_substream *subs = dev->subs[i];
+               struct snd_pcm_substream *test_substream;
+
+               if (!subs)
+                       continue;
+               test_substream = subs->pcm_substream;
+               if (!test_substream || test_substream == substream ||
+                   !test_substream->runtime)
                        continue;
-               pcm = dev->device_data;
-               for (s = 0; s < 2; ++s) {
-                       struct snd_pcm_substream *test_substream;
-                       test_substream = pcm->streams[s].substream;
-                       if (test_substream && test_substream != substream  &&
-                           test_substream->runtime &&
-                           ((test_substream->runtime->format &&
-                             test_substream->runtime->format != format) ||
-                            (test_substream->runtime->rate &&
-                             test_substream->runtime->rate != rate)))
-                               return -EINVAL;
+               if ((test_substream->runtime->format &&
+                    test_substream->runtime->format != format) ||
+                   (test_substream->runtime->rate &&
+                    test_substream->runtime->rate != rate)) {
+                       err = -EINVAL;
+                       goto error;
                }
        }
-       if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) {
+
+       err = snd_pcm_lib_malloc_pages(substream,
+                                      params_buffer_bytes(hw_params));
+       if (err < 0) {
                snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n",
                           substream, params_buffer_bytes(hw_params), err);
-               return err;
+               goto error;
        }
-       return 0;
+
+ error:
+       mutex_unlock(&usX2Y(card)->pcm_mutex);
+       return err;
 }
 
 /*
@@ -791,7 +799,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_usX2Y_substream *subs = runtime->private_data;
-       mutex_lock(&subs->usX2Y->prepare_mutex);
+       mutex_lock(&subs->usX2Y->pcm_mutex);
        snd_printdd("snd_usX2Y_hw_free(%p)\n", substream);
 
        if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
@@ -812,7 +820,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
                        usX2Y_urbs_release(subs);
                }
        }
-       mutex_unlock(&subs->usX2Y->prepare_mutex);
+       mutex_unlock(&subs->usX2Y->pcm_mutex);
        return snd_pcm_lib_free_pages(substream);
 }
 /*
@@ -829,7 +837,7 @@ static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream)
        int err = 0;
        snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream);
 
-       mutex_lock(&usX2Y->prepare_mutex);
+       mutex_lock(&usX2Y->pcm_mutex);
        usX2Y_subs_prepare(subs);
 // Start hardware streams
 // SyncStream first....
@@ -849,7 +857,7 @@ static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream)
                err = usX2Y_urbs_start(subs);
 
  up_prepare_mutex:
-       mutex_unlock(&usX2Y->prepare_mutex);
+       mutex_unlock(&usX2Y->pcm_mutex);
        return err;
 }
 
index 814d0e887c62e5c451c3ff7cc4b8f448c3a45007..90766a92e7fdf471e7f109def88bd21ebb50048f 100644 (file)
@@ -358,7 +358,7 @@ static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_usX2Y_substream *subs = runtime->private_data,
                *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2];
-       mutex_lock(&subs->usX2Y->prepare_mutex);
+       mutex_lock(&subs->usX2Y->pcm_mutex);
        snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream);
 
        if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
@@ -387,7 +387,7 @@ static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream)
                                usX2Y_usbpcm_urbs_release(cap_subs2);
                }
        }
-       mutex_unlock(&subs->usX2Y->prepare_mutex);
+       mutex_unlock(&subs->usX2Y->pcm_mutex);
        return snd_pcm_lib_free_pages(substream);
 }
 
@@ -493,7 +493,7 @@ static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream)
                memset(usX2Y->hwdep_pcm_shm, 0, sizeof(struct snd_usX2Y_hwdep_pcm_shm));
        }
 
-       mutex_lock(&usX2Y->prepare_mutex);
+       mutex_lock(&usX2Y->pcm_mutex);
        usX2Y_subs_prepare(subs);
 // Start hardware streams
 // SyncStream first....
@@ -534,7 +534,7 @@ static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream)
                usX2Y->hwdep_pcm_shm->capture_iso_start = -1;
 
  up_prepare_mutex:
-       mutex_unlock(&usX2Y->prepare_mutex);
+       mutex_unlock(&usX2Y->pcm_mutex);
        return err;
 }
 
@@ -600,59 +600,30 @@ static struct snd_pcm_ops snd_usX2Y_usbpcm_ops =
 };
 
 
-static int usX2Y_pcms_lock_check(struct snd_card *card)
+static int usX2Y_pcms_busy_check(struct snd_card *card)
 {
-       struct list_head *list;
-       struct snd_device *dev;
-       struct snd_pcm *pcm;
-       int err = 0;
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
-               if (dev->type != SNDRV_DEV_PCM)
-                       continue;
-               pcm = dev->device_data;
-               mutex_lock(&pcm->open_mutex);
-       }
-       list_for_each(list, &card->devices) {
-               int s;
-               dev = snd_device(list);
-               if (dev->type != SNDRV_DEV_PCM)
-                       continue;
-               pcm = dev->device_data;
-               for (s = 0; s < 2; ++s) {
-                       struct snd_pcm_substream *substream;
-                       substream = pcm->streams[s].substream;
-                       if (substream && SUBSTREAM_BUSY(substream))
-                               err = -EBUSY;
-               }
-       }
-       return err;
-}
-
+       struct usX2Ydev *dev = usX2Y(card);
+       int i;
 
-static void usX2Y_pcms_unlock(struct snd_card *card)
-{
-       struct list_head *list;
-       struct snd_device *dev;
-       struct snd_pcm *pcm;
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
-               if (dev->type != SNDRV_DEV_PCM)
-                       continue;
-               pcm = dev->device_data;
-               mutex_unlock(&pcm->open_mutex);
+       for (i = 0; i < dev->pcm_devs * 2; i++) {
+               struct snd_usX2Y_substream *subs = dev->subs[i];
+               if (subs && subs->pcm_substream &&
+                   SUBSTREAM_BUSY(subs->pcm_substream))
+                       return -EBUSY;
        }
+       return 0;
 }
 
-
 static int snd_usX2Y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file)
 {
-       // we need to be the first 
        struct snd_card *card = hw->card;
-       int err = usX2Y_pcms_lock_check(card);
-       if (0 == err)
+       int err;
+
+       mutex_lock(&usX2Y(card)->pcm_mutex);
+       err = usX2Y_pcms_busy_check(card);
+       if (!err)
                usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS;
-       usX2Y_pcms_unlock(card);
+       mutex_unlock(&usX2Y(card)->pcm_mutex);
        return err;
 }
 
@@ -660,10 +631,13 @@ static int snd_usX2Y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file)
 static int snd_usX2Y_hwdep_pcm_release(struct snd_hwdep *hw, struct file *file)
 {
        struct snd_card *card = hw->card;
-       int err = usX2Y_pcms_lock_check(card);
-       if (0 == err)
+       int err;
+
+       mutex_lock(&usX2Y(card)->pcm_mutex);
+       err = usX2Y_pcms_busy_check(card);
+       if (!err)
                usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS;
-       usX2Y_pcms_unlock(card);
+       mutex_unlock(&usX2Y(card)->pcm_mutex);
        return err;
 }