summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/sound/kernel-api/writing-an-alsa-driver.rst35
-rw-r--r--drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c1
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-g723.c4
-rw-r--r--drivers/media/pci/tw686x/tw686x-audio.c3
-rw-r--r--include/sound/core.h1
-rw-r--r--include/sound/hda_register.h2
-rw-r--r--include/sound/hda_verbs.h2
-rw-r--r--include/sound/hdaudio.h3
-rw-r--r--include/sound/info.h36
-rw-r--r--include/sound/memalloc.h1
-rw-r--r--include/sound/pcm.h21
-rw-r--r--sound/aoa/soundbus/i2sbus/core.c4
-rw-r--r--sound/arm/aaci.c4
-rw-r--r--sound/arm/pxa2xx-ac97.c1
-rw-r--r--sound/atmel/ac97c.c4
-rw-r--r--sound/core/compress_offload.c11
-rw-r--r--sound/core/info.c131
-rw-r--r--sound/core/init.c31
-rw-r--r--sound/core/memalloc.c2
-rw-r--r--sound/core/oss/pcm_oss.c1
-rw-r--r--sound/core/pcm.c163
-rw-r--r--sound/core/pcm_lib.c14
-rw-r--r--sound/core/pcm_local.h1
-rw-r--r--sound/core/pcm_memory.c33
-rw-r--r--sound/core/pcm_native.c307
-rw-r--r--sound/drivers/aloop.c14
-rw-r--r--sound/drivers/dummy.c12
-rw-r--r--sound/drivers/opl4/opl4_proc.c4
-rw-r--r--sound/drivers/pcsp/pcsp.c1
-rw-r--r--sound/drivers/vx/vx_core.c9
-rw-r--r--sound/firewire/Kconfig1
-rw-r--r--sound/firewire/bebob/bebob_proc.c12
-rw-r--r--sound/firewire/dice/dice-proc.c12
-rw-r--r--sound/firewire/dice/dice.c12
-rw-r--r--sound/firewire/digi00x/digi00x-proc.c16
-rw-r--r--sound/firewire/fireface/Makefile4
-rw-r--r--sound/firewire/fireface/ff-midi.c2
-rw-r--r--sound/firewire/fireface/ff-pcm.c2
-rw-r--r--sound/firewire/fireface/ff-proc.c229
-rw-r--r--sound/firewire/fireface/ff-protocol-ff400.c161
-rw-r--r--sound/firewire/fireface/ff-protocol-ff800.c143
-rw-r--r--sound/firewire/fireface/ff-protocol-former.c597
-rw-r--r--sound/firewire/fireface/ff-protocol-latter.c430
-rw-r--r--sound/firewire/fireface/ff-stream.c40
-rw-r--r--sound/firewire/fireface/ff-transaction.c143
-rw-r--r--sound/firewire/fireface/ff.c28
-rw-r--r--sound/firewire/fireface/ff.h23
-rw-r--r--sound/firewire/fireworks/fireworks_proc.c12
-rw-r--r--sound/firewire/motu/motu-proc.c12
-rw-r--r--sound/firewire/oxfw/oxfw-proc.c12
-rw-r--r--sound/firewire/tascam/tascam-proc.c12
-rw-r--r--sound/hda/hdac_controller.c8
-rw-r--r--sound/hda/hdac_stream.c44
-rw-r--r--sound/i2c/other/ak4113.c5
-rw-r--r--sound/i2c/other/ak4114.c5
-rw-r--r--sound/i2c/other/ak4xxx-adda.c8
-rw-r--r--sound/isa/ad1816a/ad1816a_lib.c3
-rw-r--r--sound/isa/als100.c1
-rw-r--r--sound/isa/cmi8328.c1
-rw-r--r--sound/isa/cmi8330.c3
-rw-r--r--sound/isa/es1688/es1688.c2
-rw-r--r--sound/isa/es1688/es1688_lib.c2
-rw-r--r--sound/isa/es18xx.c4
-rw-r--r--sound/isa/gus/gus_irq.c5
-rw-r--r--sound/isa/gus/gus_main.c13
-rw-r--r--sound/isa/gus/gus_mem.c6
-rw-r--r--sound/isa/gus/gus_pcm.c4
-rw-r--r--sound/isa/opti9xx/miro.c5
-rw-r--r--sound/isa/sb/jazz16.c1
-rw-r--r--sound/isa/sb/sb16.c1
-rw-r--r--sound/isa/sb/sb16_csp.c5
-rw-r--r--sound/isa/sb/sb16_main.c12
-rw-r--r--sound/isa/sb/sb8.c1
-rw-r--r--sound/isa/sb/sb8_main.c2
-rw-r--r--sound/isa/sscape.c7
-rw-r--r--sound/isa/wss/wss_lib.c3
-rw-r--r--sound/mips/hal2.c31
-rw-r--r--sound/mips/sgio2audio.c7
-rw-r--r--sound/parisc/harmony.c10
-rw-r--r--sound/pci/ac97/ac97_proc.c26
-rw-r--r--sound/pci/ad1889.c13
-rw-r--r--sound/pci/ak4531_codec.c5
-rw-r--r--sound/pci/ali5451/ali5451.c8
-rw-r--r--sound/pci/als300.c1
-rw-r--r--sound/pci/als4000.c1
-rw-r--r--sound/pci/asihpi/asihpi.c6
-rw-r--r--sound/pci/atiixp.c24
-rw-r--r--sound/pci/atiixp_modem.c8
-rw-r--r--sound/pci/aw2/aw2-alsa.c40
-rw-r--r--sound/pci/azt3328.c4
-rw-r--r--sound/pci/bt87x.c10
-rw-r--r--sound/pci/ca0106/ca0106_main.c19
-rw-r--r--sound/pci/ca0106/ca0106_proc.c40
-rw-r--r--sound/pci/cmipci.c9
-rw-r--r--sound/pci/cs4281.c5
-rw-r--r--sound/pci/cs46xx/cs46xx_dsp_spos.h6
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c6
-rw-r--r--sound/pci/cs46xx/dsp_spos.c133
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c19
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pm.c1
-rw-r--r--sound/pci/ctxfi/ctatc.c8
-rw-r--r--sound/pci/echoaudio/echoaudio.c19
-rw-r--r--sound/pci/emu10k1/emu10k1.c6
-rw-r--r--sound/pci/emu10k1/emu10k1x.c12
-rw-r--r--sound/pci/emu10k1/emupcm.c22
-rw-r--r--sound/pci/emu10k1/emuproc.c81
-rw-r--r--sound/pci/emu10k1/p16v.c17
-rw-r--r--sound/pci/ens1370.c9
-rw-r--r--sound/pci/es1938.c1
-rw-r--r--sound/pci/es1968.c1
-rw-r--r--sound/pci/fm801.c1
-rw-r--r--sound/pci/hda/hda_beep.c151
-rw-r--r--sound/pci/hda/hda_beep.h5
-rw-r--r--sound/pci/hda/hda_codec.c56
-rw-r--r--sound/pci/hda/hda_proc.c9
-rw-r--r--sound/pci/hda/hda_tegra.c114
-rw-r--r--sound/pci/hda/patch_hdmi.c10
-rw-r--r--sound/pci/hda/patch_realtek.c80
-rw-r--r--sound/pci/ice1712/ews.c7
-rw-r--r--sound/pci/ice1712/ice1712.c8
-rw-r--r--sound/pci/ice1712/ice1724.c8
-rw-r--r--sound/pci/ice1712/pontis.c12
-rw-r--r--sound/pci/ice1712/prodigy192.c5
-rw-r--r--sound/pci/ice1712/prodigy_hifi.c8
-rw-r--r--sound/pci/ice1712/quartet.c4
-rw-r--r--sound/pci/intel8x0.c8
-rw-r--r--sound/pci/intel8x0m.c9
-rw-r--r--sound/pci/korg1212/korg1212.c6
-rw-r--r--sound/pci/lola/lola_proc.c16
-rw-r--r--sound/pci/lx6464es/lx6464es.c16
-rw-r--r--sound/pci/maestro3.c1
-rw-r--r--sound/pci/mixart/mixart.c6
-rw-r--r--sound/pci/nm256/nm256.c1
-rw-r--r--sound/pci/oxygen/oxygen_lib.c12
-rw-r--r--sound/pci/oxygen/pcm1796.h1
-rw-r--r--sound/pci/oxygen/xonar_pcm179x.c71
-rw-r--r--sound/pci/pcxhr/pcxhr.c21
-rw-r--r--sound/pci/riptide/riptide.c7
-rw-r--r--sound/pci/rme32.c5
-rw-r--r--sound/pci/rme96.c7
-rw-r--r--sound/pci/rme9652/hdsp.c5
-rw-r--r--sound/pci/rme9652/hdspm.c75
-rw-r--r--sound/pci/rme9652/rme9652.c6
-rw-r--r--sound/pci/sis7019.c1
-rw-r--r--sound/pci/sonicvibes.c6
-rw-r--r--sound/pci/trident/trident_main.c8
-rw-r--r--sound/pci/via82xx.c8
-rw-r--r--sound/pci/via82xx_modem.c16
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c10
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_core.c6
-rw-r--r--sound/ppc/pmac.c1
-rw-r--r--sound/ppc/snd_ps3.c6
-rw-r--r--sound/sh/aica.c14
-rw-r--r--sound/soc/amd/acp-pcm-dma.c26
-rw-r--r--sound/soc/amd/raven/acp3x-pcm-dma.c8
-rw-r--r--sound/soc/dwc/dwc-pcm.c3
-rw-r--r--sound/soc/intel/atom/sst-mfld-platform-pcm.c9
-rw-r--r--sound/soc/intel/baytrail/sst-baytrail-pcm.c15
-rw-r--r--sound/soc/intel/haswell/sst-haswell-pcm.c10
-rw-r--r--sound/soc/intel/skylake/skl-pcm.c9
-rw-r--r--sound/soc/mediatek/common/mtk-afe-platform-driver.c6
-rw-r--r--sound/soc/meson/axg-fifo.c7
-rw-r--r--sound/soc/sh/fsi.c3
-rw-r--r--sound/soc/sh/rcar/core.c5
-rw-r--r--sound/soc/sh/siu_pcm.c15
-rw-r--r--sound/soc/soc-generic-dmaengine-pcm.c5
-rw-r--r--sound/soc/soc-pcm.c1
-rw-r--r--sound/soc/stm/stm32_adfsdm.c5
-rw-r--r--sound/soc/txx9/txx9aclc.c4
-rw-r--r--sound/soc/uniphier/aio-dma.c3
-rw-r--r--sound/soc/xtensa/xtfpga-i2s.c6
-rw-r--r--sound/sparc/dbri.c19
-rw-r--r--sound/spi/at73c213.c2
-rw-r--r--sound/synth/emux/emux_proc.c4
-rw-r--r--sound/usb/card.c1
-rw-r--r--sound/usb/line6/driver.c4
-rw-r--r--sound/usb/line6/pod.c3
-rw-r--r--sound/usb/mixer.c13
-rw-r--r--sound/usb/mixer_quirks.c6
-rw-r--r--sound/usb/proc.c13
-rw-r--r--sound/usb/quirks.c17
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c21
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.c19
-rw-r--r--sound/x86/intel_hdmi_audio.c15
184 files changed, 2357 insertions, 2265 deletions
diff --git a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst
index b37234afdfa1..6b154dbb02cc 100644
--- a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst
+++ b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst
@@ -3520,14 +3520,14 @@ allocator will try to get an area as large as possible within the
3520given size. 3520given size.
3521 3521
3522The second argument (type) and the third argument (device pointer) are 3522The second argument (type) and the third argument (device pointer) are
3523dependent on the bus. In the case of the ISA bus, pass 3523dependent on the bus. For normal devices, pass the device pointer
3524:c:func:`snd_dma_isa_data()` as the third argument with 3524(typically identical as ``card->dev``) to the third argument with
3525``SNDRV_DMA_TYPE_DEV`` type. For the continuous buffer unrelated to the 3525``SNDRV_DMA_TYPE_DEV`` type. For the continuous buffer unrelated to the
3526bus can be pre-allocated with ``SNDRV_DMA_TYPE_CONTINUOUS`` type and the 3526bus can be pre-allocated with ``SNDRV_DMA_TYPE_CONTINUOUS`` type and the
3527``snd_dma_continuous_data(GFP_KERNEL)`` device pointer, where 3527``snd_dma_continuous_data(GFP_KERNEL)`` device pointer, where
3528``GFP_KERNEL`` is the kernel allocation flag to use. For the PCI 3528``GFP_KERNEL`` is the kernel allocation flag to use. For the
3529scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with 3529scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with the device
3530``snd_dma_pci_data(pci)`` (see the `Non-Contiguous Buffers`_ 3530pointer (see the `Non-Contiguous Buffers`_
3531section). 3531section).
3532 3532
3533Once the buffer is pre-allocated, you can use the allocator in the 3533Once the buffer is pre-allocated, you can use the allocator in the
@@ -3924,15 +3924,12 @@ The scheme of the real suspend job is as follows.
39242. Call :c:func:`snd_power_change_state()` with 39242. Call :c:func:`snd_power_change_state()` with
3925 ``SNDRV_CTL_POWER_D3hot`` to change the power status. 3925 ``SNDRV_CTL_POWER_D3hot`` to change the power status.
3926 3926
39273. Call :c:func:`snd_pcm_suspend_all()` to suspend the running 39273. If AC97 codecs are used, call :c:func:`snd_ac97_suspend()` for
3928 PCM streams.
3929
39304. If AC97 codecs are used, call :c:func:`snd_ac97_suspend()` for
3931 each codec. 3928 each codec.
3932 3929
39335. Save the register values if necessary. 39304. Save the register values if necessary.
3934 3931
39356. Stop the hardware if necessary. 39325. Stop the hardware if necessary.
3936 3933
3937A typical code would be like: 3934A typical code would be like:
3938 3935
@@ -3946,12 +3943,10 @@ A typical code would be like:
3946 /* (2) */ 3943 /* (2) */
3947 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3944 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3948 /* (3) */ 3945 /* (3) */
3949 snd_pcm_suspend_all(chip->pcm);
3950 /* (4) */
3951 snd_ac97_suspend(chip->ac97); 3946 snd_ac97_suspend(chip->ac97);
3952 /* (5) */ 3947 /* (4) */
3953 snd_mychip_save_registers(chip); 3948 snd_mychip_save_registers(chip);
3954 /* (6) */ 3949 /* (5) */
3955 snd_mychip_stop_hardware(chip); 3950 snd_mychip_stop_hardware(chip);
3956 return 0; 3951 return 0;
3957 } 3952 }
@@ -3994,13 +3989,9 @@ A typical code would be like:
3994 return 0; 3989 return 0;
3995 } 3990 }
3996 3991
3997As shown in the above, it's better to save registers after suspending 3992Note that, at the time this callback gets called, the PCM stream has
3998the PCM operations via :c:func:`snd_pcm_suspend_all()` or 3993been already suspended via its own PM ops calling
3999:c:func:`snd_pcm_suspend()`. It means that the PCM streams are 3994:c:func:`snd_pcm_suspend_all()` internally.
4000already stopped when the register snapshot is taken. But, remember that
4001you don't have to restart the PCM stream in the resume callback. It'll
4002be restarted via trigger call with ``SNDRV_PCM_TRIGGER_RESUME`` when
4003necessary.
4004 3995
4005OK, we have all callbacks now. Let's set them up. In the initialization 3996OK, we have all callbacks now. Let's set them up. In the initialization
4006of the card, make sure that you can get the chip data from the card 3997of the card, make sure that you can get the chip data from the card
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
index cf3f0caf9c63..ed7af7518b52 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
@@ -614,7 +614,6 @@ static int snd_dw_hdmi_suspend(struct device *dev)
614 struct snd_dw_hdmi *dw = dev_get_drvdata(dev); 614 struct snd_dw_hdmi *dw = dev_get_drvdata(dev);
615 615
616 snd_power_change_state(dw->card, SNDRV_CTL_POWER_D3cold); 616 snd_power_change_state(dw->card, SNDRV_CTL_POWER_D3cold);
617 snd_pcm_suspend_all(dw->pcm);
618 617
619 return 0; 618 return 0;
620} 619}
diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
index 2cc05a9d57ac..a16242a9206f 100644
--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
@@ -360,13 +360,11 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
360 ss; ss = ss->next, i++) 360 ss; ss = ss->next, i++)
361 sprintf(ss->name, "Camera #%d Audio", i); 361 sprintf(ss->name, "Camera #%d Audio", i);
362 362
363 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 363 snd_pcm_lib_preallocate_pages_for_all(pcm,
364 SNDRV_DMA_TYPE_CONTINUOUS, 364 SNDRV_DMA_TYPE_CONTINUOUS,
365 snd_dma_continuous_data(GFP_KERNEL), 365 snd_dma_continuous_data(GFP_KERNEL),
366 G723_PERIOD_BYTES * PERIODS, 366 G723_PERIOD_BYTES * PERIODS,
367 G723_PERIOD_BYTES * PERIODS); 367 G723_PERIOD_BYTES * PERIODS);
368 if (ret < 0)
369 return ret;
370 368
371 solo_dev->snd_pcm = pcm; 369 solo_dev->snd_pcm = pcm;
372 370
diff --git a/drivers/media/pci/tw686x/tw686x-audio.c b/drivers/media/pci/tw686x/tw686x-audio.c
index a28329698e20..fb0e7573b5ae 100644
--- a/drivers/media/pci/tw686x/tw686x-audio.c
+++ b/drivers/media/pci/tw686x/tw686x-audio.c
@@ -301,11 +301,12 @@ static int tw686x_snd_pcm_init(struct tw686x_dev *dev)
301 ss; ss = ss->next, i++) 301 ss; ss = ss->next, i++)
302 snprintf(ss->name, sizeof(ss->name), "vch%u audio", i); 302 snprintf(ss->name, sizeof(ss->name), "vch%u audio", i);
303 303
304 return snd_pcm_lib_preallocate_pages_for_all(pcm, 304 snd_pcm_lib_preallocate_pages_for_all(pcm,
305 SNDRV_DMA_TYPE_DEV, 305 SNDRV_DMA_TYPE_DEV,
306 snd_dma_pci_data(dev->pci_dev), 306 snd_dma_pci_data(dev->pci_dev),
307 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX, 307 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX,
308 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX); 308 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX);
309 return 0;
309} 310}
310 311
311static void tw686x_audio_dma_free(struct tw686x_dev *dev, 312static void tw686x_audio_dma_free(struct tw686x_dev *dev,
diff --git a/include/sound/core.h b/include/sound/core.h
index 36a5934cf4b1..e923c23e05dd 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -120,7 +120,6 @@ struct snd_card {
120 struct list_head ctl_files; /* active control files */ 120 struct list_head ctl_files; /* active control files */
121 121
122 struct snd_info_entry *proc_root; /* root for soundcard specific files */ 122 struct snd_info_entry *proc_root; /* root for soundcard specific files */
123 struct snd_info_entry *proc_id; /* the card id */
124 struct proc_dir_entry *proc_root_link; /* number link to real id */ 123 struct proc_dir_entry *proc_root_link; /* number link to real id */
125 124
126 struct list_head files_list; /* all files associated to this card */ 125 struct list_head files_list; /* all files associated to this card */
diff --git a/include/sound/hda_register.h b/include/sound/hda_register.h
index 2ab39fb52d7a..0fd39295b426 100644
--- a/include/sound/hda_register.h
+++ b/include/sound/hda_register.h
@@ -79,6 +79,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
79 79
80/* stream register offsets from stream base */ 80/* stream register offsets from stream base */
81#define AZX_REG_SD_CTL 0x00 81#define AZX_REG_SD_CTL 0x00
82#define AZX_REG_SD_CTL_3B 0x02 /* 3rd byte of SD_CTL register */
82#define AZX_REG_SD_STS 0x03 83#define AZX_REG_SD_STS 0x03
83#define AZX_REG_SD_LPIB 0x04 84#define AZX_REG_SD_LPIB 0x04
84#define AZX_REG_SD_CBL 0x08 85#define AZX_REG_SD_CBL 0x08
@@ -165,6 +166,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
165#define SD_INT_COMPLETE 0x04 /* completion interrupt */ 166#define SD_INT_COMPLETE 0x04 /* completion interrupt */
166#define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\ 167#define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
167 SD_INT_COMPLETE) 168 SD_INT_COMPLETE)
169#define SD_CTL_STRIPE_MASK 0x3 /* stripe control mask */
168 170
169/* SD_STS */ 171/* SD_STS */
170#define SD_STS_FIFO_READY 0x20 /* FIFO ready */ 172#define SD_STS_FIFO_READY 0x20 /* FIFO ready */
diff --git a/include/sound/hda_verbs.h b/include/sound/hda_verbs.h
index 2a8573a00ea6..e36b77531c5c 100644
--- a/include/sound/hda_verbs.h
+++ b/include/sound/hda_verbs.h
@@ -66,6 +66,7 @@ enum {
66#define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c 66#define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c
67/* f20: AFG/MFG */ 67/* f20: AFG/MFG */
68#define AC_VERB_GET_SUBSYSTEM_ID 0x0f20 68#define AC_VERB_GET_SUBSYSTEM_ID 0x0f20
69#define AC_VERB_GET_STRIPE_CONTROL 0x0f24
69#define AC_VERB_GET_CVT_CHAN_COUNT 0x0f2d 70#define AC_VERB_GET_CVT_CHAN_COUNT 0x0f2d
70#define AC_VERB_GET_HDMI_DIP_SIZE 0x0f2e 71#define AC_VERB_GET_HDMI_DIP_SIZE 0x0f2e
71#define AC_VERB_GET_HDMI_ELDD 0x0f2f 72#define AC_VERB_GET_HDMI_ELDD 0x0f2f
@@ -110,6 +111,7 @@ enum {
110#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 0x71f 111#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 0x71f
111#define AC_VERB_SET_EAPD 0x788 112#define AC_VERB_SET_EAPD 0x788
112#define AC_VERB_SET_CODEC_RESET 0x7ff 113#define AC_VERB_SET_CODEC_RESET 0x7ff
114#define AC_VERB_SET_STRIPE_CONTROL 0x724
113#define AC_VERB_SET_CVT_CHAN_COUNT 0x72d 115#define AC_VERB_SET_CVT_CHAN_COUNT 0x72d
114#define AC_VERB_SET_HDMI_DIP_INDEX 0x730 116#define AC_VERB_SET_HDMI_DIP_INDEX 0x730
115#define AC_VERB_SET_HDMI_DIP_DATA 0x731 117#define AC_VERB_SET_HDMI_DIP_DATA 0x731
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index b4fa1c775251..45f944d57982 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -539,6 +539,9 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
539 unsigned int streams); 539 unsigned int streams);
540void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev, 540void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
541 unsigned int streams); 541 unsigned int streams);
542int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus,
543 struct snd_pcm_substream *substream);
544
542/* 545/*
543 * macros for easy use 546 * macros for easy use
544 */ 547 */
diff --git a/include/sound/info.h b/include/sound/info.h
index becdf66d2825..97fdda41e076 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -82,7 +82,6 @@ struct snd_info_entry {
82 struct snd_info_entry_ops *ops; 82 struct snd_info_entry_ops *ops;
83 } c; 83 } c;
84 struct snd_info_entry *parent; 84 struct snd_info_entry *parent;
85 struct snd_card *card;
86 struct module *module; 85 struct module *module;
87 void *private_data; 86 void *private_data;
88 void (*private_free)(struct snd_info_entry *entry); 87 void (*private_free)(struct snd_info_entry *entry);
@@ -160,6 +159,13 @@ static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
160 entry->c.text.read = read; 159 entry->c.text.read = read;
161} 160}
162 161
162int snd_card_rw_proc_new(struct snd_card *card, const char *name,
163 void *private_data,
164 void (*read)(struct snd_info_entry *,
165 struct snd_info_buffer *),
166 void (*write)(struct snd_info_entry *entry,
167 struct snd_info_buffer *buffer));
168
163int snd_info_check_reserved_words(const char *str); 169int snd_info_check_reserved_words(const char *str);
164 170
165#else 171#else
@@ -189,10 +195,38 @@ static inline int snd_card_proc_new(struct snd_card *card, const char *name,
189static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)), 195static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
190 void *private_data, 196 void *private_data,
191 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {} 197 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
198static inline int snd_card_rw_proc_new(struct snd_card *card, const char *name,
199 void *private_data,
200 void (*read)(struct snd_info_entry *,
201 struct snd_info_buffer *),
202 void (*write)(struct snd_info_entry *entry,
203 struct snd_info_buffer *buffer))
204{
205 return 0;
206}
192static inline int snd_info_check_reserved_words(const char *str) { return 1; } 207static inline int snd_info_check_reserved_words(const char *str) { return 1; }
193 208
194#endif 209#endif
195 210
211/**
212 * snd_card_ro_proc_new - Create a read-only text proc file entry for the card
213 * @card: the card instance
214 * @name: the file name
215 * @private_data: the arbitrary private data
216 * @read: the read callback
217 *
218 * This proc file entry will be registered via snd_card_register() call, and
219 * it will be removed automatically at the card removal, too.
220 */
221static inline int
222snd_card_ro_proc_new(struct snd_card *card, const char *name,
223 void *private_data,
224 void (*read)(struct snd_info_entry *,
225 struct snd_info_buffer *))
226{
227 return snd_card_rw_proc_new(card, name, private_data, read, NULL);
228}
229
196/* 230/*
197 * OSS info part 231 * OSS info part
198 */ 232 */
diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h
index af3fa577fa06..1ac0dd82a916 100644
--- a/include/sound/memalloc.h
+++ b/include/sound/memalloc.h
@@ -37,7 +37,6 @@ struct snd_dma_device {
37}; 37};
38 38
39#define snd_dma_pci_data(pci) (&(pci)->dev) 39#define snd_dma_pci_data(pci) (&(pci)->dev)
40#define snd_dma_isa_data() NULL
41#define snd_dma_continuous_data(x) ((struct device *)(__force unsigned long)(x)) 40#define snd_dma_continuous_data(x) ((struct device *)(__force unsigned long)(x))
42 41
43 42
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index d6bd3caf6878..ca20f80f8976 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -30,6 +30,7 @@
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/bitops.h> 31#include <linux/bitops.h>
32#include <linux/pm_qos.h> 32#include <linux/pm_qos.h>
33#include <linux/refcount.h>
33 34
34#define snd_pcm_substream_chip(substream) ((substream)->private_data) 35#define snd_pcm_substream_chip(substream) ((substream)->private_data)
35#define snd_pcm_chip(pcm) ((pcm)->private_data) 36#define snd_pcm_chip(pcm) ((pcm)->private_data)
@@ -439,7 +440,7 @@ struct snd_pcm_group { /* keep linked substreams */
439 spinlock_t lock; 440 spinlock_t lock;
440 struct mutex mutex; 441 struct mutex mutex;
441 struct list_head substreams; 442 struct list_head substreams;
442 int count; 443 refcount_t refs;
443}; 444};
444 445
445struct pid; 446struct pid;
@@ -470,7 +471,6 @@ struct snd_pcm_substream {
470 struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */ 471 struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */
471 struct snd_pcm_group *group; /* pointer to current group */ 472 struct snd_pcm_group *group; /* pointer to current group */
472 /* -- assigned files -- */ 473 /* -- assigned files -- */
473 void *file;
474 int ref_count; 474 int ref_count;
475 atomic_t mmap_count; 475 atomic_t mmap_count;
476 unsigned int f_flags; 476 unsigned int f_flags;
@@ -482,15 +482,6 @@ struct snd_pcm_substream {
482#endif 482#endif
483#ifdef CONFIG_SND_VERBOSE_PROCFS 483#ifdef CONFIG_SND_VERBOSE_PROCFS
484 struct snd_info_entry *proc_root; 484 struct snd_info_entry *proc_root;
485 struct snd_info_entry *proc_info_entry;
486 struct snd_info_entry *proc_hw_params_entry;
487 struct snd_info_entry *proc_sw_params_entry;
488 struct snd_info_entry *proc_status_entry;
489 struct snd_info_entry *proc_prealloc_entry;
490 struct snd_info_entry *proc_prealloc_max_entry;
491#ifdef CONFIG_SND_PCM_XRUN_DEBUG
492 struct snd_info_entry *proc_xrun_injection_entry;
493#endif
494#endif /* CONFIG_SND_VERBOSE_PROCFS */ 485#endif /* CONFIG_SND_VERBOSE_PROCFS */
495 /* misc flags */ 486 /* misc flags */
496 unsigned int hw_opened: 1; 487 unsigned int hw_opened: 1;
@@ -512,10 +503,8 @@ struct snd_pcm_str {
512#endif 503#endif
513#ifdef CONFIG_SND_VERBOSE_PROCFS 504#ifdef CONFIG_SND_VERBOSE_PROCFS
514 struct snd_info_entry *proc_root; 505 struct snd_info_entry *proc_root;
515 struct snd_info_entry *proc_info_entry;
516#ifdef CONFIG_SND_PCM_XRUN_DEBUG 506#ifdef CONFIG_SND_PCM_XRUN_DEBUG
517 unsigned int xrun_debug; /* 0 = disabled, 1 = verbose, 2 = stacktrace */ 507 unsigned int xrun_debug; /* 0 = disabled, 1 = verbose, 2 = stacktrace */
518 struct snd_info_entry *proc_xrun_debug_entry;
519#endif 508#endif
520#endif 509#endif
521 struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */ 510 struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
@@ -538,6 +527,7 @@ struct snd_pcm {
538 void (*private_free) (struct snd_pcm *pcm); 527 void (*private_free) (struct snd_pcm *pcm);
539 bool internal; /* pcm is for internal use only */ 528 bool internal; /* pcm is for internal use only */
540 bool nonatomic; /* whole PCM operations are in non-atomic context */ 529 bool nonatomic; /* whole PCM operations are in non-atomic context */
530 bool no_device_suspend; /* don't invoke device PM suspend */
541#if IS_ENABLED(CONFIG_SND_PCM_OSS) 531#if IS_ENABLED(CONFIG_SND_PCM_OSS)
542 struct snd_pcm_oss oss; 532 struct snd_pcm_oss oss;
543#endif 533#endif
@@ -581,13 +571,8 @@ int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
581int snd_pcm_drain_done(struct snd_pcm_substream *substream); 571int snd_pcm_drain_done(struct snd_pcm_substream *substream);
582int snd_pcm_stop_xrun(struct snd_pcm_substream *substream); 572int snd_pcm_stop_xrun(struct snd_pcm_substream *substream);
583#ifdef CONFIG_PM 573#ifdef CONFIG_PM
584int snd_pcm_suspend(struct snd_pcm_substream *substream);
585int snd_pcm_suspend_all(struct snd_pcm *pcm); 574int snd_pcm_suspend_all(struct snd_pcm *pcm);
586#else 575#else
587static inline int snd_pcm_suspend(struct snd_pcm_substream *substream)
588{
589 return 0;
590}
591static inline int snd_pcm_suspend_all(struct snd_pcm *pcm) 576static inline int snd_pcm_suspend_all(struct snd_pcm *pcm)
592{ 577{
593 return 0; 578 return 0;
diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c
index 40ebde2e1ab1..904659d14988 100644
--- a/sound/aoa/soundbus/i2sbus/core.c
+++ b/sound/aoa/soundbus/i2sbus/core.c
@@ -380,10 +380,6 @@ static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state)
380 int err, ret = 0; 380 int err, ret = 0;
381 381
382 list_for_each_entry(i2sdev, &control->list, item) { 382 list_for_each_entry(i2sdev, &control->list, item) {
383 /* Notify Alsa */
384 /* Suspend PCM streams */
385 snd_pcm_suspend_all(i2sdev->sound.pcm);
386
387 /* Notify codecs */ 383 /* Notify codecs */
388 list_for_each_entry(cii, &i2sdev->sound.codec_list, list) { 384 list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
389 err = 0; 385 err = 0;
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 0114ffed56dd..a2d4b41096e0 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -757,7 +757,6 @@ static int aaci_do_suspend(struct snd_card *card)
757{ 757{
758 struct aaci *aaci = card->private_data; 758 struct aaci *aaci = card->private_data;
759 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); 759 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);
760 snd_pcm_suspend_all(aaci->pcm);
761 return 0; 760 return 0;
762} 761}
763 762
@@ -942,7 +941,8 @@ static int aaci_init_pcm(struct aaci *aaci)
942 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); 941 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
943 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops); 942 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops);
944 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 943 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
945 NULL, 0, 64 * 1024); 944 aaci->card->dev,
945 0, 64 * 1024);
946 } 946 }
947 947
948 return ret; 948 return ret;
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 1f72672262d0..68fe5bb11eea 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -124,7 +124,6 @@ static int pxa2xx_ac97_do_suspend(struct snd_card *card)
124 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; 124 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;
125 125
126 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); 126 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);
127 snd_pcm_suspend_all(pxa2xx_ac97_pcm);
128 snd_ac97_suspend(pxa2xx_ac97_ac97); 127 snd_ac97_suspend(pxa2xx_ac97_ac97);
129 if (platform_ops && platform_ops->suspend) 128 if (platform_ops && platform_ops->suspend)
130 platform_ops->suspend(platform_ops->priv); 129 platform_ops->suspend(platform_ops->priv);
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 380025887aef..33c87a0547a9 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -603,11 +603,9 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip)
603 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops); 603 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops);
604 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops); 604 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops);
605 605
606 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 606 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
607 &chip->pdev->dev, hw.periods_min * hw.period_bytes_min, 607 &chip->pdev->dev, hw.periods_min * hw.period_bytes_min,
608 hw.buffer_bytes_max); 608 hw.buffer_bytes_max);
609 if (retval)
610 return retval;
611 609
612 pcm->private_data = chip; 610 pcm->private_data = chip;
613 pcm->info_flags = 0; 611 pcm->info_flags = 0;
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index f7d2b373da0a..a1a6fd75cfe5 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -1015,22 +1015,13 @@ static int snd_compress_proc_init(struct snd_compr *compr)
1015 if (!entry) 1015 if (!entry)
1016 return -ENOMEM; 1016 return -ENOMEM;
1017 entry->mode = S_IFDIR | 0555; 1017 entry->mode = S_IFDIR | 0555;
1018 if (snd_info_register(entry) < 0) {
1019 snd_info_free_entry(entry);
1020 return -ENOMEM;
1021 }
1022 compr->proc_root = entry; 1018 compr->proc_root = entry;
1023 1019
1024 entry = snd_info_create_card_entry(compr->card, "info", 1020 entry = snd_info_create_card_entry(compr->card, "info",
1025 compr->proc_root); 1021 compr->proc_root);
1026 if (entry) { 1022 if (entry)
1027 snd_info_set_text_ops(entry, compr, 1023 snd_info_set_text_ops(entry, compr,
1028 snd_compress_proc_info_read); 1024 snd_compress_proc_info_read);
1029 if (snd_info_register(entry) < 0) {
1030 snd_info_free_entry(entry);
1031 entry = NULL;
1032 }
1033 }
1034 compr->proc_info_entry = entry; 1025 compr->proc_info_entry = entry;
1035 1026
1036 return 0; 1027 return 0;
diff --git a/sound/core/info.c b/sound/core/info.c
index fe502bc5e6d2..96a074019c33 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -463,11 +463,12 @@ static struct snd_info_entry *create_subdir(struct module *mod,
463} 463}
464 464
465static struct snd_info_entry * 465static struct snd_info_entry *
466snd_info_create_entry(const char *name, struct snd_info_entry *parent); 466snd_info_create_entry(const char *name, struct snd_info_entry *parent,
467 struct module *module);
467 468
468int __init snd_info_init(void) 469int __init snd_info_init(void)
469{ 470{
470 snd_proc_root = snd_info_create_entry("asound", NULL); 471 snd_proc_root = snd_info_create_entry("asound", NULL, THIS_MODULE);
471 if (!snd_proc_root) 472 if (!snd_proc_root)
472 return -ENOMEM; 473 return -ENOMEM;
473 snd_proc_root->mode = S_IFDIR | 0555; 474 snd_proc_root->mode = S_IFDIR | 0555;
@@ -503,6 +504,14 @@ int __exit snd_info_done(void)
503 return 0; 504 return 0;
504} 505}
505 506
507static void snd_card_id_read(struct snd_info_entry *entry,
508 struct snd_info_buffer *buffer)
509{
510 struct snd_card *card = entry->private_data;
511
512 snd_iprintf(buffer, "%s\n", card->id);
513}
514
506/* 515/*
507 * create a card proc file 516 * create a card proc file
508 * called from init.c 517 * called from init.c
@@ -520,28 +529,8 @@ int snd_info_card_create(struct snd_card *card)
520 if (!entry) 529 if (!entry)
521 return -ENOMEM; 530 return -ENOMEM;
522 card->proc_root = entry; 531 card->proc_root = entry;
523 return 0;
524}
525
526/* register all pending info entries */
527static int snd_info_register_recursive(struct snd_info_entry *entry)
528{
529 struct snd_info_entry *p;
530 int err;
531 532
532 if (!entry->p) { 533 return snd_card_ro_proc_new(card, "id", card, snd_card_id_read);
533 err = snd_info_register(entry);
534 if (err < 0)
535 return err;
536 }
537
538 list_for_each_entry(p, &entry->children, list) {
539 err = snd_info_register_recursive(p);
540 if (err < 0)
541 return err;
542 }
543
544 return 0;
545} 534}
546 535
547/* 536/*
@@ -557,7 +546,7 @@ int snd_info_card_register(struct snd_card *card)
557 if (snd_BUG_ON(!card)) 546 if (snd_BUG_ON(!card))
558 return -ENXIO; 547 return -ENXIO;
559 548
560 err = snd_info_register_recursive(card->proc_root); 549 err = snd_info_register(card->proc_root);
561 if (err < 0) 550 if (err < 0)
562 return err; 551 return err;
563 552
@@ -705,7 +694,8 @@ EXPORT_SYMBOL(snd_info_get_str);
705 * Return: The pointer of the new instance, or %NULL on failure. 694 * Return: The pointer of the new instance, or %NULL on failure.
706 */ 695 */
707static struct snd_info_entry * 696static struct snd_info_entry *
708snd_info_create_entry(const char *name, struct snd_info_entry *parent) 697snd_info_create_entry(const char *name, struct snd_info_entry *parent,
698 struct module *module)
709{ 699{
710 struct snd_info_entry *entry; 700 struct snd_info_entry *entry;
711 entry = kzalloc(sizeof(*entry), GFP_KERNEL); 701 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
@@ -722,6 +712,7 @@ snd_info_create_entry(const char *name, struct snd_info_entry *parent)
722 INIT_LIST_HEAD(&entry->children); 712 INIT_LIST_HEAD(&entry->children);
723 INIT_LIST_HEAD(&entry->list); 713 INIT_LIST_HEAD(&entry->list);
724 entry->parent = parent; 714 entry->parent = parent;
715 entry->module = module;
725 if (parent) 716 if (parent)
726 list_add_tail(&entry->list, &parent->children); 717 list_add_tail(&entry->list, &parent->children);
727 return entry; 718 return entry;
@@ -741,10 +732,9 @@ struct snd_info_entry *snd_info_create_module_entry(struct module * module,
741 const char *name, 732 const char *name,
742 struct snd_info_entry *parent) 733 struct snd_info_entry *parent)
743{ 734{
744 struct snd_info_entry *entry = snd_info_create_entry(name, parent); 735 if (!parent)
745 if (entry) 736 parent = snd_proc_root;
746 entry->module = module; 737 return snd_info_create_entry(name, parent, module);
747 return entry;
748} 738}
749EXPORT_SYMBOL(snd_info_create_module_entry); 739EXPORT_SYMBOL(snd_info_create_module_entry);
750 740
@@ -762,12 +752,9 @@ struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
762 const char *name, 752 const char *name,
763 struct snd_info_entry * parent) 753 struct snd_info_entry * parent)
764{ 754{
765 struct snd_info_entry *entry = snd_info_create_entry(name, parent); 755 if (!parent)
766 if (entry) { 756 parent = card->proc_root;
767 entry->module = card->module; 757 return snd_info_create_entry(name, parent, card->module);
768 entry->card = card;
769 }
770 return entry;
771} 758}
772EXPORT_SYMBOL(snd_info_create_card_entry); 759EXPORT_SYMBOL(snd_info_create_card_entry);
773 760
@@ -813,15 +800,7 @@ void snd_info_free_entry(struct snd_info_entry * entry)
813} 800}
814EXPORT_SYMBOL(snd_info_free_entry); 801EXPORT_SYMBOL(snd_info_free_entry);
815 802
816/** 803static int __snd_info_register(struct snd_info_entry *entry)
817 * snd_info_register - register the info entry
818 * @entry: the info entry
819 *
820 * Registers the proc info entry.
821 *
822 * Return: Zero if successful, or a negative error code on failure.
823 */
824int snd_info_register(struct snd_info_entry * entry)
825{ 804{
826 struct proc_dir_entry *root, *p = NULL; 805 struct proc_dir_entry *root, *p = NULL;
827 806
@@ -829,6 +808,8 @@ int snd_info_register(struct snd_info_entry * entry)
829 return -ENXIO; 808 return -ENXIO;
830 root = entry->parent == NULL ? snd_proc_root->p : entry->parent->p; 809 root = entry->parent == NULL ? snd_proc_root->p : entry->parent->p;
831 mutex_lock(&info_mutex); 810 mutex_lock(&info_mutex);
811 if (entry->p || !root)
812 goto unlock;
832 if (S_ISDIR(entry->mode)) { 813 if (S_ISDIR(entry->mode)) {
833 p = proc_mkdir_mode(entry->name, entry->mode, root); 814 p = proc_mkdir_mode(entry->name, entry->mode, root);
834 if (!p) { 815 if (!p) {
@@ -850,11 +831,73 @@ int snd_info_register(struct snd_info_entry * entry)
850 proc_set_size(p, entry->size); 831 proc_set_size(p, entry->size);
851 } 832 }
852 entry->p = p; 833 entry->p = p;
834 unlock:
853 mutex_unlock(&info_mutex); 835 mutex_unlock(&info_mutex);
854 return 0; 836 return 0;
855} 837}
838
839/**
840 * snd_info_register - register the info entry
841 * @entry: the info entry
842 *
843 * Registers the proc info entry.
844 * The all children entries are registered recursively.
845 *
846 * Return: Zero if successful, or a negative error code on failure.
847 */
848int snd_info_register(struct snd_info_entry *entry)
849{
850 struct snd_info_entry *p;
851 int err;
852
853 if (!entry->p) {
854 err = __snd_info_register(entry);
855 if (err < 0)
856 return err;
857 }
858
859 list_for_each_entry(p, &entry->children, list) {
860 err = snd_info_register(p);
861 if (err < 0)
862 return err;
863 }
864
865 return 0;
866}
856EXPORT_SYMBOL(snd_info_register); 867EXPORT_SYMBOL(snd_info_register);
857 868
869/**
870 * snd_card_rw_proc_new - Create a read/write text proc file entry for the card
871 * @card: the card instance
872 * @name: the file name
873 * @private_data: the arbitrary private data
874 * @read: the read callback
875 * @write: the write callback, NULL for read-only
876 *
877 * This proc file entry will be registered via snd_card_register() call, and
878 * it will be removed automatically at the card removal, too.
879 */
880int snd_card_rw_proc_new(struct snd_card *card, const char *name,
881 void *private_data,
882 void (*read)(struct snd_info_entry *,
883 struct snd_info_buffer *),
884 void (*write)(struct snd_info_entry *entry,
885 struct snd_info_buffer *buffer))
886{
887 struct snd_info_entry *entry;
888
889 entry = snd_info_create_card_entry(card, name, card->proc_root);
890 if (!entry)
891 return -ENOMEM;
892 snd_info_set_text_ops(entry, private_data, read);
893 if (write) {
894 entry->mode |= 0200;
895 entry->c.text.write = write;
896 }
897 return 0;
898}
899EXPORT_SYMBOL_GPL(snd_card_rw_proc_new);
900
858/* 901/*
859 902
860 */ 903 */
diff --git a/sound/core/init.c b/sound/core/init.c
index 4849c611c0fe..0c4dc40376a7 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -100,31 +100,6 @@ int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
100EXPORT_SYMBOL(snd_mixer_oss_notify_callback); 100EXPORT_SYMBOL(snd_mixer_oss_notify_callback);
101#endif 101#endif
102 102
103#ifdef CONFIG_SND_PROC_FS
104static void snd_card_id_read(struct snd_info_entry *entry,
105 struct snd_info_buffer *buffer)
106{
107 snd_iprintf(buffer, "%s\n", entry->card->id);
108}
109
110static int init_info_for_card(struct snd_card *card)
111{
112 struct snd_info_entry *entry;
113
114 entry = snd_info_create_card_entry(card, "id", card->proc_root);
115 if (!entry) {
116 dev_dbg(card->dev, "unable to create card entry\n");
117 return -ENOMEM;
118 }
119 entry->c.text.read = snd_card_id_read;
120 card->proc_id = entry;
121
122 return snd_info_card_register(card);
123}
124#else /* !CONFIG_SND_PROC_FS */
125#define init_info_for_card(card)
126#endif
127
128static int check_empty_slot(struct module *module, int slot) 103static int check_empty_slot(struct module *module, int slot)
129{ 104{
130 return !slots[slot] || !*slots[slot]; 105 return !slots[slot] || !*slots[slot];
@@ -491,7 +466,6 @@ static int snd_card_do_free(struct snd_card *card)
491 snd_device_free_all(card); 466 snd_device_free_all(card);
492 if (card->private_free) 467 if (card->private_free)
493 card->private_free(card); 468 card->private_free(card);
494 snd_info_free_entry(card->proc_id);
495 if (snd_info_card_free(card) < 0) { 469 if (snd_info_card_free(card) < 0) {
496 dev_warn(card->dev, "unable to free card info\n"); 470 dev_warn(card->dev, "unable to free card info\n");
497 /* Not fatal error */ 471 /* Not fatal error */
@@ -795,7 +769,10 @@ int snd_card_register(struct snd_card *card)
795 } 769 }
796 snd_cards[card->number] = card; 770 snd_cards[card->number] = card;
797 mutex_unlock(&snd_card_mutex); 771 mutex_unlock(&snd_card_mutex);
798 init_info_for_card(card); 772 err = snd_info_card_register(card);
773 if (err < 0)
774 return err;
775
799#if IS_ENABLED(CONFIG_SND_MIXER_OSS) 776#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
800 if (snd_mixer_oss_notify_callback) 777 if (snd_mixer_oss_notify_callback)
801 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); 778 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 59a4adc286ed..eb974235c92b 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -182,6 +182,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
182 return -ENXIO; 182 return -ENXIO;
183 if (WARN_ON(!dmab)) 183 if (WARN_ON(!dmab))
184 return -ENXIO; 184 return -ENXIO;
185 if (WARN_ON(!device))
186 return -EINVAL;
185 187
186 dmab->dev.type = type; 188 dmab->dev.type = type;
187 dmab->dev.dev = device; 189 dmab->dev.dev = device;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 467039b342b5..d5b0d7ba83c4 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2427,7 +2427,6 @@ static int snd_pcm_oss_open_file(struct file *file,
2427 } 2427 }
2428 2428
2429 pcm_oss_file->streams[idx] = substream; 2429 pcm_oss_file->streams[idx] = substream;
2430 substream->file = pcm_oss_file;
2431 snd_pcm_oss_init_substream(substream, &setup[idx], minor); 2430 snd_pcm_oss_init_substream(substream, &setup[idx], minor);
2432 } 2431 }
2433 2432
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 01b9d62eef14..7b63aee124af 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -528,52 +528,44 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
528 if (!entry) 528 if (!entry)
529 return -ENOMEM; 529 return -ENOMEM;
530 entry->mode = S_IFDIR | 0555; 530 entry->mode = S_IFDIR | 0555;
531 if (snd_info_register(entry) < 0) {
532 snd_info_free_entry(entry);
533 return -ENOMEM;
534 }
535 pstr->proc_root = entry; 531 pstr->proc_root = entry;
536 entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root); 532 entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root);
537 if (entry) { 533 if (entry)
538 snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read); 534 snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read);
539 if (snd_info_register(entry) < 0) {
540 snd_info_free_entry(entry);
541 entry = NULL;
542 }
543 }
544 pstr->proc_info_entry = entry;
545
546#ifdef CONFIG_SND_PCM_XRUN_DEBUG 535#ifdef CONFIG_SND_PCM_XRUN_DEBUG
547 entry = snd_info_create_card_entry(pcm->card, "xrun_debug", 536 entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
548 pstr->proc_root); 537 pstr->proc_root);
549 if (entry) { 538 if (entry) {
550 entry->c.text.read = snd_pcm_xrun_debug_read; 539 snd_info_set_text_ops(entry, pstr, snd_pcm_xrun_debug_read);
551 entry->c.text.write = snd_pcm_xrun_debug_write; 540 entry->c.text.write = snd_pcm_xrun_debug_write;
552 entry->mode |= 0200; 541 entry->mode |= 0200;
553 entry->private_data = pstr;
554 if (snd_info_register(entry) < 0) {
555 snd_info_free_entry(entry);
556 entry = NULL;
557 }
558 } 542 }
559 pstr->proc_xrun_debug_entry = entry;
560#endif 543#endif
561 return 0; 544 return 0;
562} 545}
563 546
564static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) 547static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
565{ 548{
566#ifdef CONFIG_SND_PCM_XRUN_DEBUG
567 snd_info_free_entry(pstr->proc_xrun_debug_entry);
568 pstr->proc_xrun_debug_entry = NULL;
569#endif
570 snd_info_free_entry(pstr->proc_info_entry);
571 pstr->proc_info_entry = NULL;
572 snd_info_free_entry(pstr->proc_root); 549 snd_info_free_entry(pstr->proc_root);
573 pstr->proc_root = NULL; 550 pstr->proc_root = NULL;
574 return 0; 551 return 0;
575} 552}
576 553
554static struct snd_info_entry *
555create_substream_info_entry(struct snd_pcm_substream *substream,
556 const char *name,
557 void (*read)(struct snd_info_entry *,
558 struct snd_info_buffer *))
559{
560 struct snd_info_entry *entry;
561
562 entry = snd_info_create_card_entry(substream->pcm->card, name,
563 substream->proc_root);
564 if (entry)
565 snd_info_set_text_ops(entry, substream, read);
566 return entry;
567}
568
577static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) 569static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
578{ 570{
579 struct snd_info_entry *entry; 571 struct snd_info_entry *entry;
@@ -588,101 +580,61 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
588 if (!entry) 580 if (!entry)
589 return -ENOMEM; 581 return -ENOMEM;
590 entry->mode = S_IFDIR | 0555; 582 entry->mode = S_IFDIR | 0555;
591 if (snd_info_register(entry) < 0) {
592 snd_info_free_entry(entry);
593 return -ENOMEM;
594 }
595 substream->proc_root = entry; 583 substream->proc_root = entry;
596 entry = snd_info_create_card_entry(card, "info", substream->proc_root); 584
597 if (entry) { 585 create_substream_info_entry(substream, "info",
598 snd_info_set_text_ops(entry, substream, 586 snd_pcm_substream_proc_info_read);
599 snd_pcm_substream_proc_info_read); 587 create_substream_info_entry(substream, "hw_params",
600 if (snd_info_register(entry) < 0) { 588 snd_pcm_substream_proc_hw_params_read);
601 snd_info_free_entry(entry); 589 create_substream_info_entry(substream, "sw_params",
602 entry = NULL; 590 snd_pcm_substream_proc_sw_params_read);
603 } 591 create_substream_info_entry(substream, "status",
604 } 592 snd_pcm_substream_proc_status_read);
605 substream->proc_info_entry = entry;
606 entry = snd_info_create_card_entry(card, "hw_params",
607 substream->proc_root);
608 if (entry) {
609 snd_info_set_text_ops(entry, substream,
610 snd_pcm_substream_proc_hw_params_read);
611 if (snd_info_register(entry) < 0) {
612 snd_info_free_entry(entry);
613 entry = NULL;
614 }
615 }
616 substream->proc_hw_params_entry = entry;
617 entry = snd_info_create_card_entry(card, "sw_params",
618 substream->proc_root);
619 if (entry) {
620 snd_info_set_text_ops(entry, substream,
621 snd_pcm_substream_proc_sw_params_read);
622 if (snd_info_register(entry) < 0) {
623 snd_info_free_entry(entry);
624 entry = NULL;
625 }
626 }
627 substream->proc_sw_params_entry = entry;
628 entry = snd_info_create_card_entry(card, "status",
629 substream->proc_root);
630 if (entry) {
631 snd_info_set_text_ops(entry, substream,
632 snd_pcm_substream_proc_status_read);
633 if (snd_info_register(entry) < 0) {
634 snd_info_free_entry(entry);
635 entry = NULL;
636 }
637 }
638 substream->proc_status_entry = entry;
639 593
640#ifdef CONFIG_SND_PCM_XRUN_DEBUG 594#ifdef CONFIG_SND_PCM_XRUN_DEBUG
641 entry = snd_info_create_card_entry(card, "xrun_injection", 595 entry = create_substream_info_entry(substream, "xrun_injection", NULL);
642 substream->proc_root);
643 if (entry) { 596 if (entry) {
644 entry->private_data = substream;
645 entry->c.text.read = NULL;
646 entry->c.text.write = snd_pcm_xrun_injection_write; 597 entry->c.text.write = snd_pcm_xrun_injection_write;
647 entry->mode = S_IFREG | 0200; 598 entry->mode = S_IFREG | 0200;
648 if (snd_info_register(entry) < 0) {
649 snd_info_free_entry(entry);
650 entry = NULL;
651 }
652 } 599 }
653 substream->proc_xrun_injection_entry = entry;
654#endif /* CONFIG_SND_PCM_XRUN_DEBUG */ 600#endif /* CONFIG_SND_PCM_XRUN_DEBUG */
655 601
656 return 0; 602 return 0;
657} 603}
658 604
659static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
660{
661 snd_info_free_entry(substream->proc_info_entry);
662 substream->proc_info_entry = NULL;
663 snd_info_free_entry(substream->proc_hw_params_entry);
664 substream->proc_hw_params_entry = NULL;
665 snd_info_free_entry(substream->proc_sw_params_entry);
666 substream->proc_sw_params_entry = NULL;
667 snd_info_free_entry(substream->proc_status_entry);
668 substream->proc_status_entry = NULL;
669#ifdef CONFIG_SND_PCM_XRUN_DEBUG
670 snd_info_free_entry(substream->proc_xrun_injection_entry);
671 substream->proc_xrun_injection_entry = NULL;
672#endif
673 snd_info_free_entry(substream->proc_root);
674 substream->proc_root = NULL;
675 return 0;
676}
677#else /* !CONFIG_SND_VERBOSE_PROCFS */ 605#else /* !CONFIG_SND_VERBOSE_PROCFS */
678static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; } 606static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; }
679static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; } 607static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; }
680static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; } 608static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; }
681static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; }
682#endif /* CONFIG_SND_VERBOSE_PROCFS */ 609#endif /* CONFIG_SND_VERBOSE_PROCFS */
683 610
684static const struct attribute_group *pcm_dev_attr_groups[]; 611static const struct attribute_group *pcm_dev_attr_groups[];
685 612
613/*
614 * PM callbacks: we need to deal only with suspend here, as the resume is
615 * triggered either from user-space or the driver's resume callback
616 */
617#ifdef CONFIG_PM_SLEEP
618static int do_pcm_suspend(struct device *dev)
619{
620 struct snd_pcm_str *pstr = container_of(dev, struct snd_pcm_str, dev);
621
622 if (!pstr->pcm->no_device_suspend)
623 snd_pcm_suspend_all(pstr->pcm);
624 return 0;
625}
626#endif
627
628static const struct dev_pm_ops pcm_dev_pm_ops = {
629 SET_SYSTEM_SLEEP_PM_OPS(do_pcm_suspend, NULL)
630};
631
632/* device type for PCM -- basically only for passing PM callbacks */
633static const struct device_type pcm_dev_type = {
634 .name = "pcm",
635 .pm = &pcm_dev_pm_ops,
636};
637
686/** 638/**
687 * snd_pcm_new_stream - create a new PCM stream 639 * snd_pcm_new_stream - create a new PCM stream
688 * @pcm: the pcm instance 640 * @pcm: the pcm instance
@@ -713,6 +665,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
713 665
714 snd_device_initialize(&pstr->dev, pcm->card); 666 snd_device_initialize(&pstr->dev, pcm->card);
715 pstr->dev.groups = pcm_dev_attr_groups; 667 pstr->dev.groups = pcm_dev_attr_groups;
668 pstr->dev.type = &pcm_dev_type;
716 dev_set_name(&pstr->dev, "pcmC%iD%i%c", pcm->card->number, pcm->device, 669 dev_set_name(&pstr->dev, "pcmC%iD%i%c", pcm->card->number, pcm->device,
717 stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c'); 670 stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c');
718 671
@@ -753,9 +706,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
753 } 706 }
754 } 707 }
755 substream->group = &substream->self_group; 708 substream->group = &substream->self_group;
756 spin_lock_init(&substream->self_group.lock); 709 snd_pcm_group_init(&substream->self_group);
757 mutex_init(&substream->self_group.mutex);
758 INIT_LIST_HEAD(&substream->self_group.substreams);
759 list_add_tail(&substream->link_list, &substream->self_group.substreams); 710 list_add_tail(&substream->link_list, &substream->self_group.substreams);
760 atomic_set(&substream->mmap_count, 0); 711 atomic_set(&substream->mmap_count, 0);
761 prev = substream; 712 prev = substream;
@@ -885,15 +836,17 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
885#if IS_ENABLED(CONFIG_SND_PCM_OSS) 836#if IS_ENABLED(CONFIG_SND_PCM_OSS)
886 struct snd_pcm_oss_setup *setup, *setupn; 837 struct snd_pcm_oss_setup *setup, *setupn;
887#endif 838#endif
839
840 /* free all proc files under the stream */
841 snd_pcm_stream_proc_done(pstr);
842
888 substream = pstr->substream; 843 substream = pstr->substream;
889 while (substream) { 844 while (substream) {
890 substream_next = substream->next; 845 substream_next = substream->next;
891 snd_pcm_timer_done(substream); 846 snd_pcm_timer_done(substream);
892 snd_pcm_substream_proc_done(substream);
893 kfree(substream); 847 kfree(substream);
894 substream = substream_next; 848 substream = substream_next;
895 } 849 }
896 snd_pcm_stream_proc_done(pstr);
897#if IS_ENABLED(CONFIG_SND_PCM_OSS) 850#if IS_ENABLED(CONFIG_SND_PCM_OSS)
898 for (setup = pstr->oss.setup_list; setup; setup = setupn) { 851 for (setup = pstr->oss.setup_list; setup; setup = setupn) {
899 setupn = setup->next; 852 setupn = setup->next;
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 40013b26f671..5957aeb1099e 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -2112,6 +2112,13 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
2112 return 0; 2112 return 0;
2113} 2113}
2114 2114
2115/* allow waiting for a capture stream that hasn't been started */
2116#if IS_ENABLED(CONFIG_SND_PCM_OSS)
2117#define wait_capture_start(substream) ((substream)->oss.oss)
2118#else
2119#define wait_capture_start(substream) false
2120#endif
2121
2115/* the common loop for read/write data */ 2122/* the common loop for read/write data */
2116snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream, 2123snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
2117 void *data, bool interleaved, 2124 void *data, bool interleaved,
@@ -2182,7 +2189,7 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
2182 err = snd_pcm_start(substream); 2189 err = snd_pcm_start(substream);
2183 if (err < 0) 2190 if (err < 0)
2184 goto _end_unlock; 2191 goto _end_unlock;
2185 } else { 2192 } else if (!wait_capture_start(substream)) {
2186 /* nothing to do */ 2193 /* nothing to do */
2187 err = 0; 2194 err = 0;
2188 goto _end_unlock; 2195 goto _end_unlock;
@@ -2219,9 +2226,8 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
2219 if (frames > cont) 2226 if (frames > cont)
2220 frames = cont; 2227 frames = cont;
2221 if (snd_BUG_ON(!frames)) { 2228 if (snd_BUG_ON(!frames)) {
2222 runtime->twake = 0; 2229 err = -EINVAL;
2223 snd_pcm_stream_unlock_irq(substream); 2230 goto _end_unlock;
2224 return -EINVAL;
2225 } 2231 }
2226 snd_pcm_stream_unlock_irq(substream); 2232 snd_pcm_stream_unlock_irq(substream);
2227 err = writer(substream, appl_ofs, data, offset, frames, 2233 err = writer(substream, appl_ofs, data, offset, frames,
diff --git a/sound/core/pcm_local.h b/sound/core/pcm_local.h
index c515612969a4..0b4b5dfaec18 100644
--- a/sound/core/pcm_local.h
+++ b/sound/core/pcm_local.h
@@ -66,5 +66,6 @@ static inline void snd_pcm_timer_done(struct snd_pcm_substream *substream) {}
66#endif 66#endif
67 67
68void __snd_pcm_xrun(struct snd_pcm_substream *substream); 68void __snd_pcm_xrun(struct snd_pcm_substream *substream);
69void snd_pcm_group_init(struct snd_pcm_group *group);
69 70
70#endif /* __SOUND_CORE_PCM_LOCAL_H */ 71#endif /* __SOUND_CORE_PCM_LOCAL_H */
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 4b5356a10315..4012a3a01de1 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -93,12 +93,6 @@ static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream
93int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) 93int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
94{ 94{
95 snd_pcm_lib_preallocate_dma_free(substream); 95 snd_pcm_lib_preallocate_dma_free(substream);
96#ifdef CONFIG_SND_VERBOSE_PROCFS
97 snd_info_free_entry(substream->proc_prealloc_max_entry);
98 substream->proc_prealloc_max_entry = NULL;
99 snd_info_free_entry(substream->proc_prealloc_entry);
100 substream->proc_prealloc_entry = NULL;
101#endif
102 return 0; 96 return 0;
103} 97}
104 98
@@ -198,26 +192,19 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
198{ 192{
199 struct snd_info_entry *entry; 193 struct snd_info_entry *entry;
200 194
201 if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", substream->proc_root)) != NULL) { 195 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc",
202 entry->c.text.read = snd_pcm_lib_preallocate_proc_read; 196 substream->proc_root);
197 if (entry) {
198 snd_info_set_text_ops(entry, substream,
199 snd_pcm_lib_preallocate_proc_read);
203 entry->c.text.write = snd_pcm_lib_preallocate_proc_write; 200 entry->c.text.write = snd_pcm_lib_preallocate_proc_write;
204 entry->mode |= 0200; 201 entry->mode |= 0200;
205 entry->private_data = substream;
206 if (snd_info_register(entry) < 0) {
207 snd_info_free_entry(entry);
208 entry = NULL;
209 }
210 }
211 substream->proc_prealloc_entry = entry;
212 if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", substream->proc_root)) != NULL) {
213 entry->c.text.read = snd_pcm_lib_preallocate_max_proc_read;
214 entry->private_data = substream;
215 if (snd_info_register(entry) < 0) {
216 snd_info_free_entry(entry);
217 entry = NULL;
218 }
219 } 202 }
220 substream->proc_prealloc_max_entry = entry; 203 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max",
204 substream->proc_root);
205 if (entry)
206 snd_info_set_text_ops(entry, substream,
207 snd_pcm_lib_preallocate_max_proc_read);
221} 208}
222 209
223#else /* !CONFIG_SND_VERBOSE_PROCFS */ 210#else /* !CONFIG_SND_VERBOSE_PROCFS */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 818dff1de545..672babd20cb1 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -85,71 +85,30 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream);
85 * 85 *
86 */ 86 */
87 87
88static DEFINE_RWLOCK(snd_pcm_link_rwlock);
89static DECLARE_RWSEM(snd_pcm_link_rwsem); 88static DECLARE_RWSEM(snd_pcm_link_rwsem);
90 89
91/* Writer in rwsem may block readers even during its waiting in queue, 90void snd_pcm_group_init(struct snd_pcm_group *group)
92 * and this may lead to a deadlock when the code path takes read sem
93 * twice (e.g. one in snd_pcm_action_nonatomic() and another in
94 * snd_pcm_stream_lock()). As a (suboptimal) workaround, let writer to
95 * sleep until all the readers are completed without blocking by writer.
96 */
97static inline void down_write_nonfifo(struct rw_semaphore *lock)
98{ 91{
99 while (!down_write_trylock(lock)) 92 spin_lock_init(&group->lock);
100 msleep(1); 93 mutex_init(&group->mutex);
94 INIT_LIST_HEAD(&group->substreams);
95 refcount_set(&group->refs, 0);
101} 96}
102 97
103#define PCM_LOCK_DEFAULT 0 98/* define group lock helpers */
104#define PCM_LOCK_IRQ 1 99#define DEFINE_PCM_GROUP_LOCK(action, mutex_action) \
105#define PCM_LOCK_IRQSAVE 2 100static void snd_pcm_group_ ## action(struct snd_pcm_group *group, bool nonatomic) \
106 101{ \
107static unsigned long __snd_pcm_stream_lock_mode(struct snd_pcm_substream *substream, 102 if (nonatomic) \
108 unsigned int mode) 103 mutex_ ## mutex_action(&group->mutex); \
109{ 104 else \
110 unsigned long flags = 0; 105 spin_ ## action(&group->lock); \
111 if (substream->pcm->nonatomic) {
112 down_read_nested(&snd_pcm_link_rwsem, SINGLE_DEPTH_NESTING);
113 mutex_lock(&substream->self_group.mutex);
114 } else {
115 switch (mode) {
116 case PCM_LOCK_DEFAULT:
117 read_lock(&snd_pcm_link_rwlock);
118 break;
119 case PCM_LOCK_IRQ:
120 read_lock_irq(&snd_pcm_link_rwlock);
121 break;
122 case PCM_LOCK_IRQSAVE:
123 read_lock_irqsave(&snd_pcm_link_rwlock, flags);
124 break;
125 }
126 spin_lock(&substream->self_group.lock);
127 }
128 return flags;
129} 106}
130 107
131static void __snd_pcm_stream_unlock_mode(struct snd_pcm_substream *substream, 108DEFINE_PCM_GROUP_LOCK(lock, lock);
132 unsigned int mode, unsigned long flags) 109DEFINE_PCM_GROUP_LOCK(unlock, unlock);
133{ 110DEFINE_PCM_GROUP_LOCK(lock_irq, lock);
134 if (substream->pcm->nonatomic) { 111DEFINE_PCM_GROUP_LOCK(unlock_irq, unlock);
135 mutex_unlock(&substream->self_group.mutex);
136 up_read(&snd_pcm_link_rwsem);
137 } else {
138 spin_unlock(&substream->self_group.lock);
139
140 switch (mode) {
141 case PCM_LOCK_DEFAULT:
142 read_unlock(&snd_pcm_link_rwlock);
143 break;
144 case PCM_LOCK_IRQ:
145 read_unlock_irq(&snd_pcm_link_rwlock);
146 break;
147 case PCM_LOCK_IRQSAVE:
148 read_unlock_irqrestore(&snd_pcm_link_rwlock, flags);
149 break;
150 }
151 }
152}
153 112
154/** 113/**
155 * snd_pcm_stream_lock - Lock the PCM stream 114 * snd_pcm_stream_lock - Lock the PCM stream
@@ -161,7 +120,7 @@ static void __snd_pcm_stream_unlock_mode(struct snd_pcm_substream *substream,
161 */ 120 */
162void snd_pcm_stream_lock(struct snd_pcm_substream *substream) 121void snd_pcm_stream_lock(struct snd_pcm_substream *substream)
163{ 122{
164 __snd_pcm_stream_lock_mode(substream, PCM_LOCK_DEFAULT); 123 snd_pcm_group_lock(&substream->self_group, substream->pcm->nonatomic);
165} 124}
166EXPORT_SYMBOL_GPL(snd_pcm_stream_lock); 125EXPORT_SYMBOL_GPL(snd_pcm_stream_lock);
167 126
@@ -173,7 +132,7 @@ EXPORT_SYMBOL_GPL(snd_pcm_stream_lock);
173 */ 132 */
174void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) 133void snd_pcm_stream_unlock(struct snd_pcm_substream *substream)
175{ 134{
176 __snd_pcm_stream_unlock_mode(substream, PCM_LOCK_DEFAULT, 0); 135 snd_pcm_group_unlock(&substream->self_group, substream->pcm->nonatomic);
177} 136}
178EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock); 137EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock);
179 138
@@ -187,7 +146,8 @@ EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock);
187 */ 146 */
188void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) 147void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream)
189{ 148{
190 __snd_pcm_stream_lock_mode(substream, PCM_LOCK_IRQ); 149 snd_pcm_group_lock_irq(&substream->self_group,
150 substream->pcm->nonatomic);
191} 151}
192EXPORT_SYMBOL_GPL(snd_pcm_stream_lock_irq); 152EXPORT_SYMBOL_GPL(snd_pcm_stream_lock_irq);
193 153
@@ -199,13 +159,19 @@ EXPORT_SYMBOL_GPL(snd_pcm_stream_lock_irq);
199 */ 159 */
200void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) 160void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream)
201{ 161{
202 __snd_pcm_stream_unlock_mode(substream, PCM_LOCK_IRQ, 0); 162 snd_pcm_group_unlock_irq(&substream->self_group,
163 substream->pcm->nonatomic);
203} 164}
204EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irq); 165EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irq);
205 166
206unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) 167unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream)
207{ 168{
208 return __snd_pcm_stream_lock_mode(substream, PCM_LOCK_IRQSAVE); 169 unsigned long flags = 0;
170 if (substream->pcm->nonatomic)
171 mutex_lock(&substream->self_group.mutex);
172 else
173 spin_lock_irqsave(&substream->self_group.lock, flags);
174 return flags;
209} 175}
210EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave); 176EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave);
211 177
@@ -219,7 +185,10 @@ EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave);
219void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, 185void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
220 unsigned long flags) 186 unsigned long flags)
221{ 187{
222 __snd_pcm_stream_unlock_mode(substream, PCM_LOCK_IRQSAVE, flags); 188 if (substream->pcm->nonatomic)
189 mutex_unlock(&substream->self_group.mutex);
190 else
191 spin_unlock_irqrestore(&substream->self_group.lock, flags);
223} 192}
224EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irqrestore); 193EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irqrestore);
225 194
@@ -1124,6 +1093,68 @@ static int snd_pcm_action_single(const struct action_ops *ops,
1124 return res; 1093 return res;
1125} 1094}
1126 1095
1096static void snd_pcm_group_assign(struct snd_pcm_substream *substream,
1097 struct snd_pcm_group *new_group)
1098{
1099 substream->group = new_group;
1100 list_move(&substream->link_list, &new_group->substreams);
1101}
1102
1103/*
1104 * Unref and unlock the group, but keep the stream lock;
1105 * when the group becomes empty and no longer referred, destroy itself
1106 */
1107static void snd_pcm_group_unref(struct snd_pcm_group *group,
1108 struct snd_pcm_substream *substream)
1109{
1110 bool do_free;
1111
1112 if (!group)
1113 return;
1114 do_free = refcount_dec_and_test(&group->refs) &&
1115 list_empty(&group->substreams);
1116 snd_pcm_group_unlock(group, substream->pcm->nonatomic);
1117 if (do_free)
1118 kfree(group);
1119}
1120
1121/*
1122 * Lock the group inside a stream lock and reference it;
1123 * return the locked group object, or NULL if not linked
1124 */
1125static struct snd_pcm_group *
1126snd_pcm_stream_group_ref(struct snd_pcm_substream *substream)
1127{
1128 bool nonatomic = substream->pcm->nonatomic;
1129 struct snd_pcm_group *group;
1130 bool trylock;
1131
1132 for (;;) {
1133 if (!snd_pcm_stream_linked(substream))
1134 return NULL;
1135 group = substream->group;
1136 /* block freeing the group object */
1137 refcount_inc(&group->refs);
1138
1139 trylock = nonatomic ? mutex_trylock(&group->mutex) :
1140 spin_trylock(&group->lock);
1141 if (trylock)
1142 break; /* OK */
1143
1144 /* re-lock for avoiding ABBA deadlock */
1145 snd_pcm_stream_unlock(substream);
1146 snd_pcm_group_lock(group, nonatomic);
1147 snd_pcm_stream_lock(substream);
1148
1149 /* check the group again; the above opens a small race window */
1150 if (substream->group == group)
1151 break; /* OK */
1152 /* group changed, try again */
1153 snd_pcm_group_unref(group, substream);
1154 }
1155 return group;
1156}
1157
1127/* 1158/*
1128 * Note: call with stream lock 1159 * Note: call with stream lock
1129 */ 1160 */
@@ -1131,28 +1162,15 @@ static int snd_pcm_action(const struct action_ops *ops,
1131 struct snd_pcm_substream *substream, 1162 struct snd_pcm_substream *substream,
1132 int state) 1163 int state)
1133{ 1164{
1165 struct snd_pcm_group *group;
1134 int res; 1166 int res;
1135 1167
1136 if (!snd_pcm_stream_linked(substream)) 1168 group = snd_pcm_stream_group_ref(substream);
1137 return snd_pcm_action_single(ops, substream, state); 1169 if (group)
1138
1139 if (substream->pcm->nonatomic) {
1140 if (!mutex_trylock(&substream->group->mutex)) {
1141 mutex_unlock(&substream->self_group.mutex);
1142 mutex_lock(&substream->group->mutex);
1143 mutex_lock(&substream->self_group.mutex);
1144 }
1145 res = snd_pcm_action_group(ops, substream, state, 1);
1146 mutex_unlock(&substream->group->mutex);
1147 } else {
1148 if (!spin_trylock(&substream->group->lock)) {
1149 spin_unlock(&substream->self_group.lock);
1150 spin_lock(&substream->group->lock);
1151 spin_lock(&substream->self_group.lock);
1152 }
1153 res = snd_pcm_action_group(ops, substream, state, 1); 1170 res = snd_pcm_action_group(ops, substream, state, 1);
1154 spin_unlock(&substream->group->lock); 1171 else
1155 } 1172 res = snd_pcm_action_single(ops, substream, state);
1173 snd_pcm_group_unref(group, substream);
1156 return res; 1174 return res;
1157} 1175}
1158 1176
@@ -1179,6 +1197,7 @@ static int snd_pcm_action_nonatomic(const struct action_ops *ops,
1179{ 1197{
1180 int res; 1198 int res;
1181 1199
1200 /* Guarantee the group members won't change during non-atomic action */
1182 down_read(&snd_pcm_link_rwsem); 1201 down_read(&snd_pcm_link_rwsem);
1183 if (snd_pcm_stream_linked(substream)) 1202 if (snd_pcm_stream_linked(substream))
1184 res = snd_pcm_action_group(ops, substream, state, 0); 1203 res = snd_pcm_action_group(ops, substream, state, 0);
@@ -1460,29 +1479,24 @@ static const struct action_ops snd_pcm_action_suspend = {
1460 .post_action = snd_pcm_post_suspend 1479 .post_action = snd_pcm_post_suspend
1461}; 1480};
1462 1481
1463/** 1482/*
1464 * snd_pcm_suspend - trigger SUSPEND to all linked streams 1483 * snd_pcm_suspend - trigger SUSPEND to all linked streams
1465 * @substream: the PCM substream 1484 * @substream: the PCM substream
1466 * 1485 *
1467 * After this call, all streams are changed to SUSPENDED state. 1486 * After this call, all streams are changed to SUSPENDED state.
1468 * 1487 *
1469 * Return: Zero if successful (or @substream is %NULL), or a negative error 1488 * Return: Zero if successful, or a negative error code.
1470 * code.
1471 */ 1489 */
1472int snd_pcm_suspend(struct snd_pcm_substream *substream) 1490static int snd_pcm_suspend(struct snd_pcm_substream *substream)
1473{ 1491{
1474 int err; 1492 int err;
1475 unsigned long flags; 1493 unsigned long flags;
1476 1494
1477 if (! substream)
1478 return 0;
1479
1480 snd_pcm_stream_lock_irqsave(substream, flags); 1495 snd_pcm_stream_lock_irqsave(substream, flags);
1481 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); 1496 err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0);
1482 snd_pcm_stream_unlock_irqrestore(substream, flags); 1497 snd_pcm_stream_unlock_irqrestore(substream, flags);
1483 return err; 1498 return err;
1484} 1499}
1485EXPORT_SYMBOL(snd_pcm_suspend);
1486 1500
1487/** 1501/**
1488 * snd_pcm_suspend_all - trigger SUSPEND to all substreams in the given pcm 1502 * snd_pcm_suspend_all - trigger SUSPEND to all substreams in the given pcm
@@ -1792,8 +1806,6 @@ static const struct action_ops snd_pcm_action_drain_init = {
1792 .post_action = snd_pcm_post_drain_init 1806 .post_action = snd_pcm_post_drain_init
1793}; 1807};
1794 1808
1795static int snd_pcm_drop(struct snd_pcm_substream *substream);
1796
1797/* 1809/*
1798 * Drain the stream(s). 1810 * Drain the stream(s).
1799 * When the substream is linked, sync until the draining of all playback streams 1811 * When the substream is linked, sync until the draining of all playback streams
@@ -1807,6 +1819,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1807 struct snd_card *card; 1819 struct snd_card *card;
1808 struct snd_pcm_runtime *runtime; 1820 struct snd_pcm_runtime *runtime;
1809 struct snd_pcm_substream *s; 1821 struct snd_pcm_substream *s;
1822 struct snd_pcm_group *group;
1810 wait_queue_entry_t wait; 1823 wait_queue_entry_t wait;
1811 int result = 0; 1824 int result = 0;
1812 int nonblock = 0; 1825 int nonblock = 0;
@@ -1823,7 +1836,6 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1823 } else if (substream->f_flags & O_NONBLOCK) 1836 } else if (substream->f_flags & O_NONBLOCK)
1824 nonblock = 1; 1837 nonblock = 1;
1825 1838
1826 down_read(&snd_pcm_link_rwsem);
1827 snd_pcm_stream_lock_irq(substream); 1839 snd_pcm_stream_lock_irq(substream);
1828 /* resume pause */ 1840 /* resume pause */
1829 if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) 1841 if (runtime->status->state == SNDRV_PCM_STATE_PAUSED)
@@ -1848,6 +1860,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1848 } 1860 }
1849 /* find a substream to drain */ 1861 /* find a substream to drain */
1850 to_check = NULL; 1862 to_check = NULL;
1863 group = snd_pcm_stream_group_ref(substream);
1851 snd_pcm_group_for_each_entry(s, substream) { 1864 snd_pcm_group_for_each_entry(s, substream) {
1852 if (s->stream != SNDRV_PCM_STREAM_PLAYBACK) 1865 if (s->stream != SNDRV_PCM_STREAM_PLAYBACK)
1853 continue; 1866 continue;
@@ -1857,12 +1870,12 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1857 break; 1870 break;
1858 } 1871 }
1859 } 1872 }
1873 snd_pcm_group_unref(group, substream);
1860 if (!to_check) 1874 if (!to_check)
1861 break; /* all drained */ 1875 break; /* all drained */
1862 init_waitqueue_entry(&wait, current); 1876 init_waitqueue_entry(&wait, current);
1863 add_wait_queue(&to_check->sleep, &wait); 1877 add_wait_queue(&to_check->sleep, &wait);
1864 snd_pcm_stream_unlock_irq(substream); 1878 snd_pcm_stream_unlock_irq(substream);
1865 up_read(&snd_pcm_link_rwsem);
1866 if (runtime->no_period_wakeup) 1879 if (runtime->no_period_wakeup)
1867 tout = MAX_SCHEDULE_TIMEOUT; 1880 tout = MAX_SCHEDULE_TIMEOUT;
1868 else { 1881 else {
@@ -1874,9 +1887,17 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1874 tout = msecs_to_jiffies(tout * 1000); 1887 tout = msecs_to_jiffies(tout * 1000);
1875 } 1888 }
1876 tout = schedule_timeout_interruptible(tout); 1889 tout = schedule_timeout_interruptible(tout);
1877 down_read(&snd_pcm_link_rwsem); 1890
1878 snd_pcm_stream_lock_irq(substream); 1891 snd_pcm_stream_lock_irq(substream);
1879 remove_wait_queue(&to_check->sleep, &wait); 1892 group = snd_pcm_stream_group_ref(substream);
1893 snd_pcm_group_for_each_entry(s, substream) {
1894 if (s->runtime == to_check) {
1895 remove_wait_queue(&to_check->sleep, &wait);
1896 break;
1897 }
1898 }
1899 snd_pcm_group_unref(group, substream);
1900
1880 if (card->shutdown) { 1901 if (card->shutdown) {
1881 result = -ENODEV; 1902 result = -ENODEV;
1882 break; 1903 break;
@@ -1896,7 +1917,6 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1896 1917
1897 unlock: 1918 unlock:
1898 snd_pcm_stream_unlock_irq(substream); 1919 snd_pcm_stream_unlock_irq(substream);
1899 up_read(&snd_pcm_link_rwsem);
1900 1920
1901 return result; 1921 return result;
1902} 1922}
@@ -1935,13 +1955,19 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream)
1935static bool is_pcm_file(struct file *file) 1955static bool is_pcm_file(struct file *file)
1936{ 1956{
1937 struct inode *inode = file_inode(file); 1957 struct inode *inode = file_inode(file);
1958 struct snd_pcm *pcm;
1938 unsigned int minor; 1959 unsigned int minor;
1939 1960
1940 if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major) 1961 if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major)
1941 return false; 1962 return false;
1942 minor = iminor(inode); 1963 minor = iminor(inode);
1943 return snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK) || 1964 pcm = snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK);
1944 snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE); 1965 if (!pcm)
1966 pcm = snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE);
1967 if (!pcm)
1968 return false;
1969 snd_card_unref(pcm->card);
1970 return true;
1945} 1971}
1946 1972
1947/* 1973/*
@@ -1952,7 +1978,8 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
1952 int res = 0; 1978 int res = 0;
1953 struct snd_pcm_file *pcm_file; 1979 struct snd_pcm_file *pcm_file;
1954 struct snd_pcm_substream *substream1; 1980 struct snd_pcm_substream *substream1;
1955 struct snd_pcm_group *group; 1981 struct snd_pcm_group *group, *target_group;
1982 bool nonatomic = substream->pcm->nonatomic;
1956 struct fd f = fdget(fd); 1983 struct fd f = fdget(fd);
1957 1984
1958 if (!f.file) 1985 if (!f.file)
@@ -1963,13 +1990,14 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
1963 } 1990 }
1964 pcm_file = f.file->private_data; 1991 pcm_file = f.file->private_data;
1965 substream1 = pcm_file->substream; 1992 substream1 = pcm_file->substream;
1966 group = kmalloc(sizeof(*group), GFP_KERNEL); 1993 group = kzalloc(sizeof(*group), GFP_KERNEL);
1967 if (!group) { 1994 if (!group) {
1968 res = -ENOMEM; 1995 res = -ENOMEM;
1969 goto _nolock; 1996 goto _nolock;
1970 } 1997 }
1971 down_write_nonfifo(&snd_pcm_link_rwsem); 1998 snd_pcm_group_init(group);
1972 write_lock_irq(&snd_pcm_link_rwlock); 1999
2000 down_write(&snd_pcm_link_rwsem);
1973 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || 2001 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN ||
1974 substream->runtime->status->state != substream1->runtime->status->state || 2002 substream->runtime->status->state != substream1->runtime->status->state ||
1975 substream->pcm->nonatomic != substream1->pcm->nonatomic) { 2003 substream->pcm->nonatomic != substream1->pcm->nonatomic) {
@@ -1980,23 +2008,23 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
1980 res = -EALREADY; 2008 res = -EALREADY;
1981 goto _end; 2009 goto _end;
1982 } 2010 }
2011
2012 snd_pcm_stream_lock_irq(substream);
1983 if (!snd_pcm_stream_linked(substream)) { 2013 if (!snd_pcm_stream_linked(substream)) {
1984 substream->group = group; 2014 snd_pcm_group_assign(substream, group);
1985 group = NULL; 2015 group = NULL; /* assigned, don't free this one below */
1986 spin_lock_init(&substream->group->lock); 2016 }
1987 mutex_init(&substream->group->mutex); 2017 target_group = substream->group;
1988 INIT_LIST_HEAD(&substream->group->substreams); 2018 snd_pcm_stream_unlock_irq(substream);
1989 list_add_tail(&substream->link_list, &substream->group->substreams); 2019
1990 substream->group->count = 1; 2020 snd_pcm_group_lock_irq(target_group, nonatomic);
1991 } 2021 snd_pcm_stream_lock(substream1);
1992 list_add_tail(&substream1->link_list, &substream->group->substreams); 2022 snd_pcm_group_assign(substream1, target_group);
1993 substream->group->count++; 2023 snd_pcm_stream_unlock(substream1);
1994 substream1->group = substream->group; 2024 snd_pcm_group_unlock_irq(target_group, nonatomic);
1995 _end: 2025 _end:
1996 write_unlock_irq(&snd_pcm_link_rwlock);
1997 up_write(&snd_pcm_link_rwsem); 2026 up_write(&snd_pcm_link_rwsem);
1998 _nolock: 2027 _nolock:
1999 snd_card_unref(substream1->pcm->card);
2000 kfree(group); 2028 kfree(group);
2001 _badf: 2029 _badf:
2002 fdput(f); 2030 fdput(f);
@@ -2005,34 +2033,43 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
2005 2033
2006static void relink_to_local(struct snd_pcm_substream *substream) 2034static void relink_to_local(struct snd_pcm_substream *substream)
2007{ 2035{
2008 substream->group = &substream->self_group; 2036 snd_pcm_stream_lock(substream);
2009 INIT_LIST_HEAD(&substream->self_group.substreams); 2037 snd_pcm_group_assign(substream, &substream->self_group);
2010 list_add_tail(&substream->link_list, &substream->self_group.substreams); 2038 snd_pcm_stream_unlock(substream);
2011} 2039}
2012 2040
2013static int snd_pcm_unlink(struct snd_pcm_substream *substream) 2041static int snd_pcm_unlink(struct snd_pcm_substream *substream)
2014{ 2042{
2015 struct snd_pcm_substream *s; 2043 struct snd_pcm_group *group;
2044 bool nonatomic = substream->pcm->nonatomic;
2045 bool do_free = false;
2016 int res = 0; 2046 int res = 0;
2017 2047
2018 down_write_nonfifo(&snd_pcm_link_rwsem); 2048 down_write(&snd_pcm_link_rwsem);
2019 write_lock_irq(&snd_pcm_link_rwlock); 2049
2020 if (!snd_pcm_stream_linked(substream)) { 2050 if (!snd_pcm_stream_linked(substream)) {
2021 res = -EALREADY; 2051 res = -EALREADY;
2022 goto _end; 2052 goto _end;
2023 } 2053 }
2024 list_del(&substream->link_list); 2054
2025 substream->group->count--; 2055 group = substream->group;
2026 if (substream->group->count == 1) { /* detach the last stream, too */ 2056 snd_pcm_group_lock_irq(group, nonatomic);
2027 snd_pcm_group_for_each_entry(s, substream) { 2057
2028 relink_to_local(s);
2029 break;
2030 }
2031 kfree(substream->group);
2032 }
2033 relink_to_local(substream); 2058 relink_to_local(substream);
2059
2060 /* detach the last stream, too */
2061 if (list_is_singular(&group->substreams)) {
2062 relink_to_local(list_first_entry(&group->substreams,
2063 struct snd_pcm_substream,
2064 link_list));
2065 do_free = !refcount_read(&group->refs);
2066 }
2067
2068 snd_pcm_group_unlock_irq(group, nonatomic);
2069 if (do_free)
2070 kfree(group);
2071
2034 _end: 2072 _end:
2035 write_unlock_irq(&snd_pcm_link_rwlock);
2036 up_write(&snd_pcm_link_rwsem); 2073 up_write(&snd_pcm_link_rwsem);
2037 return res; 2074 return res;
2038} 2075}
@@ -2457,10 +2494,8 @@ static int snd_pcm_open_file(struct file *file,
2457 return -ENOMEM; 2494 return -ENOMEM;
2458 } 2495 }
2459 pcm_file->substream = substream; 2496 pcm_file->substream = substream;
2460 if (substream->ref_count == 1) { 2497 if (substream->ref_count == 1)
2461 substream->file = pcm_file;
2462 substream->pcm_release = pcm_release_private; 2498 substream->pcm_release = pcm_release_private;
2463 }
2464 file->private_data = pcm_file; 2499 file->private_data = pcm_file;
2465 2500
2466 return 0; 2501 return 0;
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 1e34e6381baa..8c3fbe1276be 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -1133,16 +1133,10 @@ static void print_cable_info(struct snd_info_entry *entry,
1133static int loopback_proc_new(struct loopback *loopback, int cidx) 1133static int loopback_proc_new(struct loopback *loopback, int cidx)
1134{ 1134{
1135 char name[32]; 1135 char name[32];
1136 struct snd_info_entry *entry;
1137 int err;
1138 1136
1139 snprintf(name, sizeof(name), "cable#%d", cidx); 1137 snprintf(name, sizeof(name), "cable#%d", cidx);
1140 err = snd_card_proc_new(loopback->card, name, &entry); 1138 return snd_card_ro_proc_new(loopback->card, name, loopback,
1141 if (err < 0) 1139 print_cable_info);
1142 return err;
1143
1144 snd_info_set_text_ops(entry, loopback, print_cable_info);
1145 return 0;
1146} 1140}
1147 1141
1148static int loopback_probe(struct platform_device *devptr) 1142static int loopback_probe(struct platform_device *devptr)
@@ -1200,12 +1194,8 @@ static int loopback_remove(struct platform_device *devptr)
1200static int loopback_suspend(struct device *pdev) 1194static int loopback_suspend(struct device *pdev)
1201{ 1195{
1202 struct snd_card *card = dev_get_drvdata(pdev); 1196 struct snd_card *card = dev_get_drvdata(pdev);
1203 struct loopback *loopback = card->private_data;
1204 1197
1205 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1198 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1206
1207 snd_pcm_suspend_all(loopback->pcm[0]);
1208 snd_pcm_suspend_all(loopback->pcm[1]);
1209 return 0; 1199 return 0;
1210} 1200}
1211 1201
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 9af154db530a..2672c2e13334 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -1037,14 +1037,8 @@ static void dummy_proc_write(struct snd_info_entry *entry,
1037 1037
1038static void dummy_proc_init(struct snd_dummy *chip) 1038static void dummy_proc_init(struct snd_dummy *chip)
1039{ 1039{
1040 struct snd_info_entry *entry; 1040 snd_card_rw_proc_new(chip->card, "dummy_pcm", chip,
1041 1041 dummy_proc_read, dummy_proc_write);
1042 if (!snd_card_proc_new(chip->card, "dummy_pcm", &entry)) {
1043 snd_info_set_text_ops(entry, chip, dummy_proc_read);
1044 entry->c.text.write = dummy_proc_write;
1045 entry->mode |= 0200;
1046 entry->private_data = chip;
1047 }
1048} 1042}
1049#else 1043#else
1050#define dummy_proc_init(x) 1044#define dummy_proc_init(x)
@@ -1138,10 +1132,8 @@ static int snd_dummy_remove(struct platform_device *devptr)
1138static int snd_dummy_suspend(struct device *pdev) 1132static int snd_dummy_suspend(struct device *pdev)
1139{ 1133{
1140 struct snd_card *card = dev_get_drvdata(pdev); 1134 struct snd_card *card = dev_get_drvdata(pdev);
1141 struct snd_dummy *dummy = card->private_data;
1142 1135
1143 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1136 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1144 snd_pcm_suspend_all(dummy->pcm);
1145 return 0; 1137 return 0;
1146} 1138}
1147 1139
diff --git a/sound/drivers/opl4/opl4_proc.c b/sound/drivers/opl4/opl4_proc.c
index 16b24091d799..f1b839a0e7b7 100644
--- a/sound/drivers/opl4/opl4_proc.c
+++ b/sound/drivers/opl4/opl4_proc.c
@@ -114,10 +114,6 @@ int snd_opl4_create_proc(struct snd_opl4 *opl4)
114 entry->c.ops = &snd_opl4_mem_proc_ops; 114 entry->c.ops = &snd_opl4_mem_proc_ops;
115 entry->module = THIS_MODULE; 115 entry->module = THIS_MODULE;
116 entry->private_data = opl4; 116 entry->private_data = opl4;
117 if (snd_info_register(entry) < 0) {
118 snd_info_free_entry(entry);
119 entry = NULL;
120 }
121 } 117 }
122 opl4->proc_entry = entry; 118 opl4->proc_entry = entry;
123 return 0; 119 return 0;
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 0dd3f46eb03e..d83ad3820f02 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -197,7 +197,6 @@ static int pcsp_suspend(struct device *dev)
197{ 197{
198 struct snd_pcsp *chip = dev_get_drvdata(dev); 198 struct snd_pcsp *chip = dev_get_drvdata(dev);
199 pcsp_stop_beep(chip); 199 pcsp_stop_beep(chip);
200 snd_pcm_suspend_all(chip->pcm);
201 return 0; 200 return 0;
202} 201}
203 202
diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c
index 04368dd59a4c..543945643a76 100644
--- a/sound/drivers/vx/vx_core.c
+++ b/sound/drivers/vx/vx_core.c
@@ -643,10 +643,7 @@ static void vx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *b
643 643
644static void vx_proc_init(struct vx_core *chip) 644static void vx_proc_init(struct vx_core *chip)
645{ 645{
646 struct snd_info_entry *entry; 646 snd_card_ro_proc_new(chip->card, "vx-status", chip, vx_proc_read);
647
648 if (! snd_card_proc_new(chip->card, "vx-status", &entry))
649 snd_info_set_text_ops(entry, chip, vx_proc_read);
650} 647}
651 648
652 649
@@ -732,12 +729,8 @@ EXPORT_SYMBOL(snd_vx_dsp_load);
732 */ 729 */
733int snd_vx_suspend(struct vx_core *chip) 730int snd_vx_suspend(struct vx_core *chip)
734{ 731{
735 unsigned int i;
736
737 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); 732 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
738 chip->chip_status |= VX_STAT_IN_SUSPEND; 733 chip->chip_status |= VX_STAT_IN_SUSPEND;
739 for (i = 0; i < chip->hw->num_codecs; i++)
740 snd_pcm_suspend_all(chip->pcm[i]);
741 734
742 return 0; 735 return 0;
743} 736}
diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
index 052e00590259..b9e96d0b3a0a 100644
--- a/sound/firewire/Kconfig
+++ b/sound/firewire/Kconfig
@@ -163,5 +163,6 @@ config SND_FIREFACE
163 Say Y here to include support for RME fireface series. 163 Say Y here to include support for RME fireface series.
164 * Fireface 400 164 * Fireface 400
165 * Fireface 800 165 * Fireface 800
166 * Fireface UCX
166 167
167endif # SND_FIREWIRE 168endif # SND_FIREWIRE
diff --git a/sound/firewire/bebob/bebob_proc.c b/sound/firewire/bebob/bebob_proc.c
index 8096891af913..05e2a1c6326c 100644
--- a/sound/firewire/bebob/bebob_proc.c
+++ b/sound/firewire/bebob/bebob_proc.c
@@ -163,12 +163,8 @@ add_node(struct snd_bebob *bebob, struct snd_info_entry *root, const char *name,
163 struct snd_info_entry *entry; 163 struct snd_info_entry *entry;
164 164
165 entry = snd_info_create_card_entry(bebob->card, name, root); 165 entry = snd_info_create_card_entry(bebob->card, name, root);
166 if (entry == NULL) 166 if (entry)
167 return; 167 snd_info_set_text_ops(entry, bebob, op);
168
169 snd_info_set_text_ops(entry, bebob, op);
170 if (snd_info_register(entry) < 0)
171 snd_info_free_entry(entry);
172} 168}
173 169
174void snd_bebob_proc_init(struct snd_bebob *bebob) 170void snd_bebob_proc_init(struct snd_bebob *bebob)
@@ -184,10 +180,6 @@ void snd_bebob_proc_init(struct snd_bebob *bebob)
184 if (root == NULL) 180 if (root == NULL)
185 return; 181 return;
186 root->mode = S_IFDIR | 0555; 182 root->mode = S_IFDIR | 0555;
187 if (snd_info_register(root) < 0) {
188 snd_info_free_entry(root);
189 return;
190 }
191 183
192 add_node(bebob, root, "clock", proc_read_clock); 184 add_node(bebob, root, "clock", proc_read_clock);
193 add_node(bebob, root, "firmware", proc_read_hw_info); 185 add_node(bebob, root, "firmware", proc_read_hw_info);
diff --git a/sound/firewire/dice/dice-proc.c b/sound/firewire/dice/dice-proc.c
index bb870fc73f99..9b1d509c6320 100644
--- a/sound/firewire/dice/dice-proc.c
+++ b/sound/firewire/dice/dice-proc.c
@@ -285,12 +285,8 @@ static void add_node(struct snd_dice *dice, struct snd_info_entry *root,
285 struct snd_info_entry *entry; 285 struct snd_info_entry *entry;
286 286
287 entry = snd_info_create_card_entry(dice->card, name, root); 287 entry = snd_info_create_card_entry(dice->card, name, root);
288 if (!entry) 288 if (entry)
289 return; 289 snd_info_set_text_ops(entry, dice, op);
290
291 snd_info_set_text_ops(entry, dice, op);
292 if (snd_info_register(entry) < 0)
293 snd_info_free_entry(entry);
294} 290}
295 291
296void snd_dice_create_proc(struct snd_dice *dice) 292void snd_dice_create_proc(struct snd_dice *dice)
@@ -306,10 +302,6 @@ void snd_dice_create_proc(struct snd_dice *dice)
306 if (!root) 302 if (!root)
307 return; 303 return;
308 root->mode = S_IFDIR | 0555; 304 root->mode = S_IFDIR | 0555;
309 if (snd_info_register(root) < 0) {
310 snd_info_free_entry(root);
311 return;
312 }
313 305
314 add_node(dice, root, "dice", dice_proc_read); 306 add_node(dice, root, "dice", dice_proc_read);
315 add_node(dice, root, "formation", dice_proc_read_formation); 307 add_node(dice, root, "formation", dice_proc_read_formation);
diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
index ed50b222d36e..eee184b05d93 100644
--- a/sound/firewire/dice/dice.c
+++ b/sound/firewire/dice/dice.c
@@ -18,6 +18,7 @@ MODULE_LICENSE("GPL v2");
18#define OUI_ALESIS 0x000595 18#define OUI_ALESIS 0x000595
19#define OUI_MAUDIO 0x000d6c 19#define OUI_MAUDIO 0x000d6c
20#define OUI_MYTEK 0x001ee8 20#define OUI_MYTEK 0x001ee8
21#define OUI_SSL 0x0050c2 // Actually ID reserved by IEEE.
21 22
22#define DICE_CATEGORY_ID 0x04 23#define DICE_CATEGORY_ID 0x04
23#define WEISS_CATEGORY_ID 0x00 24#define WEISS_CATEGORY_ID 0x00
@@ -196,7 +197,7 @@ static int dice_probe(struct fw_unit *unit,
196 struct snd_dice *dice; 197 struct snd_dice *dice;
197 int err; 198 int err;
198 199
199 if (!entry->driver_data) { 200 if (!entry->driver_data && entry->vendor_id != OUI_SSL) {
200 err = check_dice_category(unit); 201 err = check_dice_category(unit);
201 if (err < 0) 202 if (err < 0)
202 return -ENODEV; 203 return -ENODEV;
@@ -361,6 +362,15 @@ static const struct ieee1394_device_id dice_id_table[] = {
361 .model_id = 0x000002, 362 .model_id = 0x000002,
362 .driver_data = (kernel_ulong_t)snd_dice_detect_mytek_formats, 363 .driver_data = (kernel_ulong_t)snd_dice_detect_mytek_formats,
363 }, 364 },
365 // Solid State Logic, Duende Classic and Mini.
366 // NOTE: each field of GUID in config ROM is not compliant to standard
367 // DICE scheme.
368 {
369 .match_flags = IEEE1394_MATCH_VENDOR_ID |
370 IEEE1394_MATCH_MODEL_ID,
371 .vendor_id = OUI_SSL,
372 .model_id = 0x000070,
373 },
364 { 374 {
365 .match_flags = IEEE1394_MATCH_VERSION, 375 .match_flags = IEEE1394_MATCH_VERSION,
366 .version = DICE_INTERFACE, 376 .version = DICE_INTERFACE,
diff --git a/sound/firewire/digi00x/digi00x-proc.c b/sound/firewire/digi00x/digi00x-proc.c
index 6996d5a6ff5f..d22e8675b10f 100644
--- a/sound/firewire/digi00x/digi00x-proc.c
+++ b/sound/firewire/digi00x/digi00x-proc.c
@@ -80,20 +80,8 @@ void snd_dg00x_proc_init(struct snd_dg00x *dg00x)
80 return; 80 return;
81 81
82 root->mode = S_IFDIR | 0555; 82 root->mode = S_IFDIR | 0555;
83 if (snd_info_register(root) < 0) {
84 snd_info_free_entry(root);
85 return;
86 }
87 83
88 entry = snd_info_create_card_entry(dg00x->card, "clock", root); 84 entry = snd_info_create_card_entry(dg00x->card, "clock", root);
89 if (entry == NULL) { 85 if (entry)
90 snd_info_free_entry(root); 86 snd_info_set_text_ops(entry, dg00x, proc_read_clock);
91 return;
92 }
93
94 snd_info_set_text_ops(entry, dg00x, proc_read_clock);
95 if (snd_info_register(entry) < 0) {
96 snd_info_free_entry(entry);
97 snd_info_free_entry(root);
98 }
99} 87}
diff --git a/sound/firewire/fireface/Makefile b/sound/firewire/fireface/Makefile
index 79a7d6d99d72..d64f4e2a1096 100644
--- a/sound/firewire/fireface/Makefile
+++ b/sound/firewire/fireface/Makefile
@@ -1,4 +1,4 @@
1snd-fireface-objs := ff.o ff-transaction.o ff-midi.o ff-proc.o amdtp-ff.o \ 1snd-fireface-objs := ff.o ff-transaction.o ff-midi.o ff-proc.o amdtp-ff.o \
2 ff-stream.o ff-pcm.o ff-hwdep.o ff-protocol-ff400.o \ 2 ff-stream.o ff-pcm.o ff-hwdep.o ff-protocol-former.o \
3 ff-protocol-ff800.o 3 ff-protocol-latter.o
4obj-$(CONFIG_SND_FIREFACE) += snd-fireface.o 4obj-$(CONFIG_SND_FIREFACE) += snd-fireface.o
diff --git a/sound/firewire/fireface/ff-midi.c b/sound/firewire/fireface/ff-midi.c
index 6a49611ee462..5b44e1c4569a 100644
--- a/sound/firewire/fireface/ff-midi.c
+++ b/sound/firewire/fireface/ff-midi.c
@@ -19,7 +19,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
19 struct snd_ff *ff = substream->rmidi->private_data; 19 struct snd_ff *ff = substream->rmidi->private_data;
20 20
21 /* Initialize internal status. */ 21 /* Initialize internal status. */
22 ff->running_status[substream->number] = 0; 22 ff->on_sysex[substream->number] = 0;
23 ff->rx_midi_error[substream->number] = false; 23 ff->rx_midi_error[substream->number] = false;
24 24
25 WRITE_ONCE(ff->rx_midi_substreams[substream->number], substream); 25 WRITE_ONCE(ff->rx_midi_substreams[substream->number], substream);
diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c
index d0bc96b20a65..5adf04b95c04 100644
--- a/sound/firewire/fireface/ff-pcm.c
+++ b/sound/firewire/fireface/ff-pcm.c
@@ -152,7 +152,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
152 if (err < 0) 152 if (err < 0)
153 goto release_lock; 153 goto release_lock;
154 154
155 err = snd_ff_transaction_get_clock(ff, &rate, &src); 155 err = ff->spec->protocol->get_clock(ff, &rate, &src);
156 if (err < 0) 156 if (err < 0)
157 goto release_lock; 157 goto release_lock;
158 158
diff --git a/sound/firewire/fireface/ff-proc.c b/sound/firewire/fireface/ff-proc.c
index a0c550dabe9a..b886b541c94b 100644
--- a/sound/firewire/fireface/ff-proc.c
+++ b/sound/firewire/fireface/ff-proc.c
@@ -8,209 +8,29 @@
8 8
9#include "./ff.h" 9#include "./ff.h"
10 10
11static void proc_dump_clock_config(struct snd_info_entry *entry, 11const char *snd_ff_proc_get_clk_label(enum snd_ff_clock_src src)
12 struct snd_info_buffer *buffer)
13{ 12{
14 struct snd_ff *ff = entry->private_data; 13 static const char *const labels[] = {
15 __le32 reg; 14 "Internal",
16 u32 data; 15 "S/PDIF",
17 unsigned int rate; 16 "ADAT1",
18 const char *src; 17 "ADAT2",
19 int err; 18 "Word",
20 19 "LTC",
21 err = snd_fw_transaction(ff->unit, TCODE_READ_BLOCK_REQUEST, 20 };
22 SND_FF_REG_CLOCK_CONFIG, &reg, sizeof(reg), 0); 21
23 if (err < 0) 22 if (src >= ARRAY_SIZE(labels))
24 return; 23 return NULL;
25 24
26 data = le32_to_cpu(reg); 25 return labels[src];
27
28 snd_iprintf(buffer, "Output S/PDIF format: %s (Emphasis: %s)\n",
29 (data & 0x20) ? "Professional" : "Consumer",
30 (data & 0x40) ? "on" : "off");
31
32 snd_iprintf(buffer, "Optical output interface format: %s\n",
33 ((data >> 8) & 0x01) ? "S/PDIF" : "ADAT");
34
35 snd_iprintf(buffer, "Word output single speed: %s\n",
36 ((data >> 8) & 0x20) ? "on" : "off");
37
38 snd_iprintf(buffer, "S/PDIF input interface: %s\n",
39 ((data >> 8) & 0x02) ? "Optical" : "Coaxial");
40
41 switch ((data >> 1) & 0x03) {
42 case 0x01:
43 rate = 32000;
44 break;
45 case 0x00:
46 rate = 44100;
47 break;
48 case 0x03:
49 rate = 48000;
50 break;
51 case 0x02:
52 default:
53 return;
54 }
55
56 if (data & 0x08)
57 rate *= 2;
58 else if (data & 0x10)
59 rate *= 4;
60
61 snd_iprintf(buffer, "Sampling rate: %d\n", rate);
62
63 if (data & 0x01) {
64 src = "Internal";
65 } else {
66 switch ((data >> 10) & 0x07) {
67 case 0x00:
68 src = "ADAT1";
69 break;
70 case 0x01:
71 src = "ADAT2";
72 break;
73 case 0x03:
74 src = "S/PDIF";
75 break;
76 case 0x04:
77 src = "Word";
78 break;
79 case 0x05:
80 src = "LTC";
81 break;
82 default:
83 return;
84 }
85 }
86
87 snd_iprintf(buffer, "Sync to clock source: %s\n", src);
88} 26}
89 27
90static void proc_dump_sync_status(struct snd_info_entry *entry, 28static void proc_dump_status(struct snd_info_entry *entry,
91 struct snd_info_buffer *buffer) 29 struct snd_info_buffer *buffer)
92{ 30{
93 struct snd_ff *ff = entry->private_data; 31 struct snd_ff *ff = entry->private_data;
94 __le32 reg;
95 u32 data;
96 int err;
97 32
98 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST, 33 ff->spec->protocol->dump_status(ff, buffer);
99 SND_FF_REG_SYNC_STATUS, &reg, sizeof(reg), 0);
100 if (err < 0)
101 return;
102
103 data = le32_to_cpu(reg);
104
105 snd_iprintf(buffer, "External source detection:\n");
106
107 snd_iprintf(buffer, "Word Clock:");
108 if ((data >> 24) & 0x20) {
109 if ((data >> 24) & 0x40)
110 snd_iprintf(buffer, "sync\n");
111 else
112 snd_iprintf(buffer, "lock\n");
113 } else {
114 snd_iprintf(buffer, "none\n");
115 }
116
117 snd_iprintf(buffer, "S/PDIF:");
118 if ((data >> 16) & 0x10) {
119 if ((data >> 16) & 0x04)
120 snd_iprintf(buffer, "sync\n");
121 else
122 snd_iprintf(buffer, "lock\n");
123 } else {
124 snd_iprintf(buffer, "none\n");
125 }
126
127 snd_iprintf(buffer, "ADAT1:");
128 if ((data >> 8) & 0x04) {
129 if ((data >> 8) & 0x10)
130 snd_iprintf(buffer, "sync\n");
131 else
132 snd_iprintf(buffer, "lock\n");
133 } else {
134 snd_iprintf(buffer, "none\n");
135 }
136
137 snd_iprintf(buffer, "ADAT2:");
138 if ((data >> 8) & 0x08) {
139 if ((data >> 8) & 0x20)
140 snd_iprintf(buffer, "sync\n");
141 else
142 snd_iprintf(buffer, "lock\n");
143 } else {
144 snd_iprintf(buffer, "none\n");
145 }
146
147 snd_iprintf(buffer, "\nUsed external source:\n");
148
149 if (((data >> 22) & 0x07) == 0x07) {
150 snd_iprintf(buffer, "None\n");
151 } else {
152 switch ((data >> 22) & 0x07) {
153 case 0x00:
154 snd_iprintf(buffer, "ADAT1:");
155 break;
156 case 0x01:
157 snd_iprintf(buffer, "ADAT2:");
158 break;
159 case 0x03:
160 snd_iprintf(buffer, "S/PDIF:");
161 break;
162 case 0x04:
163 snd_iprintf(buffer, "Word:");
164 break;
165 case 0x07:
166 snd_iprintf(buffer, "Nothing:");
167 break;
168 case 0x02:
169 case 0x05:
170 case 0x06:
171 default:
172 snd_iprintf(buffer, "unknown:");
173 break;
174 }
175
176 if ((data >> 25) & 0x07) {
177 switch ((data >> 25) & 0x07) {
178 case 0x01:
179 snd_iprintf(buffer, "32000\n");
180 break;
181 case 0x02:
182 snd_iprintf(buffer, "44100\n");
183 break;
184 case 0x03:
185 snd_iprintf(buffer, "48000\n");
186 break;
187 case 0x04:
188 snd_iprintf(buffer, "64000\n");
189 break;
190 case 0x05:
191 snd_iprintf(buffer, "88200\n");
192 break;
193 case 0x06:
194 snd_iprintf(buffer, "96000\n");
195 break;
196 case 0x07:
197 snd_iprintf(buffer, "128000\n");
198 break;
199 case 0x08:
200 snd_iprintf(buffer, "176400\n");
201 break;
202 case 0x09:
203 snd_iprintf(buffer, "192000\n");
204 break;
205 case 0x00:
206 snd_iprintf(buffer, "unknown\n");
207 break;
208 }
209 }
210 }
211
212 snd_iprintf(buffer, "Multiplied:");
213 snd_iprintf(buffer, "%d\n", (data & 0x3ff) * 250);
214} 34}
215 35
216static void add_node(struct snd_ff *ff, struct snd_info_entry *root, 36static void add_node(struct snd_ff *ff, struct snd_info_entry *root,
@@ -221,12 +41,8 @@ static void add_node(struct snd_ff *ff, struct snd_info_entry *root,
221 struct snd_info_entry *entry; 41 struct snd_info_entry *entry;
222 42
223 entry = snd_info_create_card_entry(ff->card, name, root); 43 entry = snd_info_create_card_entry(ff->card, name, root);
224 if (entry == NULL) 44 if (entry)
225 return; 45 snd_info_set_text_ops(entry, ff, op);
226
227 snd_info_set_text_ops(entry, ff, op);
228 if (snd_info_register(entry) < 0)
229 snd_info_free_entry(entry);
230} 46}
231 47
232void snd_ff_proc_init(struct snd_ff *ff) 48void snd_ff_proc_init(struct snd_ff *ff)
@@ -242,11 +58,6 @@ void snd_ff_proc_init(struct snd_ff *ff)
242 if (root == NULL) 58 if (root == NULL)
243 return; 59 return;
244 root->mode = S_IFDIR | 0555; 60 root->mode = S_IFDIR | 0555;
245 if (snd_info_register(root) < 0) {
246 snd_info_free_entry(root);
247 return;
248 }
249 61
250 add_node(ff, root, "clock-config", proc_dump_clock_config); 62 add_node(ff, root, "status", proc_dump_status);
251 add_node(ff, root, "sync-status", proc_dump_sync_status);
252} 63}
diff --git a/sound/firewire/fireface/ff-protocol-ff400.c b/sound/firewire/fireface/ff-protocol-ff400.c
deleted file mode 100644
index 2280fab9b3c7..000000000000
--- a/sound/firewire/fireface/ff-protocol-ff400.c
+++ /dev/null
@@ -1,161 +0,0 @@
1/*
2 * ff-protocol-ff400.c - a part of driver for RME Fireface series
3 *
4 * Copyright (c) 2015-2017 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#include <linux/delay.h>
10#include "ff.h"
11
12#define FF400_STF 0x000080100500ull
13#define FF400_RX_PACKET_FORMAT 0x000080100504ull
14#define FF400_ISOC_COMM_START 0x000080100508ull
15#define FF400_TX_PACKET_FORMAT 0x00008010050cull
16#define FF400_ISOC_COMM_STOP 0x000080100510ull
17
18/*
19 * Fireface 400 manages isochronous channel number in 3 bit field. Therefore,
20 * we can allocate between 0 and 7 channel.
21 */
22static int keep_resources(struct snd_ff *ff, unsigned int rate)
23{
24 enum snd_ff_stream_mode mode;
25 int i;
26 int err;
27
28 // Check whether the given value is supported or not.
29 for (i = 0; i < CIP_SFC_COUNT; i++) {
30 if (amdtp_rate_table[i] == rate)
31 break;
32 }
33 if (i >= CIP_SFC_COUNT)
34 return -EINVAL;
35
36 err = snd_ff_stream_get_multiplier_mode(i, &mode);
37 if (err < 0)
38 return err;
39
40 /* Keep resources for in-stream. */
41 ff->tx_resources.channels_mask = 0x00000000000000ffuLL;
42 err = fw_iso_resources_allocate(&ff->tx_resources,
43 amdtp_stream_get_max_payload(&ff->tx_stream),
44 fw_parent_device(ff->unit)->max_speed);
45 if (err < 0)
46 return err;
47
48 /* Keep resources for out-stream. */
49 err = amdtp_ff_set_parameters(&ff->rx_stream, rate,
50 ff->spec->pcm_playback_channels[mode]);
51 if (err < 0)
52 return err;
53 ff->rx_resources.channels_mask = 0x00000000000000ffuLL;
54 err = fw_iso_resources_allocate(&ff->rx_resources,
55 amdtp_stream_get_max_payload(&ff->rx_stream),
56 fw_parent_device(ff->unit)->max_speed);
57 if (err < 0)
58 fw_iso_resources_free(&ff->tx_resources);
59
60 return err;
61}
62
63static int ff400_begin_session(struct snd_ff *ff, unsigned int rate)
64{
65 __le32 reg;
66 int err;
67
68 err = keep_resources(ff, rate);
69 if (err < 0)
70 return err;
71
72 /* Set the number of data blocks transferred in a second. */
73 reg = cpu_to_le32(rate);
74 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
75 FF400_STF, &reg, sizeof(reg), 0);
76 if (err < 0)
77 return err;
78
79 msleep(100);
80
81 /*
82 * Set isochronous channel and the number of quadlets of received
83 * packets.
84 */
85 reg = cpu_to_le32(((ff->rx_stream.data_block_quadlets << 3) << 8) |
86 ff->rx_resources.channel);
87 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
88 FF400_RX_PACKET_FORMAT, &reg, sizeof(reg), 0);
89 if (err < 0)
90 return err;
91
92 /*
93 * Set isochronous channel and the number of quadlets of transmitted
94 * packet.
95 */
96 /* TODO: investigate the purpose of this 0x80. */
97 reg = cpu_to_le32((0x80 << 24) |
98 (ff->tx_resources.channel << 5) |
99 (ff->tx_stream.data_block_quadlets));
100 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
101 FF400_TX_PACKET_FORMAT, &reg, sizeof(reg), 0);
102 if (err < 0)
103 return err;
104
105 /* Allow to transmit packets. */
106 reg = cpu_to_le32(0x00000001);
107 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
108 FF400_ISOC_COMM_START, &reg, sizeof(reg), 0);
109}
110
111static void ff400_finish_session(struct snd_ff *ff)
112{
113 __le32 reg;
114
115 reg = cpu_to_le32(0x80000000);
116 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
117 FF400_ISOC_COMM_STOP, &reg, sizeof(reg), 0);
118}
119
120static void ff400_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length)
121{
122 int i;
123
124 for (i = 0; i < length / 4; i++) {
125 u32 quad = le32_to_cpu(buf[i]);
126 u8 byte;
127 unsigned int index;
128 struct snd_rawmidi_substream *substream;
129
130 /* Message in first port. */
131 /*
132 * This value may represent the index of this unit when the same
133 * units are on the same IEEE 1394 bus. This driver doesn't use
134 * it.
135 */
136 index = (quad >> 8) & 0xff;
137 if (index > 0) {
138 substream = READ_ONCE(ff->tx_midi_substreams[0]);
139 if (substream != NULL) {
140 byte = quad & 0xff;
141 snd_rawmidi_receive(substream, &byte, 1);
142 }
143 }
144
145 /* Message in second port. */
146 index = (quad >> 24) & 0xff;
147 if (index > 0) {
148 substream = READ_ONCE(ff->tx_midi_substreams[1]);
149 if (substream != NULL) {
150 byte = (quad >> 16) & 0xff;
151 snd_rawmidi_receive(substream, &byte, 1);
152 }
153 }
154 }
155}
156
157const struct snd_ff_protocol snd_ff_protocol_ff400 = {
158 .handle_midi_msg = ff400_handle_midi_msg,
159 .begin_session = ff400_begin_session,
160 .finish_session = ff400_finish_session,
161};
diff --git a/sound/firewire/fireface/ff-protocol-ff800.c b/sound/firewire/fireface/ff-protocol-ff800.c
deleted file mode 100644
index 2acbf6039770..000000000000
--- a/sound/firewire/fireface/ff-protocol-ff800.c
+++ /dev/null
@@ -1,143 +0,0 @@
1/*
2 * ff-protocol-ff800.c - a part of driver for RME Fireface series
3 *
4 * Copyright (c) 2018 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#include <linux/delay.h>
10
11#include "ff.h"
12
13#define FF800_STF 0x0000fc88f000
14#define FF800_RX_PACKET_FORMAT 0x0000fc88f004
15#define FF800_ALLOC_TX_STREAM 0x0000fc88f008
16#define FF800_ISOC_COMM_START 0x0000fc88f00c
17#define FF800_TX_S800_FLAG 0x00000800
18#define FF800_ISOC_COMM_STOP 0x0000fc88f010
19
20#define FF800_TX_PACKET_ISOC_CH 0x0000801c0008
21
22static int allocate_rx_resources(struct snd_ff *ff)
23{
24 u32 data;
25 __le32 reg;
26 int err;
27
28 // Controllers should allocate isochronous resources for rx stream.
29 err = fw_iso_resources_allocate(&ff->rx_resources,
30 amdtp_stream_get_max_payload(&ff->rx_stream),
31 fw_parent_device(ff->unit)->max_speed);
32 if (err < 0)
33 return err;
34
35 // Set isochronous channel and the number of quadlets of rx packets.
36 data = ff->rx_stream.data_block_quadlets << 3;
37 data = (data << 8) | ff->rx_resources.channel;
38 reg = cpu_to_le32(data);
39 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
40 FF800_RX_PACKET_FORMAT, &reg, sizeof(reg), 0);
41}
42
43static int allocate_tx_resources(struct snd_ff *ff)
44{
45 __le32 reg;
46 unsigned int count;
47 unsigned int tx_isoc_channel;
48 int err;
49
50 reg = cpu_to_le32(ff->tx_stream.data_block_quadlets);
51 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
52 FF800_ALLOC_TX_STREAM, &reg, sizeof(reg), 0);
53 if (err < 0)
54 return err;
55
56 // Wait till the format of tx packet is available.
57 count = 0;
58 while (count++ < 10) {
59 u32 data;
60 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
61 FF800_TX_PACKET_ISOC_CH, &reg, sizeof(reg), 0);
62 if (err < 0)
63 return err;
64
65 data = le32_to_cpu(reg);
66 if (data != 0xffffffff) {
67 tx_isoc_channel = data;
68 break;
69 }
70
71 msleep(50);
72 }
73 if (count >= 10)
74 return -ETIMEDOUT;
75
76 // NOTE: this is a makeshift to start OHCI 1394 IR context in the
77 // channel. On the other hand, 'struct fw_iso_resources.allocated' is
78 // not true and it's not deallocated at stop.
79 ff->tx_resources.channel = tx_isoc_channel;
80
81 return 0;
82}
83
84static int ff800_begin_session(struct snd_ff *ff, unsigned int rate)
85{
86 __le32 reg;
87 int err;
88
89 reg = cpu_to_le32(rate);
90 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
91 FF800_STF, &reg, sizeof(reg), 0);
92 if (err < 0)
93 return err;
94
95 // If starting isochronous communication immediately, change of STF has
96 // no effect. In this case, the communication runs based on former STF.
97 // Let's sleep for a bit.
98 msleep(100);
99
100 err = allocate_rx_resources(ff);
101 if (err < 0)
102 return err;
103
104 err = allocate_tx_resources(ff);
105 if (err < 0)
106 return err;
107
108 reg = cpu_to_le32(0x80000000);
109 reg |= cpu_to_le32(ff->tx_stream.data_block_quadlets);
110 if (fw_parent_device(ff->unit)->max_speed == SCODE_800)
111 reg |= cpu_to_le32(FF800_TX_S800_FLAG);
112 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
113 FF800_ISOC_COMM_START, &reg, sizeof(reg), 0);
114}
115
116static void ff800_finish_session(struct snd_ff *ff)
117{
118 __le32 reg;
119
120 reg = cpu_to_le32(0x80000000);
121 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
122 FF800_ISOC_COMM_STOP, &reg, sizeof(reg), 0);
123}
124
125static void ff800_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length)
126{
127 int i;
128
129 for (i = 0; i < length / 4; i++) {
130 u8 byte = le32_to_cpu(buf[i]) & 0xff;
131 struct snd_rawmidi_substream *substream;
132
133 substream = READ_ONCE(ff->tx_midi_substreams[0]);
134 if (substream)
135 snd_rawmidi_receive(substream, &byte, 1);
136 }
137}
138
139const struct snd_ff_protocol snd_ff_protocol_ff800 = {
140 .handle_midi_msg = ff800_handle_midi_msg,
141 .begin_session = ff800_begin_session,
142 .finish_session = ff800_finish_session,
143};
diff --git a/sound/firewire/fireface/ff-protocol-former.c b/sound/firewire/fireface/ff-protocol-former.c
new file mode 100644
index 000000000000..8d1c2c6e907b
--- /dev/null
+++ b/sound/firewire/fireface/ff-protocol-former.c
@@ -0,0 +1,597 @@
1// SPDX-License-Identifier: GPL-2.0
2// ff-protocol-former.c - a part of driver for RME Fireface series
3//
4// Copyright (c) 2019 Takashi Sakamoto
5//
6// Licensed under the terms of the GNU General Public License, version 2.
7
8#include <linux/delay.h>
9
10#include "ff.h"
11
12#define FORMER_REG_SYNC_STATUS 0x0000801c0000ull
13/* For block write request. */
14#define FORMER_REG_FETCH_PCM_FRAMES 0x0000801c0000ull
15#define FORMER_REG_CLOCK_CONFIG 0x0000801c0004ull
16
17static int parse_clock_bits(u32 data, unsigned int *rate,
18 enum snd_ff_clock_src *src)
19{
20 static const struct {
21 unsigned int rate;
22 u32 mask;
23 } *rate_entry, rate_entries[] = {
24 { 32000, 0x00000002, },
25 { 44100, 0x00000000, },
26 { 48000, 0x00000006, },
27 { 64000, 0x0000000a, },
28 { 88200, 0x00000008, },
29 { 96000, 0x0000000e, },
30 { 128000, 0x00000012, },
31 { 176400, 0x00000010, },
32 { 192000, 0x00000016, },
33 };
34 static const struct {
35 enum snd_ff_clock_src src;
36 u32 mask;
37 } *clk_entry, clk_entries[] = {
38 { SND_FF_CLOCK_SRC_ADAT1, 0x00000000, },
39 { SND_FF_CLOCK_SRC_ADAT2, 0x00000400, },
40 { SND_FF_CLOCK_SRC_SPDIF, 0x00000c00, },
41 { SND_FF_CLOCK_SRC_WORD, 0x00001000, },
42 { SND_FF_CLOCK_SRC_LTC, 0x00001800, },
43 };
44 int i;
45
46 for (i = 0; i < ARRAY_SIZE(rate_entries); ++i) {
47 rate_entry = rate_entries + i;
48 if ((data & 0x0000001e) == rate_entry->mask) {
49 *rate = rate_entry->rate;
50 break;
51 }
52 }
53 if (i == ARRAY_SIZE(rate_entries))
54 return -EIO;
55
56 if (data & 0x00000001) {
57 *src = SND_FF_CLOCK_SRC_INTERNAL;
58 } else {
59 for (i = 0; i < ARRAY_SIZE(clk_entries); ++i) {
60 clk_entry = clk_entries + i;
61 if ((data & 0x00001c00) == clk_entry->mask) {
62 *src = clk_entry->src;
63 break;
64 }
65 }
66 if (i == ARRAY_SIZE(clk_entries))
67 return -EIO;
68 }
69
70 return 0;
71}
72
73static int former_get_clock(struct snd_ff *ff, unsigned int *rate,
74 enum snd_ff_clock_src *src)
75{
76 __le32 reg;
77 u32 data;
78 int err;
79
80 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
81 FORMER_REG_CLOCK_CONFIG, &reg, sizeof(reg), 0);
82 if (err < 0)
83 return err;
84 data = le32_to_cpu(reg);
85
86 return parse_clock_bits(data, rate, src);
87}
88
89static int former_switch_fetching_mode(struct snd_ff *ff, bool enable)
90{
91 unsigned int count;
92 __le32 *reg;
93 int i;
94 int err;
95
96 count = 0;
97 for (i = 0; i < SND_FF_STREAM_MODE_COUNT; ++i)
98 count = max(count, ff->spec->pcm_playback_channels[i]);
99
100 reg = kcalloc(count, sizeof(__le32), GFP_KERNEL);
101 if (!reg)
102 return -ENOMEM;
103
104 if (!enable) {
105 /*
106 * Each quadlet is corresponding to data channels in a data
107 * blocks in reverse order. Precisely, quadlets for available
108 * data channels should be enabled. Here, I take second best
109 * to fetch PCM frames from all of data channels regardless of
110 * stf.
111 */
112 for (i = 0; i < count; ++i)
113 reg[i] = cpu_to_le32(0x00000001);
114 }
115
116 err = snd_fw_transaction(ff->unit, TCODE_WRITE_BLOCK_REQUEST,
117 FORMER_REG_FETCH_PCM_FRAMES, reg,
118 sizeof(__le32) * count, 0);
119 kfree(reg);
120 return err;
121}
122
123static void dump_clock_config(struct snd_ff *ff, struct snd_info_buffer *buffer)
124{
125 __le32 reg;
126 u32 data;
127 unsigned int rate;
128 enum snd_ff_clock_src src;
129 const char *label;
130 int err;
131
132 err = snd_fw_transaction(ff->unit, TCODE_READ_BLOCK_REQUEST,
133 FORMER_REG_CLOCK_CONFIG, &reg, sizeof(reg), 0);
134 if (err < 0)
135 return;
136 data = le32_to_cpu(reg);
137
138 snd_iprintf(buffer, "Output S/PDIF format: %s (Emphasis: %s)\n",
139 (data & 0x00000020) ? "Professional" : "Consumer",
140 (data & 0x00000040) ? "on" : "off");
141
142 snd_iprintf(buffer, "Optical output interface format: %s\n",
143 (data & 0x00000100) ? "S/PDIF" : "ADAT");
144
145 snd_iprintf(buffer, "Word output single speed: %s\n",
146 (data & 0x00002000) ? "on" : "off");
147
148 snd_iprintf(buffer, "S/PDIF input interface: %s\n",
149 (data & 0x00000200) ? "Optical" : "Coaxial");
150
151 err = parse_clock_bits(data, &rate, &src);
152 if (err < 0)
153 return;
154 label = snd_ff_proc_get_clk_label(src);
155 if (!label)
156 return;
157
158 snd_iprintf(buffer, "Clock configuration: %d %s\n", rate, label);
159}
160
161static void dump_sync_status(struct snd_ff *ff, struct snd_info_buffer *buffer)
162{
163 static const struct {
164 char *const label;
165 u32 locked_mask;
166 u32 synced_mask;
167 } *clk_entry, clk_entries[] = {
168 { "WDClk", 0x40000000, 0x20000000, },
169 { "S/PDIF", 0x00080000, 0x00040000, },
170 { "ADAT1", 0x00000400, 0x00001000, },
171 { "ADAT2", 0x00000800, 0x00002000, },
172 };
173 static const struct {
174 char *const label;
175 u32 mask;
176 } *referred_entry, referred_entries[] = {
177 { "ADAT1", 0x00000000, },
178 { "ADAT2", 0x00400000, },
179 { "S/PDIF", 0x00c00000, },
180 { "WDclk", 0x01000000, },
181 { "TCO", 0x01400000, },
182 };
183 static const struct {
184 unsigned int rate;
185 u32 mask;
186 } *rate_entry, rate_entries[] = {
187 { 32000, 0x02000000, },
188 { 44100, 0x04000000, },
189 { 48000, 0x06000000, },
190 { 64000, 0x08000000, },
191 { 88200, 0x0a000000, },
192 { 96000, 0x0c000000, },
193 { 128000, 0x0e000000, },
194 { 176400, 0x10000000, },
195 { 192000, 0x12000000, },
196 };
197 __le32 reg[2];
198 u32 data[2];
199 int i;
200 int err;
201
202 err = snd_fw_transaction(ff->unit, TCODE_READ_BLOCK_REQUEST,
203 FORMER_REG_SYNC_STATUS, reg, sizeof(reg), 0);
204 if (err < 0)
205 return;
206 data[0] = le32_to_cpu(reg[0]);
207 data[1] = le32_to_cpu(reg[1]);
208
209 snd_iprintf(buffer, "External source detection:\n");
210
211 for (i = 0; i < ARRAY_SIZE(clk_entries); ++i) {
212 const char *state;
213
214 clk_entry = clk_entries + i;
215 if (data[0] & clk_entry->locked_mask) {
216 if (data[0] & clk_entry->synced_mask)
217 state = "sync";
218 else
219 state = "lock";
220 } else {
221 state = "none";
222 }
223
224 snd_iprintf(buffer, "%s: %s\n", clk_entry->label, state);
225 }
226
227 snd_iprintf(buffer, "Referred clock:\n");
228
229 if (data[1] & 0x00000001) {
230 snd_iprintf(buffer, "Internal\n");
231 } else {
232 unsigned int rate;
233 const char *label;
234
235 for (i = 0; i < ARRAY_SIZE(referred_entries); ++i) {
236 referred_entry = referred_entries + i;
237 if ((data[0] & 0x1e0000) == referred_entry->mask) {
238 label = referred_entry->label;
239 break;
240 }
241 }
242 if (i == ARRAY_SIZE(referred_entries))
243 label = "none";
244
245 for (i = 0; i < ARRAY_SIZE(rate_entries); ++i) {
246 rate_entry = rate_entries + i;
247 if ((data[0] & 0x1e000000) == rate_entry->mask) {
248 rate = rate_entry->rate;
249 break;
250 }
251 }
252 if (i == ARRAY_SIZE(rate_entries))
253 rate = 0;
254
255 snd_iprintf(buffer, "%s %d\n", label, rate);
256 }
257}
258
259static void former_dump_status(struct snd_ff *ff,
260 struct snd_info_buffer *buffer)
261{
262 dump_clock_config(ff, buffer);
263 dump_sync_status(ff, buffer);
264}
265
266static int former_fill_midi_msg(struct snd_ff *ff,
267 struct snd_rawmidi_substream *substream,
268 unsigned int port)
269{
270 u8 *buf = (u8 *)ff->msg_buf[port];
271 int len;
272 int i;
273
274 len = snd_rawmidi_transmit_peek(substream, buf,
275 SND_FF_MAXIMIM_MIDI_QUADS);
276 if (len <= 0)
277 return len;
278
279 // One quadlet includes one byte.
280 for (i = len - 1; i >= 0; --i)
281 ff->msg_buf[port][i] = cpu_to_le32(buf[i]);
282 ff->rx_bytes[port] = len;
283
284 return len;
285}
286
287#define FF800_STF 0x0000fc88f000
288#define FF800_RX_PACKET_FORMAT 0x0000fc88f004
289#define FF800_ALLOC_TX_STREAM 0x0000fc88f008
290#define FF800_ISOC_COMM_START 0x0000fc88f00c
291#define FF800_TX_S800_FLAG 0x00000800
292#define FF800_ISOC_COMM_STOP 0x0000fc88f010
293
294#define FF800_TX_PACKET_ISOC_CH 0x0000801c0008
295
296static int allocate_rx_resources(struct snd_ff *ff)
297{
298 u32 data;
299 __le32 reg;
300 int err;
301
302 // Controllers should allocate isochronous resources for rx stream.
303 err = fw_iso_resources_allocate(&ff->rx_resources,
304 amdtp_stream_get_max_payload(&ff->rx_stream),
305 fw_parent_device(ff->unit)->max_speed);
306 if (err < 0)
307 return err;
308
309 // Set isochronous channel and the number of quadlets of rx packets.
310 data = ff->rx_stream.data_block_quadlets << 3;
311 data = (data << 8) | ff->rx_resources.channel;
312 reg = cpu_to_le32(data);
313 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
314 FF800_RX_PACKET_FORMAT, &reg, sizeof(reg), 0);
315}
316
317static int allocate_tx_resources(struct snd_ff *ff)
318{
319 __le32 reg;
320 unsigned int count;
321 unsigned int tx_isoc_channel;
322 int err;
323
324 reg = cpu_to_le32(ff->tx_stream.data_block_quadlets);
325 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
326 FF800_ALLOC_TX_STREAM, &reg, sizeof(reg), 0);
327 if (err < 0)
328 return err;
329
330 // Wait till the format of tx packet is available.
331 count = 0;
332 while (count++ < 10) {
333 u32 data;
334 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
335 FF800_TX_PACKET_ISOC_CH, &reg, sizeof(reg), 0);
336 if (err < 0)
337 return err;
338
339 data = le32_to_cpu(reg);
340 if (data != 0xffffffff) {
341 tx_isoc_channel = data;
342 break;
343 }
344
345 msleep(50);
346 }
347 if (count >= 10)
348 return -ETIMEDOUT;
349
350 // NOTE: this is a makeshift to start OHCI 1394 IR context in the
351 // channel. On the other hand, 'struct fw_iso_resources.allocated' is
352 // not true and it's not deallocated at stop.
353 ff->tx_resources.channel = tx_isoc_channel;
354
355 return 0;
356}
357
358static int ff800_begin_session(struct snd_ff *ff, unsigned int rate)
359{
360 __le32 reg;
361 int err;
362
363 reg = cpu_to_le32(rate);
364 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
365 FF800_STF, &reg, sizeof(reg), 0);
366 if (err < 0)
367 return err;
368
369 // If starting isochronous communication immediately, change of STF has
370 // no effect. In this case, the communication runs based on former STF.
371 // Let's sleep for a bit.
372 msleep(100);
373
374 err = allocate_rx_resources(ff);
375 if (err < 0)
376 return err;
377
378 err = allocate_tx_resources(ff);
379 if (err < 0)
380 return err;
381
382 reg = cpu_to_le32(0x80000000);
383 reg |= cpu_to_le32(ff->tx_stream.data_block_quadlets);
384 if (fw_parent_device(ff->unit)->max_speed == SCODE_800)
385 reg |= cpu_to_le32(FF800_TX_S800_FLAG);
386 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
387 FF800_ISOC_COMM_START, &reg, sizeof(reg), 0);
388}
389
390static void ff800_finish_session(struct snd_ff *ff)
391{
392 __le32 reg;
393
394 reg = cpu_to_le32(0x80000000);
395 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
396 FF800_ISOC_COMM_STOP, &reg, sizeof(reg), 0);
397}
398
399// Fireface 800 doesn't allow drivers to register lower 4 bytes of destination
400// address.
401// A write transaction to clear registered higher 4 bytes of destination address
402// has an effect to suppress asynchronous transaction from device.
403static void ff800_handle_midi_msg(struct snd_ff *ff, unsigned int offset,
404 __le32 *buf, size_t length)
405{
406 int i;
407
408 for (i = 0; i < length / 4; i++) {
409 u8 byte = le32_to_cpu(buf[i]) & 0xff;
410 struct snd_rawmidi_substream *substream;
411
412 substream = READ_ONCE(ff->tx_midi_substreams[0]);
413 if (substream)
414 snd_rawmidi_receive(substream, &byte, 1);
415 }
416}
417
418const struct snd_ff_protocol snd_ff_protocol_ff800 = {
419 .handle_midi_msg = ff800_handle_midi_msg,
420 .fill_midi_msg = former_fill_midi_msg,
421 .get_clock = former_get_clock,
422 .switch_fetching_mode = former_switch_fetching_mode,
423 .begin_session = ff800_begin_session,
424 .finish_session = ff800_finish_session,
425 .dump_status = former_dump_status,
426};
427
428#define FF400_STF 0x000080100500ull
429#define FF400_RX_PACKET_FORMAT 0x000080100504ull
430#define FF400_ISOC_COMM_START 0x000080100508ull
431#define FF400_TX_PACKET_FORMAT 0x00008010050cull
432#define FF400_ISOC_COMM_STOP 0x000080100510ull
433
434/*
435 * Fireface 400 manages isochronous channel number in 3 bit field. Therefore,
436 * we can allocate between 0 and 7 channel.
437 */
438static int keep_resources(struct snd_ff *ff, unsigned int rate)
439{
440 enum snd_ff_stream_mode mode;
441 int i;
442 int err;
443
444 // Check whether the given value is supported or not.
445 for (i = 0; i < CIP_SFC_COUNT; i++) {
446 if (amdtp_rate_table[i] == rate)
447 break;
448 }
449 if (i >= CIP_SFC_COUNT)
450 return -EINVAL;
451
452 err = snd_ff_stream_get_multiplier_mode(i, &mode);
453 if (err < 0)
454 return err;
455
456 /* Keep resources for in-stream. */
457 ff->tx_resources.channels_mask = 0x00000000000000ffuLL;
458 err = fw_iso_resources_allocate(&ff->tx_resources,
459 amdtp_stream_get_max_payload(&ff->tx_stream),
460 fw_parent_device(ff->unit)->max_speed);
461 if (err < 0)
462 return err;
463
464 /* Keep resources for out-stream. */
465 ff->rx_resources.channels_mask = 0x00000000000000ffuLL;
466 err = fw_iso_resources_allocate(&ff->rx_resources,
467 amdtp_stream_get_max_payload(&ff->rx_stream),
468 fw_parent_device(ff->unit)->max_speed);
469 if (err < 0)
470 fw_iso_resources_free(&ff->tx_resources);
471
472 return err;
473}
474
475static int ff400_begin_session(struct snd_ff *ff, unsigned int rate)
476{
477 __le32 reg;
478 int err;
479
480 err = keep_resources(ff, rate);
481 if (err < 0)
482 return err;
483
484 /* Set the number of data blocks transferred in a second. */
485 reg = cpu_to_le32(rate);
486 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
487 FF400_STF, &reg, sizeof(reg), 0);
488 if (err < 0)
489 return err;
490
491 msleep(100);
492
493 /*
494 * Set isochronous channel and the number of quadlets of received
495 * packets.
496 */
497 reg = cpu_to_le32(((ff->rx_stream.data_block_quadlets << 3) << 8) |
498 ff->rx_resources.channel);
499 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
500 FF400_RX_PACKET_FORMAT, &reg, sizeof(reg), 0);
501 if (err < 0)
502 return err;
503
504 /*
505 * Set isochronous channel and the number of quadlets of transmitted
506 * packet.
507 */
508 /* TODO: investigate the purpose of this 0x80. */
509 reg = cpu_to_le32((0x80 << 24) |
510 (ff->tx_resources.channel << 5) |
511 (ff->tx_stream.data_block_quadlets));
512 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
513 FF400_TX_PACKET_FORMAT, &reg, sizeof(reg), 0);
514 if (err < 0)
515 return err;
516
517 /* Allow to transmit packets. */
518 reg = cpu_to_le32(0x00000001);
519 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
520 FF400_ISOC_COMM_START, &reg, sizeof(reg), 0);
521}
522
523static void ff400_finish_session(struct snd_ff *ff)
524{
525 __le32 reg;
526
527 reg = cpu_to_le32(0x80000000);
528 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
529 FF400_ISOC_COMM_STOP, &reg, sizeof(reg), 0);
530}
531
532// For Fireface 400, lower 4 bytes of destination address is configured by bit
533// flag in quadlet register (little endian) at 0x'0000'801'0051c. Drivers can
534// select one of 4 options:
535//
536// bit flags: offset of destination address
537// - 0x04000000: 0x'....'....'0000'0000
538// - 0x08000000: 0x'....'....'0000'0080
539// - 0x10000000: 0x'....'....'0000'0100
540// - 0x20000000: 0x'....'....'0000'0180
541//
542// Drivers can suppress the device to transfer asynchronous transactions by
543// using below 2 bits.
544// - 0x01000000: suppress transmission
545// - 0x02000000: suppress transmission
546//
547// Actually, the register is write-only and includes the other options such as
548// input attenuation. This driver allocates destination address with '0000'0000
549// in its lower offset and expects userspace application to configure the
550// register for it.
551static void ff400_handle_midi_msg(struct snd_ff *ff, unsigned int offset,
552 __le32 *buf, size_t length)
553{
554 int i;
555
556 for (i = 0; i < length / 4; i++) {
557 u32 quad = le32_to_cpu(buf[i]);
558 u8 byte;
559 unsigned int index;
560 struct snd_rawmidi_substream *substream;
561
562 /* Message in first port. */
563 /*
564 * This value may represent the index of this unit when the same
565 * units are on the same IEEE 1394 bus. This driver doesn't use
566 * it.
567 */
568 index = (quad >> 8) & 0xff;
569 if (index > 0) {
570 substream = READ_ONCE(ff->tx_midi_substreams[0]);
571 if (substream != NULL) {
572 byte = quad & 0xff;
573 snd_rawmidi_receive(substream, &byte, 1);
574 }
575 }
576
577 /* Message in second port. */
578 index = (quad >> 24) & 0xff;
579 if (index > 0) {
580 substream = READ_ONCE(ff->tx_midi_substreams[1]);
581 if (substream != NULL) {
582 byte = (quad >> 16) & 0xff;
583 snd_rawmidi_receive(substream, &byte, 1);
584 }
585 }
586 }
587}
588
589const struct snd_ff_protocol snd_ff_protocol_ff400 = {
590 .handle_midi_msg = ff400_handle_midi_msg,
591 .fill_midi_msg = former_fill_midi_msg,
592 .get_clock = former_get_clock,
593 .switch_fetching_mode = former_switch_fetching_mode,
594 .begin_session = ff400_begin_session,
595 .finish_session = ff400_finish_session,
596 .dump_status = former_dump_status,
597};
diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c
new file mode 100644
index 000000000000..c8236ff89b7f
--- /dev/null
+++ b/sound/firewire/fireface/ff-protocol-latter.c
@@ -0,0 +1,430 @@
1// SPDX-License-Identifier: GPL-2.0
2// ff-protocol-latter - a part of driver for RME Fireface series
3//
4// Copyright (c) 2019 Takashi Sakamoto
5//
6// Licensed under the terms of the GNU General Public License, version 2.
7
8#include <linux/delay.h>
9
10#include "ff.h"
11
12#define LATTER_STF 0xffff00000004
13#define LATTER_ISOC_CHANNELS 0xffff00000008
14#define LATTER_ISOC_START 0xffff0000000c
15#define LATTER_FETCH_MODE 0xffff00000010
16#define LATTER_SYNC_STATUS 0x0000801c0000
17
18static int parse_clock_bits(u32 data, unsigned int *rate,
19 enum snd_ff_clock_src *src)
20{
21 static const struct {
22 unsigned int rate;
23 u32 flag;
24 } *rate_entry, rate_entries[] = {
25 { 32000, 0x00000000, },
26 { 44100, 0x01000000, },
27 { 48000, 0x02000000, },
28 { 64000, 0x04000000, },
29 { 88200, 0x05000000, },
30 { 96000, 0x06000000, },
31 { 128000, 0x08000000, },
32 { 176400, 0x09000000, },
33 { 192000, 0x0a000000, },
34 };
35 static const struct {
36 enum snd_ff_clock_src src;
37 u32 flag;
38 } *clk_entry, clk_entries[] = {
39 { SND_FF_CLOCK_SRC_SPDIF, 0x00000200, },
40 { SND_FF_CLOCK_SRC_ADAT1, 0x00000400, },
41 { SND_FF_CLOCK_SRC_WORD, 0x00000600, },
42 { SND_FF_CLOCK_SRC_INTERNAL, 0x00000e00, },
43 };
44 int i;
45
46 for (i = 0; i < ARRAY_SIZE(rate_entries); ++i) {
47 rate_entry = rate_entries + i;
48 if ((data & 0x0f000000) == rate_entry->flag) {
49 *rate = rate_entry->rate;
50 break;
51 }
52 }
53 if (i == ARRAY_SIZE(rate_entries))
54 return -EIO;
55
56 for (i = 0; i < ARRAY_SIZE(clk_entries); ++i) {
57 clk_entry = clk_entries + i;
58 if ((data & 0x000e00) == clk_entry->flag) {
59 *src = clk_entry->src;
60 break;
61 }
62 }
63 if (i == ARRAY_SIZE(clk_entries))
64 return -EIO;
65
66 return 0;
67}
68
69static int latter_get_clock(struct snd_ff *ff, unsigned int *rate,
70 enum snd_ff_clock_src *src)
71{
72 __le32 reg;
73 u32 data;
74 int err;
75
76 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
77 LATTER_SYNC_STATUS, &reg, sizeof(reg), 0);
78 if (err < 0)
79 return err;
80 data = le32_to_cpu(reg);
81
82 return parse_clock_bits(data, rate, src);
83}
84
85static int latter_switch_fetching_mode(struct snd_ff *ff, bool enable)
86{
87 u32 data;
88 __le32 reg;
89
90 if (enable)
91 data = 0x00000000;
92 else
93 data = 0xffffffff;
94 reg = cpu_to_le32(data);
95
96 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
97 LATTER_FETCH_MODE, &reg, sizeof(reg), 0);
98}
99
100static int keep_resources(struct snd_ff *ff, unsigned int rate)
101{
102 enum snd_ff_stream_mode mode;
103 int i;
104 int err;
105
106 // Check whether the given value is supported or not.
107 for (i = 0; i < CIP_SFC_COUNT; i++) {
108 if (amdtp_rate_table[i] == rate)
109 break;
110 }
111 if (i >= CIP_SFC_COUNT)
112 return -EINVAL;
113
114 err = snd_ff_stream_get_multiplier_mode(i, &mode);
115 if (err < 0)
116 return err;
117
118 /* Keep resources for in-stream. */
119 ff->tx_resources.channels_mask = 0x00000000000000ffuLL;
120 err = fw_iso_resources_allocate(&ff->tx_resources,
121 amdtp_stream_get_max_payload(&ff->tx_stream),
122 fw_parent_device(ff->unit)->max_speed);
123 if (err < 0)
124 return err;
125
126 /* Keep resources for out-stream. */
127 ff->rx_resources.channels_mask = 0x00000000000000ffuLL;
128 err = fw_iso_resources_allocate(&ff->rx_resources,
129 amdtp_stream_get_max_payload(&ff->rx_stream),
130 fw_parent_device(ff->unit)->max_speed);
131 if (err < 0)
132 fw_iso_resources_free(&ff->tx_resources);
133
134 return err;
135}
136
137static int latter_begin_session(struct snd_ff *ff, unsigned int rate)
138{
139 static const struct {
140 unsigned int stf;
141 unsigned int code;
142 unsigned int flag;
143 } *entry, rate_table[] = {
144 { 32000, 0x00, 0x92, },
145 { 44100, 0x02, 0x92, },
146 { 48000, 0x04, 0x92, },
147 { 64000, 0x08, 0x8e, },
148 { 88200, 0x0a, 0x8e, },
149 { 96000, 0x0c, 0x8e, },
150 { 128000, 0x10, 0x8c, },
151 { 176400, 0x12, 0x8c, },
152 { 192000, 0x14, 0x8c, },
153 };
154 u32 data;
155 __le32 reg;
156 unsigned int count;
157 int i;
158 int err;
159
160 for (i = 0; i < ARRAY_SIZE(rate_table); ++i) {
161 entry = rate_table + i;
162 if (entry->stf == rate)
163 break;
164 }
165 if (i == ARRAY_SIZE(rate_table))
166 return -EINVAL;
167
168 reg = cpu_to_le32(entry->code);
169 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
170 LATTER_STF, &reg, sizeof(reg), 0);
171 if (err < 0)
172 return err;
173
174 // Confirm to shift transmission clock.
175 count = 0;
176 while (count++ < 10) {
177 unsigned int curr_rate;
178 enum snd_ff_clock_src src;
179
180 err = latter_get_clock(ff, &curr_rate, &src);
181 if (err < 0)
182 return err;
183
184 if (curr_rate == rate)
185 break;
186 }
187 if (count == 10)
188 return -ETIMEDOUT;
189
190 err = keep_resources(ff, rate);
191 if (err < 0)
192 return err;
193
194 data = (ff->tx_resources.channel << 8) | ff->rx_resources.channel;
195 reg = cpu_to_le32(data);
196 err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
197 LATTER_ISOC_CHANNELS, &reg, sizeof(reg), 0);
198 if (err < 0)
199 return err;
200
201 // Always use the maximum number of data channels in data block of
202 // packet.
203 reg = cpu_to_le32(entry->flag);
204 return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
205 LATTER_ISOC_START, &reg, sizeof(reg), 0);
206}
207
208static void latter_finish_session(struct snd_ff *ff)
209{
210 __le32 reg;
211
212 reg = cpu_to_le32(0x00000000);
213 snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
214 LATTER_ISOC_START, &reg, sizeof(reg), 0);
215}
216
217static void latter_dump_status(struct snd_ff *ff, struct snd_info_buffer *buffer)
218{
219 static const struct {
220 char *const label;
221 u32 locked_mask;
222 u32 synced_mask;
223 } *clk_entry, clk_entries[] = {
224 { "S/PDIF", 0x00000001, 0x00000010, },
225 { "ADAT", 0x00000002, 0x00000020, },
226 { "WDClk", 0x00000004, 0x00000040, },
227 };
228 __le32 reg;
229 u32 data;
230 unsigned int rate;
231 enum snd_ff_clock_src src;
232 const char *label;
233 int i;
234 int err;
235
236 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
237 LATTER_SYNC_STATUS, &reg, sizeof(reg), 0);
238 if (err < 0)
239 return;
240 data = le32_to_cpu(reg);
241
242 snd_iprintf(buffer, "External source detection:\n");
243
244 for (i = 0; i < ARRAY_SIZE(clk_entries); ++i) {
245 clk_entry = clk_entries + i;
246 snd_iprintf(buffer, "%s: ", clk_entry->label);
247 if (data & clk_entry->locked_mask) {
248 if (data & clk_entry->synced_mask)
249 snd_iprintf(buffer, "sync\n");
250 else
251 snd_iprintf(buffer, "lock\n");
252 } else {
253 snd_iprintf(buffer, "none\n");
254 }
255 }
256
257 err = parse_clock_bits(data, &rate, &src);
258 if (err < 0)
259 return;
260 label = snd_ff_proc_get_clk_label(src);
261 if (!label)
262 return;
263
264 snd_iprintf(buffer, "Referred clock: %s %d\n", label, rate);
265}
266
267// NOTE: transactions are transferred within 0x00-0x7f in allocated range of
268// address. This seems to be for check of discontinuity in receiver side.
269//
270// Like Fireface 400, drivers can select one of 4 options for lower 4 bytes of
271// destination address by bit flags in quadlet register (little endian) at
272// 0x'ffff'0000'0014:
273//
274// bit flags: offset of destination address
275// - 0x00002000: 0x'....'....'0000'0000
276// - 0x00004000: 0x'....'....'0000'0080
277// - 0x00008000: 0x'....'....'0000'0100
278// - 0x00010000: 0x'....'....'0000'0180
279//
280// Drivers can suppress the device to transfer asynchronous transactions by
281// clear these bit flags.
282//
283// Actually, the register is write-only and includes the other settings such as
284// input attenuation. This driver allocates for the first option
285// (0x'....'....'0000'0000) and expects userspace application to configure the
286// register for it.
287static void latter_handle_midi_msg(struct snd_ff *ff, unsigned int offset,
288 __le32 *buf, size_t length)
289{
290 u32 data = le32_to_cpu(*buf);
291 unsigned int index = (data & 0x000000f0) >> 4;
292 u8 byte[3];
293 struct snd_rawmidi_substream *substream;
294 unsigned int len;
295
296 if (index >= ff->spec->midi_in_ports)
297 return;
298
299 switch (data & 0x0000000f) {
300 case 0x00000008:
301 case 0x00000009:
302 case 0x0000000a:
303 case 0x0000000b:
304 case 0x0000000e:
305 len = 3;
306 break;
307 case 0x0000000c:
308 case 0x0000000d:
309 len = 2;
310 break;
311 default:
312 len = data & 0x00000003;
313 if (len == 0)
314 len = 3;
315 break;
316 }
317
318 byte[0] = (data & 0x0000ff00) >> 8;
319 byte[1] = (data & 0x00ff0000) >> 16;
320 byte[2] = (data & 0xff000000) >> 24;
321
322 substream = READ_ONCE(ff->tx_midi_substreams[index]);
323 if (substream)
324 snd_rawmidi_receive(substream, byte, len);
325}
326
327/*
328 * When return minus value, given argument is not MIDI status.
329 * When return 0, given argument is a beginning of system exclusive.
330 * When return the others, given argument is MIDI data.
331 */
332static inline int calculate_message_bytes(u8 status)
333{
334 switch (status) {
335 case 0xf6: /* Tune request. */
336 case 0xf8: /* Timing clock. */
337 case 0xfa: /* Start. */
338 case 0xfb: /* Continue. */
339 case 0xfc: /* Stop. */
340 case 0xfe: /* Active sensing. */
341 case 0xff: /* System reset. */
342 return 1;
343 case 0xf1: /* MIDI time code quarter frame. */
344 case 0xf3: /* Song select. */
345 return 2;
346 case 0xf2: /* Song position pointer. */
347 return 3;
348 case 0xf0: /* Exclusive. */
349 return 0;
350 case 0xf7: /* End of exclusive. */
351 break;
352 case 0xf4: /* Undefined. */
353 case 0xf5: /* Undefined. */
354 case 0xf9: /* Undefined. */
355 case 0xfd: /* Undefined. */
356 break;
357 default:
358 switch (status & 0xf0) {
359 case 0x80: /* Note on. */
360 case 0x90: /* Note off. */
361 case 0xa0: /* Polyphonic key pressure. */
362 case 0xb0: /* Control change and Mode change. */
363 case 0xe0: /* Pitch bend change. */
364 return 3;
365 case 0xc0: /* Program change. */
366 case 0xd0: /* Channel pressure. */
367 return 2;
368 default:
369 break;
370 }
371 break;
372 }
373
374 return -EINVAL;
375}
376
377static int latter_fill_midi_msg(struct snd_ff *ff,
378 struct snd_rawmidi_substream *substream,
379 unsigned int port)
380{
381 u32 data = {0};
382 u8 *buf = (u8 *)&data;
383 int consumed;
384
385 buf[0] = port << 4;
386 consumed = snd_rawmidi_transmit_peek(substream, buf + 1, 3);
387 if (consumed <= 0)
388 return consumed;
389
390 if (!ff->on_sysex[port]) {
391 if (buf[1] != 0xf0) {
392 if (consumed < calculate_message_bytes(buf[1]))
393 return 0;
394 } else {
395 // The beginning of exclusives.
396 ff->on_sysex[port] = true;
397 }
398
399 buf[0] |= consumed;
400 } else {
401 if (buf[1] != 0xf7) {
402 if (buf[2] == 0xf7 || buf[3] == 0xf7) {
403 // Transfer end code at next time.
404 consumed -= 1;
405 }
406
407 buf[0] |= consumed;
408 } else {
409 // The end of exclusives.
410 ff->on_sysex[port] = false;
411 consumed = 1;
412 buf[0] |= 0x0f;
413 }
414 }
415
416 ff->msg_buf[port][0] = cpu_to_le32(data);
417 ff->rx_bytes[port] = consumed;
418
419 return 1;
420}
421
422const struct snd_ff_protocol snd_ff_protocol_latter = {
423 .handle_midi_msg = latter_handle_midi_msg,
424 .fill_midi_msg = latter_fill_midi_msg,
425 .get_clock = latter_get_clock,
426 .switch_fetching_mode = latter_switch_fetching_mode,
427 .begin_session = latter_begin_session,
428 .finish_session = latter_finish_session,
429 .dump_status = latter_dump_status,
430};
diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c
index a490e4553721..a8a90f1ae09e 100644
--- a/sound/firewire/fireface/ff-stream.c
+++ b/sound/firewire/fireface/ff-stream.c
@@ -37,44 +37,10 @@ static void release_resources(struct snd_ff *ff)
37 fw_iso_resources_free(&ff->rx_resources); 37 fw_iso_resources_free(&ff->rx_resources);
38} 38}
39 39
40static int switch_fetching_mode(struct snd_ff *ff, bool enable)
41{
42 unsigned int count;
43 __le32 *reg;
44 int i;
45 int err;
46
47 count = 0;
48 for (i = 0; i < SND_FF_STREAM_MODE_COUNT; ++i)
49 count = max(count, ff->spec->pcm_playback_channels[i]);
50
51 reg = kcalloc(count, sizeof(__le32), GFP_KERNEL);
52 if (!reg)
53 return -ENOMEM;
54
55 if (!enable) {
56 /*
57 * Each quadlet is corresponding to data channels in a data
58 * blocks in reverse order. Precisely, quadlets for available
59 * data channels should be enabled. Here, I take second best
60 * to fetch PCM frames from all of data channels regardless of
61 * stf.
62 */
63 for (i = 0; i < count; ++i)
64 reg[i] = cpu_to_le32(0x00000001);
65 }
66
67 err = snd_fw_transaction(ff->unit, TCODE_WRITE_BLOCK_REQUEST,
68 SND_FF_REG_FETCH_PCM_FRAMES, reg,
69 sizeof(__le32) * count, 0);
70 kfree(reg);
71 return err;
72}
73
74static inline void finish_session(struct snd_ff *ff) 40static inline void finish_session(struct snd_ff *ff)
75{ 41{
76 ff->spec->protocol->finish_session(ff); 42 ff->spec->protocol->finish_session(ff);
77 switch_fetching_mode(ff, false); 43 ff->spec->protocol->switch_fetching_mode(ff, false);
78} 44}
79 45
80static int init_stream(struct snd_ff *ff, enum amdtp_stream_direction dir) 46static int init_stream(struct snd_ff *ff, enum amdtp_stream_direction dir)
@@ -147,7 +113,7 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
147 if (ff->substreams_counter == 0) 113 if (ff->substreams_counter == 0)
148 return 0; 114 return 0;
149 115
150 err = snd_ff_transaction_get_clock(ff, &curr_rate, &src); 116 err = ff->spec->protocol->get_clock(ff, &curr_rate, &src);
151 if (err < 0) 117 if (err < 0)
152 return err; 118 return err;
153 if (curr_rate != rate || 119 if (curr_rate != rate ||
@@ -206,7 +172,7 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
206 goto error; 172 goto error;
207 } 173 }
208 174
209 err = switch_fetching_mode(ff, true); 175 err = ff->spec->protocol->switch_fetching_mode(ff, true);
210 if (err < 0) 176 if (err < 0)
211 goto error; 177 goto error;
212 } 178 }
diff --git a/sound/firewire/fireface/ff-transaction.c b/sound/firewire/fireface/ff-transaction.c
index 5f4ddfd55403..0d6ad19363b8 100644
--- a/sound/firewire/fireface/ff-transaction.c
+++ b/sound/firewire/fireface/ff-transaction.c
@@ -8,72 +8,6 @@
8 8
9#include "ff.h" 9#include "ff.h"
10 10
11#define SND_FF_REG_MIDI_RX_PORT_0 0x000080180000ull
12#define SND_FF_REG_MIDI_RX_PORT_1 0x000080190000ull
13
14int snd_ff_transaction_get_clock(struct snd_ff *ff, unsigned int *rate,
15 enum snd_ff_clock_src *src)
16{
17 __le32 reg;
18 u32 data;
19 int err;
20
21 err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
22 SND_FF_REG_CLOCK_CONFIG, &reg, sizeof(reg), 0);
23 if (err < 0)
24 return err;
25 data = le32_to_cpu(reg);
26
27 /* Calculate sampling rate. */
28 switch ((data >> 1) & 0x03) {
29 case 0x01:
30 *rate = 32000;
31 break;
32 case 0x00:
33 *rate = 44100;
34 break;
35 case 0x03:
36 *rate = 48000;
37 break;
38 case 0x02:
39 default:
40 return -EIO;
41 }
42
43 if (data & 0x08)
44 *rate *= 2;
45 else if (data & 0x10)
46 *rate *= 4;
47
48 /* Calculate source of clock. */
49 if (data & 0x01) {
50 *src = SND_FF_CLOCK_SRC_INTERNAL;
51 } else {
52 /* TODO: 0x02, 0x06, 0x07? */
53 switch ((data >> 10) & 0x07) {
54 case 0x00:
55 *src = SND_FF_CLOCK_SRC_ADAT1;
56 break;
57 case 0x01:
58 *src = SND_FF_CLOCK_SRC_ADAT2;
59 break;
60 case 0x03:
61 *src = SND_FF_CLOCK_SRC_SPDIF;
62 break;
63 case 0x04:
64 *src = SND_FF_CLOCK_SRC_WORD;
65 break;
66 case 0x05:
67 *src = SND_FF_CLOCK_SRC_LTC;
68 break;
69 default:
70 return -EIO;
71 }
72 }
73
74 return 0;
75}
76
77static void finish_transmit_midi_msg(struct snd_ff *ff, unsigned int port, 11static void finish_transmit_midi_msg(struct snd_ff *ff, unsigned int port,
78 int rcode) 12 int rcode)
79{ 13{
@@ -117,23 +51,17 @@ static void finish_transmit_midi1_msg(struct fw_card *card, int rcode,
117 finish_transmit_midi_msg(ff, 1, rcode); 51 finish_transmit_midi_msg(ff, 1, rcode);
118} 52}
119 53
120static inline void fill_midi_buf(struct snd_ff *ff, unsigned int port,
121 unsigned int index, u8 byte)
122{
123 ff->msg_buf[port][index] = cpu_to_le32(byte);
124}
125
126static void transmit_midi_msg(struct snd_ff *ff, unsigned int port) 54static void transmit_midi_msg(struct snd_ff *ff, unsigned int port)
127{ 55{
128 struct snd_rawmidi_substream *substream = 56 struct snd_rawmidi_substream *substream =
129 READ_ONCE(ff->rx_midi_substreams[port]); 57 READ_ONCE(ff->rx_midi_substreams[port]);
130 u8 *buf = (u8 *)ff->msg_buf[port]; 58 int quad_count;
131 int i, len;
132 59
133 struct fw_device *fw_dev = fw_parent_device(ff->unit); 60 struct fw_device *fw_dev = fw_parent_device(ff->unit);
134 unsigned long long addr; 61 unsigned long long addr;
135 int generation; 62 int generation;
136 fw_transaction_callback_t callback; 63 fw_transaction_callback_t callback;
64 int tcode;
137 65
138 if (substream == NULL || snd_rawmidi_transmit_empty(substream)) 66 if (substream == NULL || snd_rawmidi_transmit_empty(substream))
139 return; 67 return;
@@ -147,26 +75,26 @@ static void transmit_midi_msg(struct snd_ff *ff, unsigned int port)
147 return; 75 return;
148 } 76 }
149 77
150 len = snd_rawmidi_transmit_peek(substream, buf, 78 quad_count = ff->spec->protocol->fill_midi_msg(ff, substream, port);
151 SND_FF_MAXIMIM_MIDI_QUADS); 79 if (quad_count <= 0)
152 if (len <= 0)
153 return; 80 return;
154 81
155 for (i = len - 1; i >= 0; i--)
156 fill_midi_buf(ff, port, i, buf[i]);
157
158 if (port == 0) { 82 if (port == 0) {
159 addr = SND_FF_REG_MIDI_RX_PORT_0; 83 addr = ff->spec->midi_rx_addrs[0];
160 callback = finish_transmit_midi0_msg; 84 callback = finish_transmit_midi0_msg;
161 } else { 85 } else {
162 addr = SND_FF_REG_MIDI_RX_PORT_1; 86 addr = ff->spec->midi_rx_addrs[1];
163 callback = finish_transmit_midi1_msg; 87 callback = finish_transmit_midi1_msg;
164 } 88 }
165 89
166 /* Set interval to next transaction. */ 90 /* Set interval to next transaction. */
167 ff->next_ktime[port] = ktime_add_ns(ktime_get(), 91 ff->next_ktime[port] = ktime_add_ns(ktime_get(),
168 len * 8 * NSEC_PER_SEC / 31250); 92 ff->rx_bytes[port] * 8 * NSEC_PER_SEC / 31250);
169 ff->rx_bytes[port] = len; 93
94 if (quad_count == 1)
95 tcode = TCODE_WRITE_QUADLET_REQUEST;
96 else
97 tcode = TCODE_WRITE_BLOCK_REQUEST;
170 98
171 /* 99 /*
172 * In Linux FireWire core, when generation is updated with memory 100 * In Linux FireWire core, when generation is updated with memory
@@ -178,10 +106,9 @@ static void transmit_midi_msg(struct snd_ff *ff, unsigned int port)
178 */ 106 */
179 generation = fw_dev->generation; 107 generation = fw_dev->generation;
180 smp_rmb(); 108 smp_rmb();
181 fw_send_request(fw_dev->card, &ff->transactions[port], 109 fw_send_request(fw_dev->card, &ff->transactions[port], tcode,
182 TCODE_WRITE_BLOCK_REQUEST,
183 fw_dev->node_id, generation, fw_dev->max_speed, 110 fw_dev->node_id, generation, fw_dev->max_speed,
184 addr, &ff->msg_buf[port], len * 4, 111 addr, &ff->msg_buf[port], quad_count * 4,
185 callback, &ff->transactions[port]); 112 callback, &ff->transactions[port]);
186} 113}
187 114
@@ -209,7 +136,9 @@ static void handle_midi_msg(struct fw_card *card, struct fw_request *request,
209 136
210 fw_send_response(card, request, RCODE_COMPLETE); 137 fw_send_response(card, request, RCODE_COMPLETE);
211 138
212 ff->spec->protocol->handle_midi_msg(ff, buf, length); 139 offset -= ff->async_handler.offset;
140 ff->spec->protocol->handle_midi_msg(ff, (unsigned int)offset, buf,
141 length);
213} 142}
214 143
215static int allocate_own_address(struct snd_ff *ff, int i) 144static int allocate_own_address(struct snd_ff *ff, int i)
@@ -217,7 +146,7 @@ static int allocate_own_address(struct snd_ff *ff, int i)
217 struct fw_address_region midi_msg_region; 146 struct fw_address_region midi_msg_region;
218 int err; 147 int err;
219 148
220 ff->async_handler.length = SND_FF_MAXIMIM_MIDI_QUADS * 4; 149 ff->async_handler.length = ff->spec->midi_addr_range;
221 ff->async_handler.address_callback = handle_midi_msg; 150 ff->async_handler.address_callback = handle_midi_msg;
222 ff->async_handler.callback_data = ff; 151 ff->async_handler.callback_data = ff;
223 152
@@ -236,35 +165,13 @@ static int allocate_own_address(struct snd_ff *ff, int i)
236 return err; 165 return err;
237} 166}
238 167
239/* 168// Controllers are allowed to register higher 4 bytes of destination address to
240 * Controllers are allowed to register higher 4 bytes of address to receive 169// receive asynchronous transactions for MIDI messages, while the way to
241 * the transactions. Different models have different registers for this purpose; 170// register lower 4 bytes of address is different depending on protocols. For
242 * e.g. 0x'0000'8010'03f4 for Fireface 400. 171// details, please refer to comments in protocol implementations.
243 * The controllers are not allowed to register lower 4 bytes of the address. 172//
244 * They are forced to select one of 4 options for the part of address by writing 173// This driver expects userspace applications to configure registers for the
245 * corresponding bits to 0x'0000'8010'051f. 174// lower address because in most cases such registers has the other settings.
246 *
247 * The 3rd-6th bits of this register are flags to indicate lower 4 bytes of
248 * address to which the device transferrs the transactions. In short:
249 * - 0x20: 0x'....'....'0000'0180
250 * - 0x10: 0x'....'....'0000'0100
251 * - 0x08: 0x'....'....'0000'0080
252 * - 0x04: 0x'....'....'0000'0000
253 *
254 * This driver configure 0x'....'....'0000'0000 to receive MIDI messages from
255 * units. The 3rd bit of the register should be configured, however this driver
256 * deligates this task to userspace applications due to a restriction that this
257 * register is write-only and the other bits have own effects.
258 *
259 * Unlike Fireface 800, Fireface 400 cancels transferring asynchronous
260 * transactions when the 1st and 2nd of the register stand. These two bits have
261 * the same effect.
262 * - 0x02, 0x01: cancel transferring
263 *
264 * On the other hand, the bits have no effect on Fireface 800. This model
265 * cancels asynchronous transactions when the higher 4 bytes of address is
266 * overwritten with zero.
267 */
268int snd_ff_transaction_reregister(struct snd_ff *ff) 175int snd_ff_transaction_reregister(struct snd_ff *ff)
269{ 176{
270 struct fw_card *fw_card = fw_parent_device(ff->unit)->card; 177 struct fw_card *fw_card = fw_parent_device(ff->unit)->card;
diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c
index 36575f4159d1..a9611157f4c8 100644
--- a/sound/firewire/fireface/ff.c
+++ b/sound/firewire/fireface/ff.c
@@ -153,6 +153,8 @@ static const struct snd_ff_spec spec_ff800 = {
153 .midi_out_ports = 1, 153 .midi_out_ports = 1,
154 .protocol = &snd_ff_protocol_ff800, 154 .protocol = &snd_ff_protocol_ff800,
155 .midi_high_addr = 0x000200000320ull, 155 .midi_high_addr = 0x000200000320ull,
156 .midi_addr_range = 12,
157 .midi_rx_addrs = {0x000080180000ull, 0},
156}; 158};
157 159
158static const struct snd_ff_spec spec_ff400 = { 160static const struct snd_ff_spec spec_ff400 = {
@@ -163,6 +165,20 @@ static const struct snd_ff_spec spec_ff400 = {
163 .midi_out_ports = 2, 165 .midi_out_ports = 2,
164 .protocol = &snd_ff_protocol_ff400, 166 .protocol = &snd_ff_protocol_ff400,
165 .midi_high_addr = 0x0000801003f4ull, 167 .midi_high_addr = 0x0000801003f4ull,
168 .midi_addr_range = SND_FF_MAXIMIM_MIDI_QUADS * 4,
169 .midi_rx_addrs = {0x000080180000ull, 0x000080190000ull},
170};
171
172static const struct snd_ff_spec spec_ucx = {
173 .name = "FirefaceUCX",
174 .pcm_capture_channels = {18, 14, 12},
175 .pcm_playback_channels = {18, 14, 12},
176 .midi_in_ports = 2,
177 .midi_out_ports = 2,
178 .protocol = &snd_ff_protocol_latter,
179 .midi_high_addr = 0xffff00000034ull,
180 .midi_addr_range = 0x80,
181 .midi_rx_addrs = {0xffff00000030ull, 0xffff00000030ull},
166}; 182};
167 183
168static const struct ieee1394_device_id snd_ff_id_table[] = { 184static const struct ieee1394_device_id snd_ff_id_table[] = {
@@ -190,6 +206,18 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
190 .model_id = 0x101800, 206 .model_id = 0x101800,
191 .driver_data = (kernel_ulong_t)&spec_ff400, 207 .driver_data = (kernel_ulong_t)&spec_ff400,
192 }, 208 },
209 // Fireface UCX.
210 {
211 .match_flags = IEEE1394_MATCH_VENDOR_ID |
212 IEEE1394_MATCH_SPECIFIER_ID |
213 IEEE1394_MATCH_VERSION |
214 IEEE1394_MATCH_MODEL_ID,
215 .vendor_id = OUI_RME,
216 .specifier_id = OUI_RME,
217 .version = 0x000004,
218 .model_id = 0x101800,
219 .driver_data = (kernel_ulong_t)&spec_ucx,
220 },
193 {} 221 {}
194}; 222};
195MODULE_DEVICE_TABLE(ieee1394, snd_ff_id_table); 223MODULE_DEVICE_TABLE(ieee1394, snd_ff_id_table);
diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h
index 7dfc7745a914..ed8fea0ff5e1 100644
--- a/sound/firewire/fireface/ff.h
+++ b/sound/firewire/fireface/ff.h
@@ -35,11 +35,6 @@
35#define SND_FF_IN_MIDI_PORTS 2 35#define SND_FF_IN_MIDI_PORTS 2
36#define SND_FF_OUT_MIDI_PORTS 2 36#define SND_FF_OUT_MIDI_PORTS 2
37 37
38#define SND_FF_REG_SYNC_STATUS 0x0000801c0000ull
39/* For block write request. */
40#define SND_FF_REG_FETCH_PCM_FRAMES 0x0000801c0000ull
41#define SND_FF_REG_CLOCK_CONFIG 0x0000801c0004ull
42
43enum snd_ff_stream_mode { 38enum snd_ff_stream_mode {
44 SND_FF_STREAM_MODE_LOW = 0, 39 SND_FF_STREAM_MODE_LOW = 0,
45 SND_FF_STREAM_MODE_MID, 40 SND_FF_STREAM_MODE_MID,
@@ -59,6 +54,8 @@ struct snd_ff_spec {
59 54
60 const struct snd_ff_protocol *protocol; 55 const struct snd_ff_protocol *protocol;
61 u64 midi_high_addr; 56 u64 midi_high_addr;
57 u8 midi_addr_range;
58 u64 midi_rx_addrs[SND_FF_OUT_MIDI_PORTS];
62}; 59};
63 60
64struct snd_ff { 61struct snd_ff {
@@ -78,7 +75,7 @@ struct snd_ff {
78 75
79 /* TO handle MIDI rx. */ 76 /* TO handle MIDI rx. */
80 struct snd_rawmidi_substream *rx_midi_substreams[SND_FF_OUT_MIDI_PORTS]; 77 struct snd_rawmidi_substream *rx_midi_substreams[SND_FF_OUT_MIDI_PORTS];
81 u8 running_status[SND_FF_OUT_MIDI_PORTS]; 78 bool on_sysex[SND_FF_OUT_MIDI_PORTS];
82 __le32 msg_buf[SND_FF_OUT_MIDI_PORTS][SND_FF_MAXIMIM_MIDI_QUADS]; 79 __le32 msg_buf[SND_FF_OUT_MIDI_PORTS][SND_FF_MAXIMIM_MIDI_QUADS];
83 struct work_struct rx_midi_work[SND_FF_OUT_MIDI_PORTS]; 80 struct work_struct rx_midi_work[SND_FF_OUT_MIDI_PORTS];
84 struct fw_transaction transactions[SND_FF_OUT_MIDI_PORTS]; 81 struct fw_transaction transactions[SND_FF_OUT_MIDI_PORTS];
@@ -108,16 +105,23 @@ enum snd_ff_clock_src {
108}; 105};
109 106
110struct snd_ff_protocol { 107struct snd_ff_protocol {
111 void (*handle_midi_msg)(struct snd_ff *ff, __le32 *buf, size_t length); 108 void (*handle_midi_msg)(struct snd_ff *ff, unsigned int offset,
109 __le32 *buf, size_t length);
110 int (*fill_midi_msg)(struct snd_ff *ff,
111 struct snd_rawmidi_substream *substream,
112 unsigned int port);
113 int (*get_clock)(struct snd_ff *ff, unsigned int *rate,
114 enum snd_ff_clock_src *src);
115 int (*switch_fetching_mode)(struct snd_ff *ff, bool enable);
112 int (*begin_session)(struct snd_ff *ff, unsigned int rate); 116 int (*begin_session)(struct snd_ff *ff, unsigned int rate);
113 void (*finish_session)(struct snd_ff *ff); 117 void (*finish_session)(struct snd_ff *ff);
118 void (*dump_status)(struct snd_ff *ff, struct snd_info_buffer *buffer);
114}; 119};
115 120
116extern const struct snd_ff_protocol snd_ff_protocol_ff800; 121extern const struct snd_ff_protocol snd_ff_protocol_ff800;
117extern const struct snd_ff_protocol snd_ff_protocol_ff400; 122extern const struct snd_ff_protocol snd_ff_protocol_ff400;
123extern const struct snd_ff_protocol snd_ff_protocol_latter;
118 124
119int snd_ff_transaction_get_clock(struct snd_ff *ff, unsigned int *rate,
120 enum snd_ff_clock_src *src);
121int snd_ff_transaction_register(struct snd_ff *ff); 125int snd_ff_transaction_register(struct snd_ff *ff);
122int snd_ff_transaction_reregister(struct snd_ff *ff); 126int snd_ff_transaction_reregister(struct snd_ff *ff);
123void snd_ff_transaction_unregister(struct snd_ff *ff); 127void snd_ff_transaction_unregister(struct snd_ff *ff);
@@ -142,6 +146,7 @@ int snd_ff_stream_lock_try(struct snd_ff *ff);
142void snd_ff_stream_lock_release(struct snd_ff *ff); 146void snd_ff_stream_lock_release(struct snd_ff *ff);
143 147
144void snd_ff_proc_init(struct snd_ff *ff); 148void snd_ff_proc_init(struct snd_ff *ff);
149const char *snd_ff_proc_get_clk_label(enum snd_ff_clock_src src);
145 150
146int snd_ff_create_midi_devices(struct snd_ff *ff); 151int snd_ff_create_midi_devices(struct snd_ff *ff);
147 152
diff --git a/sound/firewire/fireworks/fireworks_proc.c b/sound/firewire/fireworks/fireworks_proc.c
index 779ecec5af62..9fa5c34a9572 100644
--- a/sound/firewire/fireworks/fireworks_proc.c
+++ b/sound/firewire/fireworks/fireworks_proc.c
@@ -199,12 +199,8 @@ add_node(struct snd_efw *efw, struct snd_info_entry *root, const char *name,
199 struct snd_info_entry *entry; 199 struct snd_info_entry *entry;
200 200
201 entry = snd_info_create_card_entry(efw->card, name, root); 201 entry = snd_info_create_card_entry(efw->card, name, root);
202 if (entry == NULL) 202 if (entry)
203 return; 203 snd_info_set_text_ops(entry, efw, op);
204
205 snd_info_set_text_ops(entry, efw, op);
206 if (snd_info_register(entry) < 0)
207 snd_info_free_entry(entry);
208} 204}
209 205
210void snd_efw_proc_init(struct snd_efw *efw) 206void snd_efw_proc_init(struct snd_efw *efw)
@@ -220,10 +216,6 @@ void snd_efw_proc_init(struct snd_efw *efw)
220 if (root == NULL) 216 if (root == NULL)
221 return; 217 return;
222 root->mode = S_IFDIR | 0555; 218 root->mode = S_IFDIR | 0555;
223 if (snd_info_register(root) < 0) {
224 snd_info_free_entry(root);
225 return;
226 }
227 219
228 add_node(efw, root, "clock", proc_read_clock); 220 add_node(efw, root, "clock", proc_read_clock);
229 add_node(efw, root, "firmware", proc_read_hwinfo); 221 add_node(efw, root, "firmware", proc_read_hwinfo);
diff --git a/sound/firewire/motu/motu-proc.c b/sound/firewire/motu/motu-proc.c
index ab6830a6d242..94327853620a 100644
--- a/sound/firewire/motu/motu-proc.c
+++ b/sound/firewire/motu/motu-proc.c
@@ -87,12 +87,8 @@ static void add_node(struct snd_motu *motu, struct snd_info_entry *root,
87 struct snd_info_entry *entry; 87 struct snd_info_entry *entry;
88 88
89 entry = snd_info_create_card_entry(motu->card, name, root); 89 entry = snd_info_create_card_entry(motu->card, name, root);
90 if (entry == NULL) 90 if (entry)
91 return; 91 snd_info_set_text_ops(entry, motu, op);
92
93 snd_info_set_text_ops(entry, motu, op);
94 if (snd_info_register(entry) < 0)
95 snd_info_free_entry(entry);
96} 92}
97 93
98void snd_motu_proc_init(struct snd_motu *motu) 94void snd_motu_proc_init(struct snd_motu *motu)
@@ -108,10 +104,6 @@ void snd_motu_proc_init(struct snd_motu *motu)
108 if (root == NULL) 104 if (root == NULL)
109 return; 105 return;
110 root->mode = S_IFDIR | 0555; 106 root->mode = S_IFDIR | 0555;
111 if (snd_info_register(root) < 0) {
112 snd_info_free_entry(root);
113 return;
114 }
115 107
116 add_node(motu, root, "clock", proc_read_clock); 108 add_node(motu, root, "clock", proc_read_clock);
117 add_node(motu, root, "format", proc_read_format); 109 add_node(motu, root, "format", proc_read_format);
diff --git a/sound/firewire/oxfw/oxfw-proc.c b/sound/firewire/oxfw/oxfw-proc.c
index 27dac071bc73..644107e3782e 100644
--- a/sound/firewire/oxfw/oxfw-proc.c
+++ b/sound/firewire/oxfw/oxfw-proc.c
@@ -83,12 +83,8 @@ static void add_node(struct snd_oxfw *oxfw, struct snd_info_entry *root,
83 struct snd_info_entry *entry; 83 struct snd_info_entry *entry;
84 84
85 entry = snd_info_create_card_entry(oxfw->card, name, root); 85 entry = snd_info_create_card_entry(oxfw->card, name, root);
86 if (entry == NULL) 86 if (entry)
87 return; 87 snd_info_set_text_ops(entry, oxfw, op);
88
89 snd_info_set_text_ops(entry, oxfw, op);
90 if (snd_info_register(entry) < 0)
91 snd_info_free_entry(entry);
92} 88}
93 89
94void snd_oxfw_proc_init(struct snd_oxfw *oxfw) 90void snd_oxfw_proc_init(struct snd_oxfw *oxfw)
@@ -104,10 +100,6 @@ void snd_oxfw_proc_init(struct snd_oxfw *oxfw)
104 if (root == NULL) 100 if (root == NULL)
105 return; 101 return;
106 root->mode = S_IFDIR | 0555; 102 root->mode = S_IFDIR | 0555;
107 if (snd_info_register(root) < 0) {
108 snd_info_free_entry(root);
109 return;
110 }
111 103
112 add_node(oxfw, root, "formation", proc_read_formation); 104 add_node(oxfw, root, "formation", proc_read_formation);
113} 105}
diff --git a/sound/firewire/tascam/tascam-proc.c b/sound/firewire/tascam/tascam-proc.c
index fee3bf32a0da..8bc8d277394a 100644
--- a/sound/firewire/tascam/tascam-proc.c
+++ b/sound/firewire/tascam/tascam-proc.c
@@ -58,12 +58,8 @@ static void add_node(struct snd_tscm *tscm, struct snd_info_entry *root,
58 struct snd_info_entry *entry; 58 struct snd_info_entry *entry;
59 59
60 entry = snd_info_create_card_entry(tscm->card, name, root); 60 entry = snd_info_create_card_entry(tscm->card, name, root);
61 if (entry == NULL) 61 if (entry)
62 return; 62 snd_info_set_text_ops(entry, tscm, op);
63
64 snd_info_set_text_ops(entry, tscm, op);
65 if (snd_info_register(entry) < 0)
66 snd_info_free_entry(entry);
67} 63}
68 64
69void snd_tscm_proc_init(struct snd_tscm *tscm) 65void snd_tscm_proc_init(struct snd_tscm *tscm)
@@ -79,10 +75,6 @@ void snd_tscm_proc_init(struct snd_tscm *tscm)
79 if (root == NULL) 75 if (root == NULL)
80 return; 76 return;
81 root->mode = S_IFDIR | 0555; 77 root->mode = S_IFDIR | 0555;
82 if (snd_info_register(root) < 0) {
83 snd_info_free_entry(root);
84 return;
85 }
86 78
87 add_node(tscm, root, "firmware", proc_read_firmware); 79 add_node(tscm, root, "firmware", proc_read_firmware);
88} 80}
diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c
index 74244d8e2909..b2e9454f5816 100644
--- a/sound/hda/hdac_controller.c
+++ b/sound/hda/hdac_controller.c
@@ -376,7 +376,7 @@ void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus)
376{ 376{
377 unsigned long timeout; 377 unsigned long timeout;
378 378
379 snd_hdac_chip_updateb(bus, GCTL, 0, AZX_GCTL_RESET); 379 snd_hdac_chip_updateb(bus, GCTL, AZX_GCTL_RESET, AZX_GCTL_RESET);
380 380
381 timeout = jiffies + msecs_to_jiffies(100); 381 timeout = jiffies + msecs_to_jiffies(100);
382 while (!snd_hdac_chip_readb(bus, GCTL) && time_before(jiffies, timeout)) 382 while (!snd_hdac_chip_readb(bus, GCTL) && time_before(jiffies, timeout))
@@ -415,7 +415,7 @@ int snd_hdac_bus_reset_link(struct hdac_bus *bus, bool full_reset)
415 } 415 }
416 416
417 /* Accept unsolicited responses */ 417 /* Accept unsolicited responses */
418 snd_hdac_chip_updatel(bus, GCTL, 0, AZX_GCTL_UNSOL); 418 snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL);
419 419
420 /* detect codecs */ 420 /* detect codecs */
421 if (!bus->codec_mask) { 421 if (!bus->codec_mask) {
@@ -431,7 +431,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_reset_link);
431static void azx_int_enable(struct hdac_bus *bus) 431static void azx_int_enable(struct hdac_bus *bus)
432{ 432{
433 /* enable controller CIE and GIE */ 433 /* enable controller CIE and GIE */
434 snd_hdac_chip_updatel(bus, INTCTL, 0, AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN); 434 snd_hdac_chip_updatel(bus, INTCTL,
435 AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN,
436 AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN);
435} 437}
436 438
437/* disable interrupts */ 439/* disable interrupts */
diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
index eee422390d8e..f5dd288d1a7a 100644
--- a/sound/hda/hdac_stream.c
+++ b/sound/hda/hdac_stream.c
@@ -13,6 +13,40 @@
13#include "trace.h" 13#include "trace.h"
14 14
15/** 15/**
16 * snd_hdac_get_stream_stripe_ctl - get stripe control value
17 * @bus: HD-audio core bus
18 * @substream: PCM substream
19 */
20int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus,
21 struct snd_pcm_substream *substream)
22{
23 struct snd_pcm_runtime *runtime = substream->runtime;
24 unsigned int channels = runtime->channels,
25 rate = runtime->rate,
26 bits_per_sample = runtime->sample_bits,
27 max_sdo_lines, value, sdo_line;
28
29 /* T_AZA_GCAP_NSDO is 1:2 bitfields in GCAP */
30 max_sdo_lines = snd_hdac_chip_readl(bus, GCAP) & AZX_GCAP_NSDO;
31
32 /* following is from HD audio spec */
33 for (sdo_line = max_sdo_lines; sdo_line > 0; sdo_line >>= 1) {
34 if (rate > 48000)
35 value = (channels * bits_per_sample *
36 (rate / 48000)) / sdo_line;
37 else
38 value = (channels * bits_per_sample) / sdo_line;
39
40 if (value >= 8)
41 break;
42 }
43
44 /* stripe value: 0 for 1SDO, 1 for 2SDO, 2 for 4SDO lines */
45 return sdo_line >> 1;
46}
47EXPORT_SYMBOL_GPL(snd_hdac_get_stream_stripe_ctl);
48
49/**
16 * snd_hdac_stream_init - initialize each stream (aka device) 50 * snd_hdac_stream_init - initialize each stream (aka device)
17 * @bus: HD-audio core bus 51 * @bus: HD-audio core bus
18 * @azx_dev: HD-audio core stream object to initialize 52 * @azx_dev: HD-audio core stream object to initialize
@@ -48,6 +82,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_init);
48void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start) 82void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start)
49{ 83{
50 struct hdac_bus *bus = azx_dev->bus; 84 struct hdac_bus *bus = azx_dev->bus;
85 int stripe_ctl;
51 86
52 trace_snd_hdac_stream_start(bus, azx_dev); 87 trace_snd_hdac_stream_start(bus, azx_dev);
53 88
@@ -56,7 +91,13 @@ void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start)
56 azx_dev->start_wallclk -= azx_dev->period_wallclk; 91 azx_dev->start_wallclk -= azx_dev->period_wallclk;
57 92
58 /* enable SIE */ 93 /* enable SIE */
59 snd_hdac_chip_updatel(bus, INTCTL, 0, 1 << azx_dev->index); 94 snd_hdac_chip_updatel(bus, INTCTL,
95 1 << azx_dev->index,
96 1 << azx_dev->index);
97 /* set stripe control */
98 stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream);
99 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
100 stripe_ctl);
60 /* set DMA start and interrupt mask */ 101 /* set DMA start and interrupt mask */
61 snd_hdac_stream_updateb(azx_dev, SD_CTL, 102 snd_hdac_stream_updateb(azx_dev, SD_CTL,
62 0, SD_CTL_DMA_START | SD_INT_MASK); 103 0, SD_CTL_DMA_START | SD_INT_MASK);
@@ -73,6 +114,7 @@ void snd_hdac_stream_clear(struct hdac_stream *azx_dev)
73 snd_hdac_stream_updateb(azx_dev, SD_CTL, 114 snd_hdac_stream_updateb(azx_dev, SD_CTL,
74 SD_CTL_DMA_START | SD_INT_MASK, 0); 115 SD_CTL_DMA_START | SD_INT_MASK, 0);
75 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ 116 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
117 snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
76 azx_dev->running = false; 118 azx_dev->running = false;
77} 119}
78EXPORT_SYMBOL_GPL(snd_hdac_stream_clear); 120EXPORT_SYMBOL_GPL(snd_hdac_stream_clear);
diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c
index 4099e6062d3c..573599d0378d 100644
--- a/sound/i2c/other/ak4113.c
+++ b/sound/i2c/other/ak4113.c
@@ -492,9 +492,8 @@ static void snd_ak4113_proc_regs_read(struct snd_info_entry *entry,
492 492
493static void snd_ak4113_proc_init(struct ak4113 *ak4113) 493static void snd_ak4113_proc_init(struct ak4113 *ak4113)
494{ 494{
495 struct snd_info_entry *entry; 495 snd_card_ro_proc_new(ak4113->card, "ak4113", ak4113,
496 if (!snd_card_proc_new(ak4113->card, "ak4113", &entry)) 496 snd_ak4113_proc_regs_read);
497 snd_info_set_text_ops(entry, ak4113, snd_ak4113_proc_regs_read);
498} 497}
499 498
500int snd_ak4113_build(struct ak4113 *ak4113, 499int snd_ak4113_build(struct ak4113 *ak4113,
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 7fb1aeb46915..76afb975782d 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -465,9 +465,8 @@ static void snd_ak4114_proc_regs_read(struct snd_info_entry *entry,
465 465
466static void snd_ak4114_proc_init(struct ak4114 *ak4114) 466static void snd_ak4114_proc_init(struct ak4114 *ak4114)
467{ 467{
468 struct snd_info_entry *entry; 468 snd_card_ro_proc_new(ak4114->card, "ak4114", ak4114,
469 if (!snd_card_proc_new(ak4114->card, "ak4114", &entry)) 469 snd_ak4114_proc_regs_read);
470 snd_info_set_text_ops(entry, ak4114, snd_ak4114_proc_regs_read);
471} 470}
472 471
473int snd_ak4114_build(struct ak4114 *ak4114, 472int snd_ak4114_build(struct ak4114 *ak4114,
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c
index 7f2761a2e7c8..62a6c5fa96b5 100644
--- a/sound/i2c/other/ak4xxx-adda.c
+++ b/sound/i2c/other/ak4xxx-adda.c
@@ -875,13 +875,7 @@ static void proc_regs_read(struct snd_info_entry *entry,
875 875
876static int proc_init(struct snd_akm4xxx *ak) 876static int proc_init(struct snd_akm4xxx *ak)
877{ 877{
878 struct snd_info_entry *entry; 878 return snd_card_ro_proc_new(ak->card, ak->name, ak, proc_regs_read);
879 int err;
880 err = snd_card_proc_new(ak->card, ak->name, &entry);
881 if (err < 0)
882 return err;
883 snd_info_set_text_ops(entry, ak, proc_regs_read);
884 return 0;
885} 879}
886 880
887int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak) 881int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index fba6d22f7f4b..94b381a78e9e 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -518,7 +518,6 @@ void snd_ad1816a_suspend(struct snd_ad1816a *chip)
518 int reg; 518 int reg;
519 unsigned long flags; 519 unsigned long flags;
520 520
521 snd_pcm_suspend_all(chip->pcm);
522 spin_lock_irqsave(&chip->lock, flags); 521 spin_lock_irqsave(&chip->lock, flags);
523 for (reg = 0; reg < 48; reg++) 522 for (reg = 0; reg < 48; reg++)
524 chip->image[reg] = snd_ad1816a_read(chip, reg); 523 chip->image[reg] = snd_ad1816a_read(chip, reg);
@@ -694,7 +693,7 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)
694 snd_ad1816a_init(chip); 693 snd_ad1816a_init(chip);
695 694
696 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 695 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
697 snd_dma_isa_data(), 696 chip->card->dev,
698 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); 697 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
699 698
700 chip->pcm = pcm; 699 chip->pcm = pcm;
diff --git a/sound/isa/als100.c b/sound/isa/als100.c
index f63142ec287e..571108021e9d 100644
--- a/sound/isa/als100.c
+++ b/sound/isa/als100.c
@@ -322,7 +322,6 @@ static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t stat
322 struct snd_sb *chip = acard->chip; 322 struct snd_sb *chip = acard->chip;
323 323
324 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 324 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
325 snd_pcm_suspend_all(chip->pcm);
326 snd_sbmixer_suspend(chip); 325 snd_sbmixer_suspend(chip);
327 return 0; 326 return 0;
328} 327}
diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c
index de6ef1b1cf0e..617977516201 100644
--- a/sound/isa/cmi8328.c
+++ b/sound/isa/cmi8328.c
@@ -434,7 +434,6 @@ static int snd_cmi8328_suspend(struct device *pdev, unsigned int n,
434 cmi = card->private_data; 434 cmi = card->private_data;
435 snd_cmi8328_cfg_save(cmi->port, cmi->cfg); 435 snd_cmi8328_cfg_save(cmi->port, cmi->cfg);
436 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 436 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
437 snd_pcm_suspend_all(cmi->wss->pcm);
438 cmi->wss->suspend(cmi->wss); 437 cmi->wss->suspend(cmi->wss);
439 438
440 return 0; 439 return 0;
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 6b8c46942efb..1868b73aa49c 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -470,7 +470,7 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip)
470 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops); 470 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops);
471 471
472 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 472 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
473 snd_dma_isa_data(), 473 card->dev,
474 64*1024, 128*1024); 474 64*1024, 128*1024);
475 chip->pcm = pcm; 475 chip->pcm = pcm;
476 476
@@ -484,7 +484,6 @@ static int snd_cmi8330_suspend(struct snd_card *card)
484 struct snd_cmi8330 *acard = card->private_data; 484 struct snd_cmi8330 *acard = card->private_data;
485 485
486 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 486 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
487 snd_pcm_suspend_all(acard->pcm);
488 acard->wss->suspend(acard->wss); 487 acard->wss->suspend(acard->wss);
489 snd_sbmixer_suspend(acard->sb); 488 snd_sbmixer_suspend(acard->sb);
490 return 0; 489 return 0;
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 3dfe7e592c25..87527627e059 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -301,10 +301,8 @@ static int snd_es968_pnp_suspend(struct pnp_card_link *pcard,
301 pm_message_t state) 301 pm_message_t state)
302{ 302{
303 struct snd_card *card = pnp_get_card_drvdata(pcard); 303 struct snd_card *card = pnp_get_card_drvdata(pcard);
304 struct snd_es1688 *chip = card->private_data;
305 304
306 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 305 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
307 snd_pcm_suspend_all(chip->pcm);
308 return 0; 306 return 0;
309} 307}
310 308
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index 50cdce0e8946..da341969e650 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -746,7 +746,7 @@ int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device)
746 chip->pcm = pcm; 746 chip->pcm = pcm;
747 747
748 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 748 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
749 snd_dma_isa_data(), 749 card->dev,
750 64*1024, 64*1024); 750 64*1024, 64*1024);
751 return 0; 751 return 0;
752} 752}
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 0d103d6f805e..07abc7f7840c 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1717,7 +1717,7 @@ static int snd_es18xx_pcm(struct snd_card *card, int device)
1717 chip->pcm = pcm; 1717 chip->pcm = pcm;
1718 1718
1719 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1719 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1720 snd_dma_isa_data(), 1720 card->dev,
1721 64*1024, 1721 64*1024,
1722 chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); 1722 chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
1723 return 0; 1723 return 0;
@@ -1731,8 +1731,6 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state)
1731 1731
1732 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1732 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1733 1733
1734 snd_pcm_suspend_all(chip->pcm);
1735
1736 /* power down */ 1734 /* power down */
1737 chip->pm_reg = (unsigned char)snd_es18xx_read(chip, ES18XX_PM); 1735 chip->pm_reg = (unsigned char)snd_es18xx_read(chip, ES18XX_PM);
1738 chip->pm_reg |= (ES18XX_PM_FM | ES18XX_PM_SUS); 1736 chip->pm_reg |= (ES18XX_PM_FM | ES18XX_PM_SUS);
diff --git a/sound/isa/gus/gus_irq.c b/sound/isa/gus/gus_irq.c
index 2055aff71b50..0ca6c38e2ed9 100644
--- a/sound/isa/gus/gus_irq.c
+++ b/sound/isa/gus/gus_irq.c
@@ -140,10 +140,7 @@ static void snd_gus_irq_info_read(struct snd_info_entry *entry,
140 140
141void snd_gus_irq_profile_init(struct snd_gus_card *gus) 141void snd_gus_irq_profile_init(struct snd_gus_card *gus)
142{ 142{
143 struct snd_info_entry *entry; 143 snd_card_ro_proc_new(gus->card, "gusirq", gus, snd_gus_irq_info_read);
144
145 if (! snd_card_proc_new(gus->card, "gusirq", &entry))
146 snd_info_set_text_ops(entry, gus, snd_gus_irq_info_read);
147} 144}
148 145
149#endif 146#endif
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index 3b8a0c880db5..33c8b66d5c8a 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -92,8 +92,17 @@ static const struct snd_kcontrol_new snd_gus_joystick_control = {
92 92
93static void snd_gus_init_control(struct snd_gus_card *gus) 93static void snd_gus_init_control(struct snd_gus_card *gus)
94{ 94{
95 if (!gus->ace_flag) 95 int ret;
96 snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus)); 96
97 if (!gus->ace_flag) {
98 ret =
99 snd_ctl_add(gus->card,
100 snd_ctl_new1(&snd_gus_joystick_control,
101 gus));
102 if (ret)
103 snd_printk(KERN_ERR "gus: snd_ctl_add failed: %d\n",
104 ret);
105 }
97} 106}
98 107
99/* 108/*
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c
index af888a022fc0..4ac76f46dd76 100644
--- a/sound/isa/gus/gus_mem.c
+++ b/sound/isa/gus/gus_mem.c
@@ -238,9 +238,6 @@ int snd_gf1_mem_init(struct snd_gus_card * gus)
238{ 238{
239 struct snd_gf1_mem *alloc; 239 struct snd_gf1_mem *alloc;
240 struct snd_gf1_mem_block block; 240 struct snd_gf1_mem_block block;
241#ifdef CONFIG_SND_DEBUG
242 struct snd_info_entry *entry;
243#endif
244 241
245 alloc = &gus->gf1.mem_alloc; 242 alloc = &gus->gf1.mem_alloc;
246 mutex_init(&alloc->memory_mutex); 243 mutex_init(&alloc->memory_mutex);
@@ -263,8 +260,7 @@ int snd_gf1_mem_init(struct snd_gus_card * gus)
263 if (snd_gf1_mem_xalloc(alloc, &block) == NULL) 260 if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
264 return -ENOMEM; 261 return -ENOMEM;
265#ifdef CONFIG_SND_DEBUG 262#ifdef CONFIG_SND_DEBUG
266 if (! snd_card_proc_new(gus->card, "gusmem", &entry)) 263 snd_card_ro_proc_new(gus->card, "gusmem", gus, snd_gf1_mem_info_read);
267 snd_info_set_text_ops(entry, gus, snd_gf1_mem_info_read);
268#endif 264#endif
269 return 0; 265 return 0;
270} 266}
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index 131b28997e1d..b9efc6dff45d 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -891,7 +891,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
891 891
892 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 892 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
893 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, 893 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
894 snd_dma_isa_data(), 894 card->dev,
895 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024); 895 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024);
896 896
897 pcm->info_flags = 0; 897 pcm->info_flags = 0;
@@ -901,7 +901,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
901 if (gus->gf1.dma2 == gus->gf1.dma1) 901 if (gus->gf1.dma2 == gus->gf1.dma1)
902 pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; 902 pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX;
903 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 903 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
904 SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), 904 SNDRV_DMA_TYPE_DEV, card->dev,
905 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024); 905 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
906 } 906 }
907 strcpy(pcm->name, pcm->id); 907 strcpy(pcm->name, pcm->id);
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c
index c6136c6b0214..997cdfd7b1ea 100644
--- a/sound/isa/opti9xx/miro.c
+++ b/sound/isa/opti9xx/miro.c
@@ -997,10 +997,7 @@ static void snd_miro_proc_read(struct snd_info_entry * entry,
997static void snd_miro_proc_init(struct snd_card *card, 997static void snd_miro_proc_init(struct snd_card *card,
998 struct snd_miro *miro) 998 struct snd_miro *miro)
999{ 999{
1000 struct snd_info_entry *entry; 1000 snd_card_ro_proc_new(card, "miro", miro, snd_miro_proc_read);
1001
1002 if (!snd_card_proc_new(card, "miro", &entry))
1003 snd_info_set_text_ops(entry, miro, snd_miro_proc_read);
1004} 1001}
1005 1002
1006/* 1003/*
diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c
index bfa0055e1fd6..7a313ff589c7 100644
--- a/sound/isa/sb/jazz16.c
+++ b/sound/isa/sb/jazz16.c
@@ -356,7 +356,6 @@ static int snd_jazz16_suspend(struct device *pdev, unsigned int n,
356 struct snd_sb *chip = acard->chip; 356 struct snd_sb *chip = acard->chip;
357 357
358 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 358 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
359 snd_pcm_suspend_all(chip->pcm);
360 snd_sbmixer_suspend(chip); 359 snd_sbmixer_suspend(chip);
361 return 0; 360 return 0;
362} 361}
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 8f9ebeb998f6..3844d4c02f49 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -471,7 +471,6 @@ static int snd_sb16_suspend(struct snd_card *card, pm_message_t state)
471 struct snd_sb *chip = acard->chip; 471 struct snd_sb *chip = acard->chip;
472 472
473 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 473 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
474 snd_pcm_suspend_all(chip->pcm);
475 snd_sbmixer_suspend(chip); 474 snd_sbmixer_suspend(chip);
476 return 0; 475 return 0;
477} 476}
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index bf3db0d2ea12..a09ad57b8313 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -1126,10 +1126,9 @@ static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p)
1126static int init_proc_entry(struct snd_sb_csp * p, int device) 1126static int init_proc_entry(struct snd_sb_csp * p, int device)
1127{ 1127{
1128 char name[16]; 1128 char name[16];
1129 struct snd_info_entry *entry; 1129
1130 sprintf(name, "cspD%d", device); 1130 sprintf(name, "cspD%d", device);
1131 if (! snd_card_proc_new(p->chip->card, name, &entry)) 1131 snd_card_ro_proc_new(p->chip->card, name, p, info_read);
1132 snd_info_set_text_ops(entry, p, info_read);
1133 return 0; 1132 return 0;
1134} 1133}
1135 1134
diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c
index 37e6ce7b0b13..473ec74ae48c 100644
--- a/sound/isa/sb/sb16_main.c
+++ b/sound/isa/sb/sb16_main.c
@@ -879,13 +879,17 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
879 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops); 879 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops);
880 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops); 880 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops);
881 881
882 if (chip->dma16 >= 0 && chip->dma8 != chip->dma16) 882 if (chip->dma16 >= 0 && chip->dma8 != chip->dma16) {
883 snd_ctl_add(card, snd_ctl_new1(&snd_sb16_dma_control, chip)); 883 err = snd_ctl_add(card, snd_ctl_new1(
884 else 884 &snd_sb16_dma_control, chip));
885 if (err)
886 return err;
887 } else {
885 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; 888 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
889 }
886 890
887 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 891 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
888 snd_dma_isa_data(), 892 card->dev,
889 64*1024, 128*1024); 893 64*1024, 128*1024);
890 return 0; 894 return 0;
891} 895}
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index d77dcba276b5..aa2a83eb81a9 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -218,7 +218,6 @@ static int snd_sb8_suspend(struct device *dev, unsigned int n,
218 struct snd_sb *chip = acard->chip; 218 struct snd_sb *chip = acard->chip;
219 219
220 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 220 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
221 snd_pcm_suspend_all(chip->pcm);
222 snd_sbmixer_suspend(chip); 221 snd_sbmixer_suspend(chip);
223 return 0; 222 return 0;
224} 223}
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c
index 8288fae90085..97645a732a71 100644
--- a/sound/isa/sb/sb8_main.c
+++ b/sound/isa/sb/sb8_main.c
@@ -610,7 +610,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device)
610 if (chip->dma8 > 3 || chip->dma16 >= 0) 610 if (chip->dma8 > 3 || chip->dma16 >= 0)
611 max_prealloc = 128 * 1024; 611 max_prealloc = 128 * 1024;
612 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 612 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
613 snd_dma_isa_data(), 613 card->dev,
614 64*1024, max_prealloc); 614 64*1024, max_prealloc);
615 615
616 return 0; 616 return 0;
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 733adee5afbf..8181db4db019 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -167,12 +167,13 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c)
167 * I think this means that the memory has to map to 167 * I think this means that the memory has to map to
168 * contiguous pages of physical memory. 168 * contiguous pages of physical memory.
169 */ 169 */
170static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, 170static struct snd_dma_buffer *get_dmabuf(struct soundscape *s,
171 struct snd_dma_buffer *buf,
171 unsigned long size) 172 unsigned long size)
172{ 173{
173 if (buf) { 174 if (buf) {
174 if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, 175 if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
175 snd_dma_isa_data(), 176 s->chip->card->dev,
176 size, buf) < 0) { 177 size, buf) < 0) {
177 snd_printk(KERN_ERR "sscape: Failed to allocate " 178 snd_printk(KERN_ERR "sscape: Failed to allocate "
178 "%lu bytes for DMA\n", 179 "%lu bytes for DMA\n",
@@ -443,7 +444,7 @@ static int upload_dma_data(struct soundscape *s, const unsigned char *data,
443 int ret; 444 int ret;
444 unsigned char val; 445 unsigned char val;
445 446
446 if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024))) 447 if (!get_dmabuf(s, &dma, PAGE_ALIGN(32 * 1024)))
447 return -ENOMEM; 448 return -ENOMEM;
448 449
449 spin_lock_irqsave(&s->lock, flags); 450 spin_lock_irqsave(&s->lock, flags);
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index 3a5008837576..0dfb8065b403 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -1625,7 +1625,6 @@ static void snd_wss_suspend(struct snd_wss *chip)
1625 int reg; 1625 int reg;
1626 unsigned long flags; 1626 unsigned long flags;
1627 1627
1628 snd_pcm_suspend_all(chip->pcm);
1629 spin_lock_irqsave(&chip->reg_lock, flags); 1628 spin_lock_irqsave(&chip->reg_lock, flags);
1630 for (reg = 0; reg < 32; reg++) 1629 for (reg = 0; reg < 32; reg++)
1631 chip->image[reg] = snd_wss_in(chip, reg); 1630 chip->image[reg] = snd_wss_in(chip, reg);
@@ -1943,7 +1942,7 @@ int snd_wss_pcm(struct snd_wss *chip, int device)
1943 strcpy(pcm->name, snd_wss_chip_id(chip)); 1942 strcpy(pcm->name, snd_wss_chip_id(chip));
1944 1943
1945 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1944 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1946 snd_dma_isa_data(), 1945 chip->card->dev,
1947 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); 1946 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
1948 1947
1949 chip->pcm = pcm; 1948 chip->pcm = pcm;
diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index a4ed54aeaf1d..d63e1565b62b 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -454,21 +454,22 @@ static inline void hal2_stop_adc(struct snd_hal2 *hal2)
454 hal2->adc.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD; 454 hal2->adc.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD;
455} 455}
456 456
457static int hal2_alloc_dmabuf(struct hal2_codec *codec) 457static int hal2_alloc_dmabuf(struct snd_hal2 *hal2, struct hal2_codec *codec)
458{ 458{
459 struct device *dev = hal2->card->dev;
459 struct hal2_desc *desc; 460 struct hal2_desc *desc;
460 dma_addr_t desc_dma, buffer_dma; 461 dma_addr_t desc_dma, buffer_dma;
461 int count = H2_BUF_SIZE / H2_BLOCK_SIZE; 462 int count = H2_BUF_SIZE / H2_BLOCK_SIZE;
462 int i; 463 int i;
463 464
464 codec->buffer = dma_alloc_attrs(NULL, H2_BUF_SIZE, &buffer_dma, 465 codec->buffer = dma_alloc_attrs(dev, H2_BUF_SIZE, &buffer_dma,
465 GFP_KERNEL, DMA_ATTR_NON_CONSISTENT); 466 GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
466 if (!codec->buffer) 467 if (!codec->buffer)
467 return -ENOMEM; 468 return -ENOMEM;
468 desc = dma_alloc_attrs(NULL, count * sizeof(struct hal2_desc), 469 desc = dma_alloc_attrs(dev, count * sizeof(struct hal2_desc),
469 &desc_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT); 470 &desc_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
470 if (!desc) { 471 if (!desc) {
471 dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, buffer_dma, 472 dma_free_attrs(dev, H2_BUF_SIZE, codec->buffer, buffer_dma,
472 DMA_ATTR_NON_CONSISTENT); 473 DMA_ATTR_NON_CONSISTENT);
473 return -ENOMEM; 474 return -ENOMEM;
474 } 475 }
@@ -482,17 +483,19 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
482 desc_dma : desc_dma + (i + 1) * sizeof(struct hal2_desc); 483 desc_dma : desc_dma + (i + 1) * sizeof(struct hal2_desc);
483 desc++; 484 desc++;
484 } 485 }
485 dma_cache_sync(NULL, codec->desc, count * sizeof(struct hal2_desc), 486 dma_cache_sync(dev, codec->desc, count * sizeof(struct hal2_desc),
486 DMA_TO_DEVICE); 487 DMA_TO_DEVICE);
487 codec->desc_count = count; 488 codec->desc_count = count;
488 return 0; 489 return 0;
489} 490}
490 491
491static void hal2_free_dmabuf(struct hal2_codec *codec) 492static void hal2_free_dmabuf(struct snd_hal2 *hal2, struct hal2_codec *codec)
492{ 493{
493 dma_free_attrs(NULL, codec->desc_count * sizeof(struct hal2_desc), 494 struct device *dev = hal2->card->dev;
495
496 dma_free_attrs(dev, codec->desc_count * sizeof(struct hal2_desc),
494 codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT); 497 codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT);
495 dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, codec->buffer_dma, 498 dma_free_attrs(dev, H2_BUF_SIZE, codec->buffer, codec->buffer_dma,
496 DMA_ATTR_NON_CONSISTENT); 499 DMA_ATTR_NON_CONSISTENT);
497} 500}
498 501
@@ -540,7 +543,7 @@ static int hal2_playback_open(struct snd_pcm_substream *substream)
540 543
541 runtime->hw = hal2_pcm_hw; 544 runtime->hw = hal2_pcm_hw;
542 545
543 err = hal2_alloc_dmabuf(&hal2->dac); 546 err = hal2_alloc_dmabuf(hal2, &hal2->dac);
544 if (err) 547 if (err)
545 return err; 548 return err;
546 return 0; 549 return 0;
@@ -550,7 +553,7 @@ static int hal2_playback_close(struct snd_pcm_substream *substream)
550{ 553{
551 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); 554 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream);
552 555
553 hal2_free_dmabuf(&hal2->dac); 556 hal2_free_dmabuf(hal2, &hal2->dac);
554 return 0; 557 return 0;
555} 558}
556 559
@@ -606,7 +609,7 @@ static void hal2_playback_transfer(struct snd_pcm_substream *substream,
606 unsigned char *buf = hal2->dac.buffer + rec->hw_data; 609 unsigned char *buf = hal2->dac.buffer + rec->hw_data;
607 610
608 memcpy(buf, substream->runtime->dma_area + rec->sw_data, bytes); 611 memcpy(buf, substream->runtime->dma_area + rec->sw_data, bytes);
609 dma_cache_sync(NULL, buf, bytes, DMA_TO_DEVICE); 612 dma_cache_sync(hal2->card->dev, buf, bytes, DMA_TO_DEVICE);
610 613
611} 614}
612 615
@@ -629,7 +632,7 @@ static int hal2_capture_open(struct snd_pcm_substream *substream)
629 632
630 runtime->hw = hal2_pcm_hw; 633 runtime->hw = hal2_pcm_hw;
631 634
632 err = hal2_alloc_dmabuf(adc); 635 err = hal2_alloc_dmabuf(hal2, adc);
633 if (err) 636 if (err)
634 return err; 637 return err;
635 return 0; 638 return 0;
@@ -639,7 +642,7 @@ static int hal2_capture_close(struct snd_pcm_substream *substream)
639{ 642{
640 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); 643 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream);
641 644
642 hal2_free_dmabuf(&hal2->adc); 645 hal2_free_dmabuf(hal2, &hal2->adc);
643 return 0; 646 return 0;
644} 647}
645 648
@@ -694,7 +697,7 @@ static void hal2_capture_transfer(struct snd_pcm_substream *substream,
694 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); 697 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream);
695 unsigned char *buf = hal2->adc.buffer + rec->hw_data; 698 unsigned char *buf = hal2->adc.buffer + rec->hw_data;
696 699
697 dma_cache_sync(NULL, buf, bytes, DMA_FROM_DEVICE); 700 dma_cache_sync(hal2->card->dev, buf, bytes, DMA_FROM_DEVICE);
698 memcpy(substream->runtime->dma_area + rec->sw_data, buf, bytes); 701 memcpy(substream->runtime->dma_area + rec->sw_data, buf, bytes);
699} 702}
700 703
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c
index 3ec9391a4736..53a4ee01c522 100644
--- a/sound/mips/sgio2audio.c
+++ b/sound/mips/sgio2audio.c
@@ -805,7 +805,7 @@ static int snd_sgio2audio_free(struct snd_sgio2audio *chip)
805 free_irq(snd_sgio2_isr_table[i].irq, 805 free_irq(snd_sgio2_isr_table[i].irq,
806 &chip->channel[snd_sgio2_isr_table[i].idx]); 806 &chip->channel[snd_sgio2_isr_table[i].idx]);
807 807
808 dma_free_coherent(NULL, MACEISA_RINGBUFFERS_SIZE, 808 dma_free_coherent(chip->card->dev, MACEISA_RINGBUFFERS_SIZE,
809 chip->ring_base, chip->ring_base_dma); 809 chip->ring_base, chip->ring_base_dma);
810 810
811 /* release card data */ 811 /* release card data */
@@ -843,8 +843,9 @@ static int snd_sgio2audio_create(struct snd_card *card,
843 843
844 chip->card = card; 844 chip->card = card;
845 845
846 chip->ring_base = dma_alloc_coherent(NULL, MACEISA_RINGBUFFERS_SIZE, 846 chip->ring_base = dma_alloc_coherent(card->dev,
847 &chip->ring_base_dma, GFP_USER); 847 MACEISA_RINGBUFFERS_SIZE,
848 &chip->ring_base_dma, GFP_KERNEL);
848 if (chip->ring_base == NULL) { 849 if (chip->ring_base == NULL) {
849 printk(KERN_ERR 850 printk(KERN_ERR
850 "sgio2audio: could not allocate ring buffers\n"); 851 "sgio2audio: could not allocate ring buffers\n");
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index f36e7006e00c..a4264b8943f0 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -669,14 +669,8 @@ snd_harmony_pcm_init(struct snd_harmony *h)
669 } 669 }
670 670
671 /* pre-allocate space for DMA */ 671 /* pre-allocate space for DMA */
672 err = snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, 672 snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, h->dma.dev,
673 h->dma.dev, 673 MAX_BUF_SIZE, MAX_BUF_SIZE);
674 MAX_BUF_SIZE,
675 MAX_BUF_SIZE);
676 if (err < 0) {
677 printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
678 return err;
679 }
680 674
681 h->st.format = snd_harmony_set_data_format(h, 675 h->st.format = snd_harmony_set_data_format(h,
682 SNDRV_PCM_FORMAT_S16_BE, 1); 676 SNDRV_PCM_FORMAT_S16_BE, 1);
diff --git a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c
index e120a11c69e8..20516b6907b5 100644
--- a/sound/pci/ac97/ac97_proc.c
+++ b/sound/pci/ac97/ac97_proc.c
@@ -436,25 +436,20 @@ void snd_ac97_proc_init(struct snd_ac97 * ac97)
436 return; 436 return;
437 prefix = ac97_is_audio(ac97) ? "ac97" : "mc97"; 437 prefix = ac97_is_audio(ac97) ? "ac97" : "mc97";
438 sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num); 438 sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num);
439 if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) { 439 entry = snd_info_create_card_entry(ac97->bus->card, name,
440 ac97->bus->proc);
441 if (entry)
440 snd_info_set_text_ops(entry, ac97, snd_ac97_proc_read); 442 snd_info_set_text_ops(entry, ac97, snd_ac97_proc_read);
441 if (snd_info_register(entry) < 0) {
442 snd_info_free_entry(entry);
443 entry = NULL;
444 }
445 }
446 ac97->proc = entry; 443 ac97->proc = entry;
447 sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num); 444 sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num);
448 if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) { 445 entry = snd_info_create_card_entry(ac97->bus->card, name,
446 ac97->bus->proc);
447 if (entry) {
449 snd_info_set_text_ops(entry, ac97, snd_ac97_proc_regs_read); 448 snd_info_set_text_ops(entry, ac97, snd_ac97_proc_regs_read);
450#ifdef CONFIG_SND_DEBUG 449#ifdef CONFIG_SND_DEBUG
451 entry->mode |= 0200; 450 entry->mode |= 0200;
452 entry->c.text.write = snd_ac97_proc_regs_write; 451 entry->c.text.write = snd_ac97_proc_regs_write;
453#endif 452#endif
454 if (snd_info_register(entry) < 0) {
455 snd_info_free_entry(entry);
456 entry = NULL;
457 }
458 } 453 }
459 ac97->proc_regs = entry; 454 ac97->proc_regs = entry;
460} 455}
@@ -473,13 +468,10 @@ void snd_ac97_bus_proc_init(struct snd_ac97_bus * bus)
473 char name[32]; 468 char name[32];
474 469
475 sprintf(name, "codec97#%d", bus->num); 470 sprintf(name, "codec97#%d", bus->num);
476 if ((entry = snd_info_create_card_entry(bus->card, name, bus->card->proc_root)) != NULL) { 471 entry = snd_info_create_card_entry(bus->card, name,
472 bus->card->proc_root);
473 if (entry)
477 entry->mode = S_IFDIR | 0555; 474 entry->mode = S_IFDIR | 0555;
478 if (snd_info_register(entry) < 0) {
479 snd_info_free_entry(entry);
480 entry = NULL;
481 }
482 }
483 bus->proc = entry; 475 bus->proc = entry;
484} 476}
485 477
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index d9c54c08e2db..fef07ae648e6 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -644,16 +644,11 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device)
644 chip->psubs = NULL; 644 chip->psubs = NULL;
645 chip->csubs = NULL; 645 chip->csubs = NULL;
646 646
647 err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 647 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
648 snd_dma_pci_data(chip->pci), 648 snd_dma_pci_data(chip->pci),
649 BUFFER_BYTES_MAX / 2, 649 BUFFER_BYTES_MAX / 2,
650 BUFFER_BYTES_MAX); 650 BUFFER_BYTES_MAX);
651 651
652 if (err < 0) {
653 dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
654 return err;
655 }
656
657 return 0; 652 return 0;
658} 653}
659 654
@@ -741,10 +736,8 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
741static void 736static void
742snd_ad1889_proc_init(struct snd_ad1889 *chip) 737snd_ad1889_proc_init(struct snd_ad1889 *chip)
743{ 738{
744 struct snd_info_entry *entry; 739 snd_card_ro_proc_new(chip->card, chip->card->driver,
745 740 chip, snd_ad1889_proc_read);
746 if (!snd_card_proc_new(chip->card, chip->card->driver, &entry))
747 snd_info_set_text_ops(entry, chip, snd_ad1889_proc_read);
748} 741}
749 742
750static const struct ac97_quirk ac97_quirks[] = { 743static const struct ac97_quirk ac97_quirks[] = {
diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c
index 2fb1fbba3e5e..11e902cac71b 100644
--- a/sound/pci/ak4531_codec.c
+++ b/sound/pci/ak4531_codec.c
@@ -481,8 +481,5 @@ static void snd_ak4531_proc_read(struct snd_info_entry *entry,
481static void 481static void
482snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531) 482snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531)
483{ 483{
484 struct snd_info_entry *entry; 484 snd_card_ro_proc_new(card, "ak4531", ak4531, snd_ak4531_proc_read);
485
486 if (! snd_card_proc_new(card, "ak4531", &entry))
487 snd_info_set_text_ops(entry, ak4531, snd_ak4531_proc_read);
488} 485}
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 9f569379b77e..f7fbe05836b3 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -1882,10 +1882,8 @@ static int ali_suspend(struct device *dev)
1882 return 0; 1882 return 0;
1883 1883
1884 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1884 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1885 for (i = 0; i < chip->num_of_codecs; i++) { 1885 for (i = 0; i < chip->num_of_codecs; i++)
1886 snd_pcm_suspend_all(chip->pcm[i]);
1887 snd_ac97_suspend(chip->ac97[i]); 1886 snd_ac97_suspend(chip->ac97[i]);
1888 }
1889 1887
1890 spin_lock_irq(&chip->reg_lock); 1888 spin_lock_irq(&chip->reg_lock);
1891 1889
@@ -2051,9 +2049,7 @@ static void snd_ali_proc_read(struct snd_info_entry *entry,
2051 2049
2052static void snd_ali_proc_init(struct snd_ali *codec) 2050static void snd_ali_proc_init(struct snd_ali *codec)
2053{ 2051{
2054 struct snd_info_entry *entry; 2052 snd_card_ro_proc_new(codec->card, "ali5451", codec, snd_ali_proc_read);
2055 if (!snd_card_proc_new(codec->card, "ali5451", &entry))
2056 snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
2057} 2053}
2058 2054
2059static int snd_ali_resources(struct snd_ali *codec) 2055static int snd_ali_resources(struct snd_ali *codec)
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index eaa2d853d922..516b3d9cbfdf 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -731,7 +731,6 @@ static int snd_als300_suspend(struct device *dev)
731 struct snd_als300 *chip = card->private_data; 731 struct snd_als300 *chip = card->private_data;
732 732
733 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 733 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
734 snd_pcm_suspend_all(chip->pcm);
735 snd_ac97_suspend(chip->ac97); 734 snd_ac97_suspend(chip->ac97);
736 return 0; 735 return 0;
737} 736}
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 26b097edec8c..45fa38382e79 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -994,7 +994,6 @@ static int snd_als4000_suspend(struct device *dev)
994 994
995 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 995 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
996 996
997 snd_pcm_suspend_all(chip->pcm);
998 snd_sbmixer_suspend(chip); 997 snd_sbmixer_suspend(chip);
999 return 0; 998 return 0;
1000} 999}
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index aad74e809797..32b2f9802479 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -2782,10 +2782,8 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,
2782 2782
2783static void snd_asihpi_proc_init(struct snd_card_asihpi *asihpi) 2783static void snd_asihpi_proc_init(struct snd_card_asihpi *asihpi)
2784{ 2784{
2785 struct snd_info_entry *entry; 2785 snd_card_ro_proc_new(asihpi->card, "info", asihpi,
2786 2786 snd_asihpi_proc_read);
2787 if (!snd_card_proc_new(asihpi->card, "info", &entry))
2788 snd_info_set_text_ops(entry, asihpi, snd_asihpi_proc_read);
2789} 2787}
2790 2788
2791/*------------------------------------------------------------ 2789/*------------------------------------------------------------
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 1a41f8c80243..169763c88f5e 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -733,6 +733,10 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
733 case SNDRV_PCM_TRIGGER_START: 733 case SNDRV_PCM_TRIGGER_START:
734 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 734 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
735 case SNDRV_PCM_TRIGGER_RESUME: 735 case SNDRV_PCM_TRIGGER_RESUME:
736 if (dma->running && dma->suspended &&
737 cmd == SNDRV_PCM_TRIGGER_RESUME)
738 writel(dma->saved_curptr, chip->remap_addr +
739 dma->ops->dt_cur);
736 dma->ops->enable_transfer(chip, 1); 740 dma->ops->enable_transfer(chip, 1);
737 dma->running = 1; 741 dma->running = 1;
738 dma->suspended = 0; 742 dma->suspended = 0;
@@ -740,9 +744,12 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
740 case SNDRV_PCM_TRIGGER_STOP: 744 case SNDRV_PCM_TRIGGER_STOP:
741 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 745 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
742 case SNDRV_PCM_TRIGGER_SUSPEND: 746 case SNDRV_PCM_TRIGGER_SUSPEND:
747 dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;
748 if (dma->running && dma->suspended)
749 dma->saved_curptr = readl(chip->remap_addr +
750 dma->ops->dt_cur);
743 dma->ops->enable_transfer(chip, 0); 751 dma->ops->enable_transfer(chip, 0);
744 dma->running = 0; 752 dma->running = 0;
745 dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;
746 break; 753 break;
747 default: 754 default:
748 err = -EINVAL; 755 err = -EINVAL;
@@ -1479,14 +1486,6 @@ static int snd_atiixp_suspend(struct device *dev)
1479 int i; 1486 int i;
1480 1487
1481 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1488 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1482 for (i = 0; i < NUM_ATI_PCMDEVS; i++)
1483 if (chip->pcmdevs[i]) {
1484 struct atiixp_dma *dma = &chip->dmas[i];
1485 if (dma->substream && dma->running)
1486 dma->saved_curptr = readl(chip->remap_addr +
1487 dma->ops->dt_cur);
1488 snd_pcm_suspend_all(chip->pcmdevs[i]);
1489 }
1490 for (i = 0; i < NUM_ATI_CODECS; i++) 1489 for (i = 0; i < NUM_ATI_CODECS; i++)
1491 snd_ac97_suspend(chip->ac97[i]); 1490 snd_ac97_suspend(chip->ac97[i]);
1492 snd_atiixp_aclink_down(chip); 1491 snd_atiixp_aclink_down(chip);
@@ -1514,8 +1513,6 @@ static int snd_atiixp_resume(struct device *dev)
1514 dma->substream->ops->prepare(dma->substream); 1513 dma->substream->ops->prepare(dma->substream);
1515 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 1514 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,
1516 chip->remap_addr + dma->ops->llp_offset); 1515 chip->remap_addr + dma->ops->llp_offset);
1517 writel(dma->saved_curptr, chip->remap_addr +
1518 dma->ops->dt_cur);
1519 } 1516 }
1520 } 1517 }
1521 1518
@@ -1546,10 +1543,7 @@ static void snd_atiixp_proc_read(struct snd_info_entry *entry,
1546 1543
1547static void snd_atiixp_proc_init(struct atiixp *chip) 1544static void snd_atiixp_proc_init(struct atiixp *chip)
1548{ 1545{
1549 struct snd_info_entry *entry; 1546 snd_card_ro_proc_new(chip->card, "atiixp", chip, snd_atiixp_proc_read);
1550
1551 if (! snd_card_proc_new(chip->card, "atiixp", &entry))
1552 snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read);
1553} 1547}
1554 1548
1555 1549
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index dc1de860cedf..cece66bb3644 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1125,8 +1125,6 @@ static int snd_atiixp_suspend(struct device *dev)
1125 int i; 1125 int i;
1126 1126
1127 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1127 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1128 for (i = 0; i < NUM_ATI_PCMDEVS; i++)
1129 snd_pcm_suspend_all(chip->pcmdevs[i]);
1130 for (i = 0; i < NUM_ATI_CODECS; i++) 1128 for (i = 0; i < NUM_ATI_CODECS; i++)
1131 snd_ac97_suspend(chip->ac97[i]); 1129 snd_ac97_suspend(chip->ac97[i]);
1132 snd_atiixp_aclink_down(chip); 1130 snd_atiixp_aclink_down(chip);
@@ -1172,10 +1170,8 @@ static void snd_atiixp_proc_read(struct snd_info_entry *entry,
1172 1170
1173static void snd_atiixp_proc_init(struct atiixp_modem *chip) 1171static void snd_atiixp_proc_init(struct atiixp_modem *chip)
1174{ 1172{
1175 struct snd_info_entry *entry; 1173 snd_card_ro_proc_new(chip->card, "atiixp-modem", chip,
1176 1174 snd_atiixp_proc_read);
1177 if (! snd_card_proc_new(chip->card, "atiixp-modem", &entry))
1178 snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read);
1179} 1175}
1180 1176
1181 1177
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index 9a49e4243a9c..b07c5fc1da56 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -624,15 +624,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
624 624
625 /* pre-allocation of buffers */ 625 /* pre-allocation of buffers */
626 /* Preallocate continuous pages. */ 626 /* Preallocate continuous pages. */
627 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana, 627 snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
628 SNDRV_DMA_TYPE_DEV, 628 SNDRV_DMA_TYPE_DEV,
629 snd_dma_pci_data 629 snd_dma_pci_data(chip->pci),
630 (chip->pci), 630 64 * 1024, 64 * 1024);
631 64 * 1024, 64 * 1024);
632 if (err)
633 dev_err(chip->card->dev,
634 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
635 err);
636 631
637 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, 632 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
638 &pcm_playback_num); 633 &pcm_playback_num);
@@ -661,15 +656,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
661 656
662 /* pre-allocation of buffers */ 657 /* pre-allocation of buffers */
663 /* Preallocate continuous pages. */ 658 /* Preallocate continuous pages. */
664 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num, 659 snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
665 SNDRV_DMA_TYPE_DEV, 660 SNDRV_DMA_TYPE_DEV,
666 snd_dma_pci_data 661 snd_dma_pci_data(chip->pci),
667 (chip->pci), 662 64 * 1024, 64 * 1024);
668 64 * 1024, 64 * 1024);
669 if (err)
670 dev_err(chip->card->dev,
671 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
672 err);
673 663
674 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, 664 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
675 &pcm_capture); 665 &pcm_capture);
@@ -699,16 +689,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
699 689
700 /* pre-allocation of buffers */ 690 /* pre-allocation of buffers */
701 /* Preallocate continuous pages. */ 691 /* Preallocate continuous pages. */
702 err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture, 692 snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
703 SNDRV_DMA_TYPE_DEV, 693 SNDRV_DMA_TYPE_DEV,
704 snd_dma_pci_data 694 snd_dma_pci_data(chip->pci),
705 (chip->pci), 695 64 * 1024, 64 * 1024);
706 64 * 1024, 64 * 1024);
707 if (err)
708 dev_err(chip->card->dev,
709 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
710 err);
711
712 696
713 /* Create control */ 697 /* Create control */
714 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip)); 698 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index fc18c29a8173..90348817f096 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -2699,10 +2699,6 @@ snd_azf3328_suspend(struct device *dev)
2699 2699
2700 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2700 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2701 2701
2702 /* same pcm object for playback/capture */
2703 snd_pcm_suspend_all(chip->pcm[AZF_CODEC_PLAYBACK]);
2704 snd_pcm_suspend_all(chip->pcm[AZF_CODEC_I2S_OUT]);
2705
2706 snd_azf3328_suspend_ac97(chip); 2702 snd_azf3328_suspend_ac97(chip);
2707 2703
2708 snd_azf3328_suspend_regs(chip, chip->ctrl_io, 2704 snd_azf3328_suspend_regs(chip, chip->ctrl_io,
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index ba971042f871..0adcba10c067 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -714,11 +714,11 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name)
714 pcm->private_data = chip; 714 pcm->private_data = chip;
715 strcpy(pcm->name, name); 715 strcpy(pcm->name, name);
716 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); 716 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops);
717 return snd_pcm_lib_preallocate_pages_for_all(pcm, 717 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
718 SNDRV_DMA_TYPE_DEV_SG, 718 snd_dma_pci_data(chip->pci),
719 snd_dma_pci_data(chip->pci), 719 128 * 1024,
720 128 * 1024, 720 ALIGN(255 * 4092, 1024));
721 ALIGN(255 * 4092, 1024)); 721 return 0;
722} 722}
723 723
724static int snd_bt87x_create(struct snd_card *card, 724static int snd_bt87x_create(struct snd_card *card,
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index cd27b5536654..11ef0d636405 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1402,21 +1402,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
1402 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 1402 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
1403 substream; 1403 substream;
1404 substream = substream->next) { 1404 substream = substream->next) {
1405 if ((err = snd_pcm_lib_preallocate_pages(substream, 1405 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
1406 SNDRV_DMA_TYPE_DEV, 1406 snd_dma_pci_data(emu->pci),
1407 snd_dma_pci_data(emu->pci), 1407 64*1024, 64*1024);
1408 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */
1409 return err;
1410 } 1408 }
1411 1409
1412 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 1410 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
1413 substream; 1411 substream;
1414 substream = substream->next) { 1412 substream = substream->next) {
1415 if ((err = snd_pcm_lib_preallocate_pages(substream, 1413 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
1416 SNDRV_DMA_TYPE_DEV, 1414 snd_dma_pci_data(emu->pci),
1417 snd_dma_pci_data(emu->pci), 1415 64*1024, 64*1024);
1418 64*1024, 64*1024)) < 0)
1419 return err;
1420 } 1416 }
1421 1417
1422 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, 1418 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2,
@@ -1910,11 +1906,8 @@ static int snd_ca0106_suspend(struct device *dev)
1910{ 1906{
1911 struct snd_card *card = dev_get_drvdata(dev); 1907 struct snd_card *card = dev_get_drvdata(dev);
1912 struct snd_ca0106 *chip = card->private_data; 1908 struct snd_ca0106 *chip = card->private_data;
1913 int i;
1914 1909
1915 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1910 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1916 for (i = 0; i < 4; i++)
1917 snd_pcm_suspend_all(chip->pcm[i]);
1918 if (chip->details->ac97) 1911 if (chip->details->ac97)
1919 snd_ac97_suspend(chip->ac97); 1912 snd_ac97_suspend(chip->ac97);
1920 snd_ca0106_mixer_suspend(chip); 1913 snd_ca0106_mixer_suspend(chip);
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c
index a2c85cc37972..f5b8934db735 100644
--- a/sound/pci/ca0106/ca0106_proc.c
+++ b/sound/pci/ca0106/ca0106_proc.c
@@ -424,30 +424,20 @@ static void snd_ca0106_proc_i2c_write(struct snd_info_entry *entry,
424 424
425int snd_ca0106_proc_init(struct snd_ca0106 *emu) 425int snd_ca0106_proc_init(struct snd_ca0106 *emu)
426{ 426{
427 struct snd_info_entry *entry; 427 snd_card_ro_proc_new(emu->card, "iec958", emu, snd_ca0106_proc_iec958);
428 428 snd_card_rw_proc_new(emu->card, "ca0106_reg32", emu,
429 if(! snd_card_proc_new(emu->card, "iec958", &entry)) 429 snd_ca0106_proc_reg_read32,
430 snd_info_set_text_ops(entry, emu, snd_ca0106_proc_iec958); 430 snd_ca0106_proc_reg_write32);
431 if(! snd_card_proc_new(emu->card, "ca0106_reg32", &entry)) { 431 snd_card_ro_proc_new(emu->card, "ca0106_reg16", emu,
432 snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read32); 432 snd_ca0106_proc_reg_read16);
433 entry->c.text.write = snd_ca0106_proc_reg_write32; 433 snd_card_ro_proc_new(emu->card, "ca0106_reg8", emu,
434 entry->mode |= 0200; 434 snd_ca0106_proc_reg_read8);
435 } 435 snd_card_rw_proc_new(emu->card, "ca0106_regs1", emu,
436 if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry)) 436 snd_ca0106_proc_reg_read1,
437 snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read16); 437 snd_ca0106_proc_reg_write);
438 if(! snd_card_proc_new(emu->card, "ca0106_reg8", &entry)) 438 snd_card_rw_proc_new(emu->card, "ca0106_i2c", emu, NULL,
439 snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read8); 439 snd_ca0106_proc_i2c_write);
440 if(! snd_card_proc_new(emu->card, "ca0106_regs1", &entry)) { 440 snd_card_ro_proc_new(emu->card, "ca0106_regs2", emu,
441 snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read1); 441 snd_ca0106_proc_reg_read2);
442 entry->c.text.write = snd_ca0106_proc_reg_write;
443 entry->mode |= 0200;
444 }
445 if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) {
446 entry->c.text.write = snd_ca0106_proc_i2c_write;
447 entry->private_data = emu;
448 entry->mode |= 0200;
449 }
450 if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry))
451 snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read2);
452 return 0; 442 return 0;
453} 443}
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 452cc79b44af..701be04aed53 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2792,10 +2792,7 @@ static void snd_cmipci_proc_read(struct snd_info_entry *entry,
2792 2792
2793static void snd_cmipci_proc_init(struct cmipci *cm) 2793static void snd_cmipci_proc_init(struct cmipci *cm)
2794{ 2794{
2795 struct snd_info_entry *entry; 2795 snd_card_ro_proc_new(cm->card, "cmipci", cm, snd_cmipci_proc_read);
2796
2797 if (! snd_card_proc_new(cm->card, "cmipci", &entry))
2798 snd_info_set_text_ops(entry, cm, snd_cmipci_proc_read);
2799} 2796}
2800 2797
2801static const struct pci_device_id snd_cmipci_ids[] = { 2798static const struct pci_device_id snd_cmipci_ids[] = {
@@ -3351,10 +3348,6 @@ static int snd_cmipci_suspend(struct device *dev)
3351 3348
3352 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3349 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3353 3350
3354 snd_pcm_suspend_all(cm->pcm);
3355 snd_pcm_suspend_all(cm->pcm2);
3356 snd_pcm_suspend_all(cm->pcm_spdif);
3357
3358 /* save registers */ 3351 /* save registers */
3359 for (i = 0; i < ARRAY_SIZE(saved_regs); i++) 3352 for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
3360 cm->saved_regs[i] = snd_cmipci_read(cm, saved_regs[i]); 3353 cm->saved_regs[i] = snd_cmipci_read(cm, saved_regs[i]);
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index ec4247638fa1..15bbf9564c82 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -1174,8 +1174,7 @@ static void snd_cs4281_proc_init(struct cs4281 *chip)
1174{ 1174{
1175 struct snd_info_entry *entry; 1175 struct snd_info_entry *entry;
1176 1176
1177 if (! snd_card_proc_new(chip->card, "cs4281", &entry)) 1177 snd_card_ro_proc_new(chip->card, "cs4281", chip, snd_cs4281_proc_read);
1178 snd_info_set_text_ops(entry, chip, snd_cs4281_proc_read);
1179 if (! snd_card_proc_new(chip->card, "cs4281_BA0", &entry)) { 1178 if (! snd_card_proc_new(chip->card, "cs4281_BA0", &entry)) {
1180 entry->content = SNDRV_INFO_CONTENT_DATA; 1179 entry->content = SNDRV_INFO_CONTENT_DATA;
1181 entry->private_data = chip; 1180 entry->private_data = chip;
@@ -2002,8 +2001,6 @@ static int cs4281_suspend(struct device *dev)
2002 unsigned int i; 2001 unsigned int i;
2003 2002
2004 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2003 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2005 snd_pcm_suspend_all(chip->pcm);
2006
2007 snd_ac97_suspend(chip->ac97); 2004 snd_ac97_suspend(chip->ac97);
2008 snd_ac97_suspend(chip->ac97_secondary); 2005 snd_ac97_suspend(chip->ac97_secondary);
2009 2006
diff --git a/sound/pci/cs46xx/cs46xx_dsp_spos.h b/sound/pci/cs46xx/cs46xx_dsp_spos.h
index 8008c59288a6..a02e1e19c021 100644
--- a/sound/pci/cs46xx/cs46xx_dsp_spos.h
+++ b/sound/pci/cs46xx/cs46xx_dsp_spos.h
@@ -177,22 +177,16 @@ struct dsp_spos_instance {
177 /* proc fs */ 177 /* proc fs */
178 struct snd_card *snd_card; 178 struct snd_card *snd_card;
179 struct snd_info_entry * proc_dsp_dir; 179 struct snd_info_entry * proc_dsp_dir;
180 struct snd_info_entry * proc_sym_info_entry;
181 struct snd_info_entry * proc_modules_info_entry;
182 struct snd_info_entry * proc_parameter_dump_info_entry;
183 struct snd_info_entry * proc_sample_dump_info_entry;
184 180
185 /* SCB's descriptors */ 181 /* SCB's descriptors */
186 int nscb; 182 int nscb;
187 int scb_highest_frag_index; 183 int scb_highest_frag_index;
188 struct dsp_scb_descriptor scbs[DSP_MAX_SCB_DESC]; 184 struct dsp_scb_descriptor scbs[DSP_MAX_SCB_DESC];
189 struct snd_info_entry * proc_scb_info_entry;
190 struct dsp_scb_descriptor * the_null_scb; 185 struct dsp_scb_descriptor * the_null_scb;
191 186
192 /* Task's descriptors */ 187 /* Task's descriptors */
193 int ntask; 188 int ntask;
194 struct dsp_task_descriptor tasks[DSP_MAX_TASK_DESC]; 189 struct dsp_task_descriptor tasks[DSP_MAX_TASK_DESC];
195 struct snd_info_entry * proc_task_info_entry;
196 190
197 /* SPDIF status */ 191 /* SPDIF status */
198 int spdif_status_out; 192 int spdif_status_out;
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 750eec437a79..a77d4cc44028 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3781,12 +3781,6 @@ static int snd_cs46xx_suspend(struct device *dev)
3781 3781
3782 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3782 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3783 chip->in_suspend = 1; 3783 chip->in_suspend = 1;
3784 snd_pcm_suspend_all(chip->pcm);
3785#ifdef CONFIG_SND_CS46XX_NEW_DSP
3786 snd_pcm_suspend_all(chip->pcm_rear);
3787 snd_pcm_suspend_all(chip->pcm_center_lfe);
3788 snd_pcm_suspend_all(chip->pcm_iec958);
3789#endif
3790 // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); 3784 // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL);
3791 // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); 3785 // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE);
3792 3786
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 5fc497c6d738..c28e58602679 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -799,92 +799,49 @@ int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip)
799 799
800 ins->snd_card = card; 800 ins->snd_card = card;
801 801
802 if ((entry = snd_info_create_card_entry(card, "dsp", card->proc_root)) != NULL) { 802 entry = snd_info_create_card_entry(card, "dsp", card->proc_root);
803 entry->content = SNDRV_INFO_CONTENT_TEXT; 803 if (entry)
804 entry->mode = S_IFDIR | 0555; 804 entry->mode = S_IFDIR | 0555;
805
806 if (snd_info_register(entry) < 0) {
807 snd_info_free_entry(entry);
808 entry = NULL;
809 }
810 }
811
812 ins->proc_dsp_dir = entry; 805 ins->proc_dsp_dir = entry;
813 806
814 if (!ins->proc_dsp_dir) 807 if (!ins->proc_dsp_dir)
815 return -ENOMEM; 808 return -ENOMEM;
816 809
817 if ((entry = snd_info_create_card_entry(card, "spos_symbols", ins->proc_dsp_dir)) != NULL) { 810 entry = snd_info_create_card_entry(card, "spos_symbols",
818 entry->content = SNDRV_INFO_CONTENT_TEXT; 811 ins->proc_dsp_dir);
819 entry->private_data = chip; 812 if (entry)
820 entry->mode = S_IFREG | 0644; 813 snd_info_set_text_ops(entry, chip,
821 entry->c.text.read = cs46xx_dsp_proc_symbol_table_read; 814 cs46xx_dsp_proc_symbol_table_read);
822 if (snd_info_register(entry) < 0) {
823 snd_info_free_entry(entry);
824 entry = NULL;
825 }
826 }
827 ins->proc_sym_info_entry = entry;
828 815
829 if ((entry = snd_info_create_card_entry(card, "spos_modules", ins->proc_dsp_dir)) != NULL) { 816 entry = snd_info_create_card_entry(card, "spos_modules",
830 entry->content = SNDRV_INFO_CONTENT_TEXT; 817 ins->proc_dsp_dir);
831 entry->private_data = chip; 818 if (entry)
832 entry->mode = S_IFREG | 0644; 819 snd_info_set_text_ops(entry, chip,
833 entry->c.text.read = cs46xx_dsp_proc_modules_read; 820 cs46xx_dsp_proc_modules_read);
834 if (snd_info_register(entry) < 0) { 821
835 snd_info_free_entry(entry); 822 entry = snd_info_create_card_entry(card, "parameter",
836 entry = NULL; 823 ins->proc_dsp_dir);
837 } 824 if (entry)
838 } 825 snd_info_set_text_ops(entry, chip,
839 ins->proc_modules_info_entry = entry; 826 cs46xx_dsp_proc_parameter_dump_read);
840 827
841 if ((entry = snd_info_create_card_entry(card, "parameter", ins->proc_dsp_dir)) != NULL) { 828 entry = snd_info_create_card_entry(card, "sample",
842 entry->content = SNDRV_INFO_CONTENT_TEXT; 829 ins->proc_dsp_dir);
843 entry->private_data = chip; 830 if (entry)
844 entry->mode = S_IFREG | 0644; 831 snd_info_set_text_ops(entry, chip,
845 entry->c.text.read = cs46xx_dsp_proc_parameter_dump_read; 832 cs46xx_dsp_proc_sample_dump_read);
846 if (snd_info_register(entry) < 0) { 833
847 snd_info_free_entry(entry); 834 entry = snd_info_create_card_entry(card, "task_tree",
848 entry = NULL; 835 ins->proc_dsp_dir);
849 } 836 if (entry)
850 } 837 snd_info_set_text_ops(entry, chip,
851 ins->proc_parameter_dump_info_entry = entry; 838 cs46xx_dsp_proc_task_tree_read);
852 839
853 if ((entry = snd_info_create_card_entry(card, "sample", ins->proc_dsp_dir)) != NULL) { 840 entry = snd_info_create_card_entry(card, "scb_info",
854 entry->content = SNDRV_INFO_CONTENT_TEXT; 841 ins->proc_dsp_dir);
855 entry->private_data = chip; 842 if (entry)
856 entry->mode = S_IFREG | 0644; 843 snd_info_set_text_ops(entry, chip,
857 entry->c.text.read = cs46xx_dsp_proc_sample_dump_read; 844 cs46xx_dsp_proc_scb_read);
858 if (snd_info_register(entry) < 0) {
859 snd_info_free_entry(entry);
860 entry = NULL;
861 }
862 }
863 ins->proc_sample_dump_info_entry = entry;
864
865 if ((entry = snd_info_create_card_entry(card, "task_tree", ins->proc_dsp_dir)) != NULL) {
866 entry->content = SNDRV_INFO_CONTENT_TEXT;
867 entry->private_data = chip;
868 entry->mode = S_IFREG | 0644;
869 entry->c.text.read = cs46xx_dsp_proc_task_tree_read;
870 if (snd_info_register(entry) < 0) {
871 snd_info_free_entry(entry);
872 entry = NULL;
873 }
874 }
875 ins->proc_task_info_entry = entry;
876
877 if ((entry = snd_info_create_card_entry(card, "scb_info", ins->proc_dsp_dir)) != NULL) {
878 entry->content = SNDRV_INFO_CONTENT_TEXT;
879 entry->private_data = chip;
880 entry->mode = S_IFREG | 0644;
881 entry->c.text.read = cs46xx_dsp_proc_scb_read;
882 if (snd_info_register(entry) < 0) {
883 snd_info_free_entry(entry);
884 entry = NULL;
885 }
886 }
887 ins->proc_scb_info_entry = entry;
888 845
889 mutex_lock(&chip->spos_mutex); 846 mutex_lock(&chip->spos_mutex);
890 /* register/update SCB's entries on proc */ 847 /* register/update SCB's entries on proc */
@@ -906,24 +863,6 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
906 if (!ins) 863 if (!ins)
907 return 0; 864 return 0;
908 865
909 snd_info_free_entry(ins->proc_sym_info_entry);
910 ins->proc_sym_info_entry = NULL;
911
912 snd_info_free_entry(ins->proc_modules_info_entry);
913 ins->proc_modules_info_entry = NULL;
914
915 snd_info_free_entry(ins->proc_parameter_dump_info_entry);
916 ins->proc_parameter_dump_info_entry = NULL;
917
918 snd_info_free_entry(ins->proc_sample_dump_info_entry);
919 ins->proc_sample_dump_info_entry = NULL;
920
921 snd_info_free_entry(ins->proc_scb_info_entry);
922 ins->proc_scb_info_entry = NULL;
923
924 snd_info_free_entry(ins->proc_task_info_entry);
925 ins->proc_task_info_entry = NULL;
926
927 mutex_lock(&chip->spos_mutex); 866 mutex_lock(&chip->spos_mutex);
928 for (i = 0; i < ins->nscb; ++i) { 867 for (i = 0; i < ins->nscb; ++i) {
929 if (ins->scbs[i].deleted) continue; 868 if (ins->scbs[i].deleted) continue;
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 8d0a3d357345..1d9d610262de 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -254,8 +254,9 @@ void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
254 if (ins->snd_card != NULL && ins->proc_dsp_dir != NULL && 254 if (ins->snd_card != NULL && ins->proc_dsp_dir != NULL &&
255 scb->proc_info == NULL) { 255 scb->proc_info == NULL) {
256 256
257 if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name, 257 entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
258 ins->proc_dsp_dir)) != NULL) { 258 ins->proc_dsp_dir);
259 if (entry) {
259 scb_info = kmalloc(sizeof(struct proc_scb_info), GFP_KERNEL); 260 scb_info = kmalloc(sizeof(struct proc_scb_info), GFP_KERNEL);
260 if (!scb_info) { 261 if (!scb_info) {
261 snd_info_free_entry(entry); 262 snd_info_free_entry(entry);
@@ -265,18 +266,8 @@ void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
265 266
266 scb_info->chip = chip; 267 scb_info->chip = chip;
267 scb_info->scb_desc = scb; 268 scb_info->scb_desc = scb;
268 269 snd_info_set_text_ops(entry, scb_info,
269 entry->content = SNDRV_INFO_CONTENT_TEXT; 270 cs46xx_dsp_proc_scb_info_read);
270 entry->private_data = scb_info;
271 entry->mode = S_IFREG | 0644;
272
273 entry->c.text.read = cs46xx_dsp_proc_scb_info_read;
274
275 if (snd_info_register(entry) < 0) {
276 snd_info_free_entry(entry);
277 kfree (scb_info);
278 entry = NULL;
279 }
280 } 271 }
281out: 272out:
282 scb->proc_info = entry; 273 scb->proc_info = entry;
diff --git a/sound/pci/cs5535audio/cs5535audio_pm.c b/sound/pci/cs5535audio/cs5535audio_pm.c
index 82bd10b68a77..446ef1f1b45a 100644
--- a/sound/pci/cs5535audio/cs5535audio_pm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pm.c
@@ -62,7 +62,6 @@ static int __maybe_unused snd_cs5535audio_suspend(struct device *dev)
62 int i; 62 int i;
63 63
64 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 64 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
65 snd_pcm_suspend_all(cs5535au->pcm);
66 snd_ac97_suspend(cs5535au->ac97); 65 snd_ac97_suspend(cs5535au->ac97);
67 for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) { 66 for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
68 struct cs5535audio_dma *dma = &cs5535au->dmas[i]; 67 struct cs5535audio_dma *dma = &cs5535au->dmas[i];
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 2ada8444abd9..e622613ea947 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1548,18 +1548,10 @@ static void atc_connect_resources(struct ct_atc *atc)
1548#ifdef CONFIG_PM_SLEEP 1548#ifdef CONFIG_PM_SLEEP
1549static int atc_suspend(struct ct_atc *atc) 1549static int atc_suspend(struct ct_atc *atc)
1550{ 1550{
1551 int i;
1552 struct hw *hw = atc->hw; 1551 struct hw *hw = atc->hw;
1553 1552
1554 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D3hot); 1553 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D3hot);
1555 1554
1556 for (i = FRONT; i < NUM_PCMS; i++) {
1557 if (!atc->pcms[i])
1558 continue;
1559
1560 snd_pcm_suspend_all(atc->pcms[i]);
1561 }
1562
1563 atc_release_resources(atc); 1555 atc_release_resources(atc);
1564 1556
1565 hw->suspend(hw); 1557 hw->suspend(hw);
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 907cf1a46712..ea876b0b02b9 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -884,17 +884,15 @@ static const struct snd_pcm_ops digital_capture_ops = {
884static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev) 884static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
885{ 885{
886 struct snd_pcm_substream *ss; 886 struct snd_pcm_substream *ss;
887 int stream, err; 887 int stream;
888 888
889 for (stream = 0; stream < 2; stream++) 889 for (stream = 0; stream < 2; stream++)
890 for (ss = pcm->streams[stream].substream; ss; ss = ss->next) { 890 for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
891 err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG, 891 snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
892 dev, 892 dev,
893 ss->number ? 0 : 128<<10, 893 ss->number ? 0 : 128<<10,
894 256<<10); 894 256<<10);
895 if (err < 0) 895
896 return err;
897 }
898 return 0; 896 return 0;
899} 897}
900 898
@@ -2165,9 +2163,6 @@ static int snd_echo_suspend(struct device *dev)
2165{ 2163{
2166 struct echoaudio *chip = dev_get_drvdata(dev); 2164 struct echoaudio *chip = dev_get_drvdata(dev);
2167 2165
2168 snd_pcm_suspend_all(chip->analog_pcm);
2169 snd_pcm_suspend_all(chip->digital_pcm);
2170
2171#ifdef ECHOCARD_HAS_MIDI 2166#ifdef ECHOCARD_HAS_MIDI
2172 /* This call can sleep */ 2167 /* This call can sleep */
2173 if (chip->midi_out) 2168 if (chip->midi_out)
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index d3203df50a1a..3c41a0edcfb0 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -224,12 +224,6 @@ static int snd_emu10k1_suspend(struct device *dev)
224 224
225 cancel_delayed_work_sync(&emu->emu1010.firmware_work); 225 cancel_delayed_work_sync(&emu->emu1010.firmware_work);
226 226
227 snd_pcm_suspend_all(emu->pcm);
228 snd_pcm_suspend_all(emu->pcm_mic);
229 snd_pcm_suspend_all(emu->pcm_efx);
230 snd_pcm_suspend_all(emu->pcm_multi);
231 snd_pcm_suspend_all(emu->pcm_p16v);
232
233 snd_ac97_suspend(emu->ac97); 227 snd_ac97_suspend(emu->ac97);
234 228
235 snd_emu10k1_efx_suspend(emu); 229 snd_emu10k1_efx_suspend(emu);
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 611589cbdad6..576c7bd03a1a 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -1065,15 +1065,9 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,
1065 1065
1066static int snd_emu10k1x_proc_init(struct emu10k1x *emu) 1066static int snd_emu10k1x_proc_init(struct emu10k1x *emu)
1067{ 1067{
1068 struct snd_info_entry *entry; 1068 snd_card_rw_proc_new(emu->card, "emu10k1x_regs", emu,
1069 1069 snd_emu10k1x_proc_reg_read,
1070 if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { 1070 snd_emu10k1x_proc_reg_write);
1071 snd_info_set_text_ops(entry, emu, snd_emu10k1x_proc_reg_read);
1072 entry->c.text.write = snd_emu10k1x_proc_reg_write;
1073 entry->mode |= 0200;
1074 entry->private_data = emu;
1075 }
1076
1077 return 0; 1071 return 0;
1078} 1072}
1079 1073
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index 30b3472d0b75..f6b4cb9ac75c 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1427,11 +1427,14 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device)
1427 emu->pcm = pcm; 1427 emu->pcm = pcm;
1428 1428
1429 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1429 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1430 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1430 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
1431 return err; 1431 snd_dma_pci_data(emu->pci),
1432 64*1024, 64*1024);
1432 1433
1433 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) 1434 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next)
1434 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1435 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
1436 snd_dma_pci_data(emu->pci),
1437 64*1024, 64*1024);
1435 1438
1436 return 0; 1439 return 0;
1437} 1440}
@@ -1455,8 +1458,9 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device)
1455 emu->pcm_multi = pcm; 1458 emu->pcm_multi = pcm;
1456 1459
1457 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1460 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1458 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1461 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
1459 return err; 1462 snd_dma_pci_data(emu->pci),
1463 64*1024, 64*1024);
1460 1464
1461 return 0; 1465 return 0;
1462} 1466}
@@ -1489,7 +1493,9 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device)
1489 strcpy(pcm->name, "Mic Capture"); 1493 strcpy(pcm->name, "Mic Capture");
1490 emu->pcm_mic = pcm; 1494 emu->pcm_mic = pcm;
1491 1495
1492 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1496 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1497 snd_dma_pci_data(emu->pci),
1498 64*1024, 64*1024);
1493 1499
1494 return 0; 1500 return 0;
1495} 1501}
@@ -1862,7 +1868,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
1862 if (err < 0) 1868 if (err < 0)
1863 return err; 1869 return err;
1864 1870
1865 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1871 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1872 snd_dma_pci_data(emu->pci),
1873 64*1024, 64*1024);
1866 1874
1867 return 0; 1875 return 0;
1868} 1876}
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
index b57008031792..a3d9f06e8e6a 100644
--- a/sound/pci/emu10k1/emuproc.c
+++ b/sound/pci/emu10k1/emuproc.c
@@ -568,55 +568,40 @@ int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
568 struct snd_info_entry *entry; 568 struct snd_info_entry *entry;
569#ifdef CONFIG_SND_DEBUG 569#ifdef CONFIG_SND_DEBUG
570 if (emu->card_capabilities->emu_model) { 570 if (emu->card_capabilities->emu_model) {
571 if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry)) 571 snd_card_ro_proc_new(emu->card, "emu1010_regs",
572 snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read); 572 emu, snd_emu_proc_emu1010_reg_read);
573 }
574 if (! snd_card_proc_new(emu->card, "io_regs", &entry)) {
575 snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
576 entry->c.text.write = snd_emu_proc_io_reg_write;
577 entry->mode |= 0200;
578 }
579 if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) {
580 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a);
581 entry->c.text.write = snd_emu_proc_ptr_reg_write00;
582 entry->mode |= 0200;
583 }
584 if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) {
585 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b);
586 entry->c.text.write = snd_emu_proc_ptr_reg_write00;
587 entry->mode |= 0200;
588 }
589 if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) {
590 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a);
591 entry->c.text.write = snd_emu_proc_ptr_reg_write20;
592 entry->mode |= 0200;
593 }
594 if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) {
595 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b);
596 entry->c.text.write = snd_emu_proc_ptr_reg_write20;
597 entry->mode |= 0200;
598 }
599 if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) {
600 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c);
601 entry->c.text.write = snd_emu_proc_ptr_reg_write20;
602 entry->mode |= 0200;
603 } 573 }
574 snd_card_rw_proc_new(emu->card, "io_regs", emu,
575 snd_emu_proc_io_reg_read,
576 snd_emu_proc_io_reg_write);
577 snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
578 snd_emu_proc_ptr_reg_read00a,
579 snd_emu_proc_ptr_reg_write00);
580 snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
581 snd_emu_proc_ptr_reg_read00b,
582 snd_emu_proc_ptr_reg_write00);
583 snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
584 snd_emu_proc_ptr_reg_read20a,
585 snd_emu_proc_ptr_reg_write20);
586 snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
587 snd_emu_proc_ptr_reg_read20b,
588 snd_emu_proc_ptr_reg_write20);
589 snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
590 snd_emu_proc_ptr_reg_read20c,
591 snd_emu_proc_ptr_reg_write20);
604#endif 592#endif
605 593
606 if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) 594 snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);
607 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read);
608 595
609 if (emu->card_capabilities->emu10k2_chip) { 596 if (emu->card_capabilities->emu10k2_chip)
610 if (! snd_card_proc_new(emu->card, "spdif-in", &entry)) 597 snd_card_ro_proc_new(emu->card, "spdif-in", emu,
611 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read); 598 snd_emu10k1_proc_spdif_read);
612 } 599 if (emu->card_capabilities->ca0151_chip)
613 if (emu->card_capabilities->ca0151_chip) { 600 snd_card_ro_proc_new(emu->card, "capture-rates", emu,
614 if (! snd_card_proc_new(emu->card, "capture-rates", &entry)) 601 snd_emu10k1_proc_rates_read);
615 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read);
616 }
617 602
618 if (! snd_card_proc_new(emu->card, "voices", &entry)) 603 snd_card_ro_proc_new(emu->card, "voices", emu,
619 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read); 604 snd_emu10k1_proc_voices_read);
620 605
621 if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) { 606 if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
622 entry->content = SNDRV_INFO_CONTENT_DATA; 607 entry->content = SNDRV_INFO_CONTENT_DATA;
@@ -646,11 +631,7 @@ int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
646 entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE; 631 entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
647 entry->c.ops = &snd_emu10k1_proc_ops_fx8010; 632 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
648 } 633 }
649 if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) { 634 snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
650 entry->content = SNDRV_INFO_CONTENT_TEXT; 635 snd_emu10k1_proc_acode_read);
651 entry->private_data = emu;
652 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
653 entry->c.text.read = snd_emu10k1_proc_acode_read;
654 }
655 return 0; 636 return 0;
656} 637}
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 4948b95f6665..672017cac4c7 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -656,11 +656,10 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
656 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 656 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
657 substream; 657 substream;
658 substream = substream->next) { 658 substream = substream->next) {
659 if ((err = snd_pcm_lib_preallocate_pages(substream, 659 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
660 SNDRV_DMA_TYPE_DEV, 660 snd_dma_pci_data(emu->pci),
661 snd_dma_pci_data(emu->pci), 661 (65536 - 64) * 8,
662 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 662 (65536 - 64) * 8);
663 return err;
664 /* 663 /*
665 dev_dbg(emu->card->dev, 664 dev_dbg(emu->card->dev,
666 "preallocate playback substream: err=%d\n", err); 665 "preallocate playback substream: err=%d\n", err);
@@ -670,11 +669,9 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
670 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 669 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
671 substream; 670 substream;
672 substream = substream->next) { 671 substream = substream->next) {
673 if ((err = snd_pcm_lib_preallocate_pages(substream, 672 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
674 SNDRV_DMA_TYPE_DEV, 673 snd_dma_pci_data(emu->pci),
675 snd_dma_pci_data(emu->pci), 674 65536 - 64, 65536 - 64);
676 65536 - 64, 65536 - 64)) < 0)
677 return err;
678 /* 675 /*
679 dev_dbg(emu->card->dev, 676 dev_dbg(emu->card->dev,
680 "preallocate capture substream: err=%d\n", err); 677 "preallocate capture substream: err=%d\n", err);
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 727eb3da1fda..1cfff35e370e 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -1902,10 +1902,8 @@ static void snd_ensoniq_proc_read(struct snd_info_entry *entry,
1902 1902
1903static void snd_ensoniq_proc_init(struct ensoniq *ensoniq) 1903static void snd_ensoniq_proc_init(struct ensoniq *ensoniq)
1904{ 1904{
1905 struct snd_info_entry *entry; 1905 snd_card_ro_proc_new(ensoniq->card, "audiopci", ensoniq,
1906 1906 snd_ensoniq_proc_read);
1907 if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry))
1908 snd_info_set_text_ops(entry, ensoniq, snd_ensoniq_proc_read);
1909} 1907}
1910 1908
1911/* 1909/*
@@ -2037,9 +2035,6 @@ static int snd_ensoniq_suspend(struct device *dev)
2037 2035
2038 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2036 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2039 2037
2040 snd_pcm_suspend_all(ensoniq->pcm1);
2041 snd_pcm_suspend_all(ensoniq->pcm2);
2042
2043#ifdef CHIP1371 2038#ifdef CHIP1371
2044 snd_ac97_suspend(ensoniq->u.es1371.ac97); 2039 snd_ac97_suspend(ensoniq->u.es1371.ac97);
2045#else 2040#else
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 9d248eb2e26c..84d07bce581c 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1475,7 +1475,6 @@ static int es1938_suspend(struct device *dev)
1475 unsigned char *s, *d; 1475 unsigned char *s, *d;
1476 1476
1477 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1477 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1478 snd_pcm_suspend_all(chip->pcm);
1479 1478
1480 /* save mixer-related registers */ 1479 /* save mixer-related registers */
1481 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++) 1480 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++)
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 0b1845ca6005..9dcb698fc8c7 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2392,7 +2392,6 @@ static int es1968_suspend(struct device *dev)
2392 chip->in_suspend = 1; 2392 chip->in_suspend = 1;
2393 cancel_work_sync(&chip->hwvol_work); 2393 cancel_work_sync(&chip->hwvol_work);
2394 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2394 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2395 snd_pcm_suspend_all(chip->pcm);
2396 snd_ac97_suspend(chip->ac97); 2395 snd_ac97_suspend(chip->ac97);
2397 snd_es1968_bob_stop(chip); 2396 snd_es1968_bob_stop(chip);
2398 return 0; 2397 return 0;
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index e3fb9c61017c..1317f3183eb1 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1408,7 +1408,6 @@ static int snd_fm801_suspend(struct device *dev)
1408 if (chip->tea575x_tuner & TUNER_ONLY) { 1408 if (chip->tea575x_tuner & TUNER_ONLY) {
1409 /* FIXME: tea575x suspend */ 1409 /* FIXME: tea575x suspend */
1410 } else { 1410 } else {
1411 snd_pcm_suspend_all(chip->pcm);
1412 snd_ac97_suspend(chip->ac97); 1411 snd_ac97_suspend(chip->ac97);
1413 snd_ac97_suspend(chip->ac97_sec); 1412 snd_ac97_suspend(chip->ac97_sec);
1414 } 1413 }
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 066b5b59c4d7..b7d9160ed868 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -127,44 +127,6 @@ static void turn_off_beep(struct hda_beep *beep)
127 } 127 }
128} 128}
129 129
130static void snd_hda_do_detach(struct hda_beep *beep)
131{
132 if (beep->registered)
133 input_unregister_device(beep->dev);
134 else
135 input_free_device(beep->dev);
136 beep->dev = NULL;
137 turn_off_beep(beep);
138}
139
140static int snd_hda_do_attach(struct hda_beep *beep)
141{
142 struct input_dev *input_dev;
143 struct hda_codec *codec = beep->codec;
144
145 input_dev = input_allocate_device();
146 if (!input_dev)
147 return -ENOMEM;
148
149 /* setup digital beep device */
150 input_dev->name = "HDA Digital PCBeep";
151 input_dev->phys = beep->phys;
152 input_dev->id.bustype = BUS_PCI;
153 input_dev->dev.parent = &codec->card->card_dev;
154
155 input_dev->id.vendor = codec->core.vendor_id >> 16;
156 input_dev->id.product = codec->core.vendor_id & 0xffff;
157 input_dev->id.version = 0x01;
158
159 input_dev->evbit[0] = BIT_MASK(EV_SND);
160 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
161 input_dev->event = snd_hda_beep_event;
162 input_set_drvdata(input_dev, beep);
163
164 beep->dev = input_dev;
165 return 0;
166}
167
168/** 130/**
169 * snd_hda_enable_beep_device - Turn on/off beep sound 131 * snd_hda_enable_beep_device - Turn on/off beep sound
170 * @codec: the HDA codec 132 * @codec: the HDA codec
@@ -186,6 +148,38 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable)
186} 148}
187EXPORT_SYMBOL_GPL(snd_hda_enable_beep_device); 149EXPORT_SYMBOL_GPL(snd_hda_enable_beep_device);
188 150
151static int beep_dev_register(struct snd_device *device)
152{
153 struct hda_beep *beep = device->device_data;
154 int err;
155
156 err = input_register_device(beep->dev);
157 if (!err)
158 beep->registered = true;
159 return err;
160}
161
162static int beep_dev_disconnect(struct snd_device *device)
163{
164 struct hda_beep *beep = device->device_data;
165
166 if (beep->registered)
167 input_unregister_device(beep->dev);
168 else
169 input_free_device(beep->dev);
170 turn_off_beep(beep);
171 return 0;
172}
173
174static int beep_dev_free(struct snd_device *device)
175{
176 struct hda_beep *beep = device->device_data;
177
178 beep->codec->beep = NULL;
179 kfree(beep);
180 return 0;
181}
182
189/** 183/**
190 * snd_hda_attach_beep_device - Attach a beep input device 184 * snd_hda_attach_beep_device - Attach a beep input device
191 * @codec: the HDA codec 185 * @codec: the HDA codec
@@ -194,14 +188,16 @@ EXPORT_SYMBOL_GPL(snd_hda_enable_beep_device);
194 * Attach a beep object to the given widget. If beep hint is turned off 188 * Attach a beep object to the given widget. If beep hint is turned off
195 * explicitly or beep_mode of the codec is turned off, this doesn't nothing. 189 * explicitly or beep_mode of the codec is turned off, this doesn't nothing.
196 * 190 *
197 * The attached beep device has to be registered via
198 * snd_hda_register_beep_device() and released via snd_hda_detach_beep_device()
199 * appropriately.
200 *
201 * Currently, only one beep device is allowed to each codec. 191 * Currently, only one beep device is allowed to each codec.
202 */ 192 */
203int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) 193int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
204{ 194{
195 static struct snd_device_ops ops = {
196 .dev_register = beep_dev_register,
197 .dev_disconnect = beep_dev_disconnect,
198 .dev_free = beep_dev_free,
199 };
200 struct input_dev *input_dev;
205 struct hda_beep *beep; 201 struct hda_beep *beep;
206 int err; 202 int err;
207 203
@@ -226,14 +222,41 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
226 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); 222 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep);
227 mutex_init(&beep->mutex); 223 mutex_init(&beep->mutex);
228 224
229 err = snd_hda_do_attach(beep); 225 input_dev = input_allocate_device();
230 if (err < 0) { 226 if (!input_dev) {
231 kfree(beep); 227 err = -ENOMEM;
232 codec->beep = NULL; 228 goto err_free;
233 return err;
234 } 229 }
235 230
231 /* setup digital beep device */
232 input_dev->name = "HDA Digital PCBeep";
233 input_dev->phys = beep->phys;
234 input_dev->id.bustype = BUS_PCI;
235 input_dev->dev.parent = &codec->card->card_dev;
236
237 input_dev->id.vendor = codec->core.vendor_id >> 16;
238 input_dev->id.product = codec->core.vendor_id & 0xffff;
239 input_dev->id.version = 0x01;
240
241 input_dev->evbit[0] = BIT_MASK(EV_SND);
242 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
243 input_dev->event = snd_hda_beep_event;
244 input_set_drvdata(input_dev, beep);
245
246 beep->dev = input_dev;
247
248 err = snd_device_new(codec->card, SNDRV_DEV_JACK, beep, &ops);
249 if (err < 0)
250 goto err_input;
251
236 return 0; 252 return 0;
253
254 err_input:
255 input_free_device(beep->dev);
256 err_free:
257 kfree(beep);
258 codec->beep = NULL;
259 return err;
237} 260}
238EXPORT_SYMBOL_GPL(snd_hda_attach_beep_device); 261EXPORT_SYMBOL_GPL(snd_hda_attach_beep_device);
239 262
@@ -243,41 +266,11 @@ EXPORT_SYMBOL_GPL(snd_hda_attach_beep_device);
243 */ 266 */
244void snd_hda_detach_beep_device(struct hda_codec *codec) 267void snd_hda_detach_beep_device(struct hda_codec *codec)
245{ 268{
246 struct hda_beep *beep = codec->beep; 269 if (!codec->bus->shutdown && codec->beep)
247 if (beep) { 270 snd_device_free(codec->card, codec->beep);
248 if (beep->dev)
249 snd_hda_do_detach(beep);
250 codec->beep = NULL;
251 kfree(beep);
252 }
253} 271}
254EXPORT_SYMBOL_GPL(snd_hda_detach_beep_device); 272EXPORT_SYMBOL_GPL(snd_hda_detach_beep_device);
255 273
256/**
257 * snd_hda_register_beep_device - Register the beep device
258 * @codec: the HDA codec
259 */
260int snd_hda_register_beep_device(struct hda_codec *codec)
261{
262 struct hda_beep *beep = codec->beep;
263 int err;
264
265 if (!beep || !beep->dev)
266 return 0;
267
268 err = input_register_device(beep->dev);
269 if (err < 0) {
270 codec_err(codec, "hda_beep: unable to register input device\n");
271 input_free_device(beep->dev);
272 codec->beep = NULL;
273 kfree(beep);
274 return err;
275 }
276 beep->registered = true;
277 return 0;
278}
279EXPORT_SYMBOL_GPL(snd_hda_register_beep_device);
280
281static bool ctl_has_mute(struct snd_kcontrol *kcontrol) 274static bool ctl_has_mute(struct snd_kcontrol *kcontrol)
282{ 275{
283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index f1457c6b3969..a25358a4807a 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -34,7 +34,6 @@ struct hda_beep {
34int snd_hda_enable_beep_device(struct hda_codec *codec, int enable); 34int snd_hda_enable_beep_device(struct hda_codec *codec, int enable);
35int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); 35int snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
36void snd_hda_detach_beep_device(struct hda_codec *codec); 36void snd_hda_detach_beep_device(struct hda_codec *codec);
37int snd_hda_register_beep_device(struct hda_codec *codec);
38#else 37#else
39static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) 38static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
40{ 39{
@@ -43,9 +42,5 @@ static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
43static inline void snd_hda_detach_beep_device(struct hda_codec *codec) 42static inline void snd_hda_detach_beep_device(struct hda_codec *codec)
44{ 43{
45} 44}
46static inline int snd_hda_register_beep_device(struct hda_codec *codec)
47{
48 return 0;
49}
50#endif 45#endif
51#endif 46#endif
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 9f8d59e7e89f..5f2005098a60 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -813,7 +813,6 @@ void snd_hda_codec_register(struct hda_codec *codec)
813 if (codec->registered) 813 if (codec->registered)
814 return; 814 return;
815 if (device_is_registered(hda_codec_dev(codec))) { 815 if (device_is_registered(hda_codec_dev(codec))) {
816 snd_hda_register_beep_device(codec);
817 codec_display_power(codec, true); 816 codec_display_power(codec, true);
818 pm_runtime_enable(hda_codec_dev(codec)); 817 pm_runtime_enable(hda_codec_dev(codec));
819 /* it was powered up in snd_hda_codec_new(), now all done */ 818 /* it was powered up in snd_hda_codec_new(), now all done */
@@ -828,14 +827,6 @@ static int snd_hda_codec_dev_register(struct snd_device *device)
828 return 0; 827 return 0;
829} 828}
830 829
831static int snd_hda_codec_dev_disconnect(struct snd_device *device)
832{
833 struct hda_codec *codec = device->device_data;
834
835 snd_hda_detach_beep_device(codec);
836 return 0;
837}
838
839static int snd_hda_codec_dev_free(struct snd_device *device) 830static int snd_hda_codec_dev_free(struct snd_device *device)
840{ 831{
841 struct hda_codec *codec = device->device_data; 832 struct hda_codec *codec = device->device_data;
@@ -921,7 +912,6 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,
921 int err; 912 int err;
922 static struct snd_device_ops dev_ops = { 913 static struct snd_device_ops dev_ops = {
923 .dev_register = snd_hda_codec_dev_register, 914 .dev_register = snd_hda_codec_dev_register,
924 .dev_disconnect = snd_hda_codec_dev_disconnect,
925 .dev_free = snd_hda_codec_dev_free, 915 .dev_free = snd_hda_codec_dev_free,
926 }; 916 };
927 917
@@ -2917,18 +2907,16 @@ static void hda_call_codec_resume(struct hda_codec *codec)
2917 hda_jackpoll_work(&codec->jackpoll_work.work); 2907 hda_jackpoll_work(&codec->jackpoll_work.work);
2918 else 2908 else
2919 snd_hda_jack_report_sync(codec); 2909 snd_hda_jack_report_sync(codec);
2910 codec->core.dev.power.power_state = PMSG_ON;
2920 snd_hdac_leave_pm(&codec->core); 2911 snd_hdac_leave_pm(&codec->core);
2921} 2912}
2922 2913
2923static int hda_codec_runtime_suspend(struct device *dev) 2914static int hda_codec_runtime_suspend(struct device *dev)
2924{ 2915{
2925 struct hda_codec *codec = dev_to_hda_codec(dev); 2916 struct hda_codec *codec = dev_to_hda_codec(dev);
2926 struct hda_pcm *pcm;
2927 unsigned int state; 2917 unsigned int state;
2928 2918
2929 cancel_delayed_work_sync(&codec->jackpoll_work); 2919 cancel_delayed_work_sync(&codec->jackpoll_work);
2930 list_for_each_entry(pcm, &codec->pcm_list_head, list)
2931 snd_pcm_suspend_all(pcm->pcm);
2932 state = hda_call_codec_suspend(codec); 2920 state = hda_call_codec_suspend(codec);
2933 if (codec->link_down_at_suspend || 2921 if (codec->link_down_at_suspend ||
2934 (codec_has_clkstop(codec) && codec_has_epss(codec) && 2922 (codec_has_clkstop(codec) && codec_has_epss(codec) &&
@@ -2950,10 +2938,48 @@ static int hda_codec_runtime_resume(struct device *dev)
2950} 2938}
2951#endif /* CONFIG_PM */ 2939#endif /* CONFIG_PM */
2952 2940
2941#ifdef CONFIG_PM_SLEEP
2942static int hda_codec_pm_suspend(struct device *dev)
2943{
2944 dev->power.power_state = PMSG_SUSPEND;
2945 return pm_runtime_force_suspend(dev);
2946}
2947
2948static int hda_codec_pm_resume(struct device *dev)
2949{
2950 dev->power.power_state = PMSG_RESUME;
2951 return pm_runtime_force_resume(dev);
2952}
2953
2954static int hda_codec_pm_freeze(struct device *dev)
2955{
2956 dev->power.power_state = PMSG_FREEZE;
2957 return pm_runtime_force_suspend(dev);
2958}
2959
2960static int hda_codec_pm_thaw(struct device *dev)
2961{
2962 dev->power.power_state = PMSG_THAW;
2963 return pm_runtime_force_resume(dev);
2964}
2965
2966static int hda_codec_pm_restore(struct device *dev)
2967{
2968 dev->power.power_state = PMSG_RESTORE;
2969 return pm_runtime_force_resume(dev);
2970}
2971#endif /* CONFIG_PM_SLEEP */
2972
2953/* referred in hda_bind.c */ 2973/* referred in hda_bind.c */
2954const struct dev_pm_ops hda_codec_driver_pm = { 2974const struct dev_pm_ops hda_codec_driver_pm = {
2955 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 2975#ifdef CONFIG_PM_SLEEP
2956 pm_runtime_force_resume) 2976 .suspend = hda_codec_pm_suspend,
2977 .resume = hda_codec_pm_resume,
2978 .freeze = hda_codec_pm_freeze,
2979 .thaw = hda_codec_pm_thaw,
2980 .poweroff = hda_codec_pm_suspend,
2981 .restore = hda_codec_pm_restore,
2982#endif /* CONFIG_PM_SLEEP */
2957 SET_RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume, 2983 SET_RUNTIME_PM_OPS(hda_codec_runtime_suspend, hda_codec_runtime_resume,
2958 NULL) 2984 NULL)
2959}; 2985};
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index a65740419650..853842987fa1 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -919,15 +919,8 @@ static void print_codec_info(struct snd_info_entry *entry,
919int snd_hda_codec_proc_new(struct hda_codec *codec) 919int snd_hda_codec_proc_new(struct hda_codec *codec)
920{ 920{
921 char name[32]; 921 char name[32];
922 struct snd_info_entry *entry;
923 int err;
924 922
925 snprintf(name, sizeof(name), "codec#%d", codec->core.addr); 923 snprintf(name, sizeof(name), "codec#%d", codec->core.addr);
926 err = snd_card_proc_new(codec->card, name, &entry); 924 return snd_card_ro_proc_new(codec->card, name, codec, print_codec_info);
927 if (err < 0)
928 return err;
929
930 snd_info_set_text_ops(entry, codec, print_codec_info);
931 return 0;
932} 925}
933 926
diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index 97a176d817a0..c8d18dc4da2a 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -32,6 +32,7 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/time.h> 33#include <linux/time.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/pm_runtime.h>
35 36
36#include <sound/core.h> 37#include <sound/core.h>
37#include <sound/initval.h> 38#include <sound/initval.h>
@@ -232,40 +233,72 @@ static void hda_tegra_disable_clocks(struct hda_tegra *data)
232static int hda_tegra_suspend(struct device *dev) 233static int hda_tegra_suspend(struct device *dev)
233{ 234{
234 struct snd_card *card = dev_get_drvdata(dev); 235 struct snd_card *card = dev_get_drvdata(dev);
235 struct azx *chip = card->private_data; 236 int rc;
236 struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
237 struct hdac_bus *bus = azx_bus(chip);
238 237
238 rc = pm_runtime_force_suspend(dev);
239 if (rc < 0)
240 return rc;
239 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 241 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
240 242
241 azx_stop_chip(chip);
242 synchronize_irq(bus->irq);
243 azx_enter_link_reset(chip);
244 hda_tegra_disable_clocks(hda);
245
246 return 0; 243 return 0;
247} 244}
248 245
249static int hda_tegra_resume(struct device *dev) 246static int hda_tegra_resume(struct device *dev)
250{ 247{
251 struct snd_card *card = dev_get_drvdata(dev); 248 struct snd_card *card = dev_get_drvdata(dev);
249 int rc;
250
251 rc = pm_runtime_force_resume(dev);
252 if (rc < 0)
253 return rc;
254 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
255
256 return 0;
257}
258#endif /* CONFIG_PM_SLEEP */
259
260#ifdef CONFIG_PM
261static int hda_tegra_runtime_suspend(struct device *dev)
262{
263 struct snd_card *card = dev_get_drvdata(dev);
252 struct azx *chip = card->private_data; 264 struct azx *chip = card->private_data;
253 struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); 265 struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
266 struct hdac_bus *bus = azx_bus(chip);
254 267
255 hda_tegra_enable_clocks(hda); 268 if (chip && chip->running) {
269 azx_stop_chip(chip);
270 synchronize_irq(bus->irq);
271 azx_enter_link_reset(chip);
272 }
273 hda_tegra_disable_clocks(hda);
256 274
257 hda_tegra_init(hda); 275 return 0;
276}
258 277
259 azx_init_chip(chip, 1); 278static int hda_tegra_runtime_resume(struct device *dev)
279{
280 struct snd_card *card = dev_get_drvdata(dev);
281 struct azx *chip = card->private_data;
282 struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
283 int rc;
260 284
261 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 285 rc = hda_tegra_enable_clocks(hda);
286 if (rc != 0)
287 return rc;
288 if (chip && chip->running) {
289 hda_tegra_init(hda);
290 azx_init_chip(chip, 1);
291 }
262 292
263 return 0; 293 return 0;
264} 294}
265#endif /* CONFIG_PM_SLEEP */ 295#endif /* CONFIG_PM */
266 296
267static const struct dev_pm_ops hda_tegra_pm = { 297static const struct dev_pm_ops hda_tegra_pm = {
268 SET_SYSTEM_SLEEP_PM_OPS(hda_tegra_suspend, hda_tegra_resume) 298 SET_SYSTEM_SLEEP_PM_OPS(hda_tegra_suspend, hda_tegra_resume)
299 SET_RUNTIME_PM_OPS(hda_tegra_runtime_suspend,
300 hda_tegra_runtime_resume,
301 NULL)
269}; 302};
270 303
271static int hda_tegra_dev_disconnect(struct snd_device *device) 304static int hda_tegra_dev_disconnect(struct snd_device *device)
@@ -303,7 +336,23 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev)
303 struct hdac_bus *bus = azx_bus(chip); 336 struct hdac_bus *bus = azx_bus(chip);
304 struct device *dev = hda->dev; 337 struct device *dev = hda->dev;
305 struct resource *res; 338 struct resource *res;
306 int err; 339
340 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
341 hda->regs = devm_ioremap_resource(dev, res);
342 if (IS_ERR(hda->regs))
343 return PTR_ERR(hda->regs);
344
345 bus->remap_addr = hda->regs + HDA_BAR0;
346 bus->addr = res->start + HDA_BAR0;
347
348 hda_tegra_init(hda);
349
350 return 0;
351}
352
353static int hda_tegra_init_clk(struct hda_tegra *hda)
354{
355 struct device *dev = hda->dev;
307 356
308 hda->hda_clk = devm_clk_get(dev, "hda"); 357 hda->hda_clk = devm_clk_get(dev, "hda");
309 if (IS_ERR(hda->hda_clk)) { 358 if (IS_ERR(hda->hda_clk)) {
@@ -321,22 +370,6 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev)
321 return PTR_ERR(hda->hda2hdmi_clk); 370 return PTR_ERR(hda->hda2hdmi_clk);
322 } 371 }
323 372
324 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
325 hda->regs = devm_ioremap_resource(dev, res);
326 if (IS_ERR(hda->regs))
327 return PTR_ERR(hda->regs);
328
329 bus->remap_addr = hda->regs + HDA_BAR0;
330 bus->addr = res->start + HDA_BAR0;
331
332 err = hda_tegra_enable_clocks(hda);
333 if (err) {
334 dev_err(dev, "failed to get enable clocks\n");
335 return err;
336 }
337
338 hda_tegra_init(hda);
339
340 return 0; 373 return 0;
341} 374}
342 375
@@ -487,7 +520,8 @@ MODULE_DEVICE_TABLE(of, hda_tegra_match);
487 520
488static int hda_tegra_probe(struct platform_device *pdev) 521static int hda_tegra_probe(struct platform_device *pdev)
489{ 522{
490 const unsigned int driver_flags = AZX_DCAPS_CORBRP_SELF_CLEAR; 523 const unsigned int driver_flags = AZX_DCAPS_CORBRP_SELF_CLEAR |
524 AZX_DCAPS_PM_RUNTIME;
491 struct snd_card *card; 525 struct snd_card *card;
492 struct azx *chip; 526 struct azx *chip;
493 struct hda_tegra *hda; 527 struct hda_tegra *hda;
@@ -506,12 +540,21 @@ static int hda_tegra_probe(struct platform_device *pdev)
506 return err; 540 return err;
507 } 541 }
508 542
543 err = hda_tegra_init_clk(hda);
544 if (err < 0)
545 goto out_free;
546
509 err = hda_tegra_create(card, driver_flags, hda); 547 err = hda_tegra_create(card, driver_flags, hda);
510 if (err < 0) 548 if (err < 0)
511 goto out_free; 549 goto out_free;
512 card->private_data = chip; 550 card->private_data = chip;
513 551
514 dev_set_drvdata(&pdev->dev, card); 552 dev_set_drvdata(&pdev->dev, card);
553
554 pm_runtime_enable(hda->dev);
555 if (!azx_has_pm_runtime(chip))
556 pm_runtime_forbid(hda->dev);
557
515 schedule_work(&hda->probe_work); 558 schedule_work(&hda->probe_work);
516 559
517 return 0; 560 return 0;
@@ -528,6 +571,7 @@ static void hda_tegra_probe_work(struct work_struct *work)
528 struct platform_device *pdev = to_platform_device(hda->dev); 571 struct platform_device *pdev = to_platform_device(hda->dev);
529 int err; 572 int err;
530 573
574 pm_runtime_get_sync(hda->dev);
531 err = hda_tegra_first_init(chip, pdev); 575 err = hda_tegra_first_init(chip, pdev);
532 if (err < 0) 576 if (err < 0)
533 goto out_free; 577 goto out_free;
@@ -549,12 +593,18 @@ static void hda_tegra_probe_work(struct work_struct *work)
549 snd_hda_set_power_save(&chip->bus, power_save * 1000); 593 snd_hda_set_power_save(&chip->bus, power_save * 1000);
550 594
551 out_free: 595 out_free:
596 pm_runtime_put(hda->dev);
552 return; /* no error return from async probe */ 597 return; /* no error return from async probe */
553} 598}
554 599
555static int hda_tegra_remove(struct platform_device *pdev) 600static int hda_tegra_remove(struct platform_device *pdev)
556{ 601{
557 return snd_card_free(dev_get_drvdata(&pdev->dev)); 602 int ret;
603
604 ret = snd_card_free(dev_get_drvdata(&pdev->dev));
605 pm_runtime_disable(&pdev->dev);
606
607 return ret;
558} 608}
559 609
560static void hda_tegra_shutdown(struct platform_device *pdev) 610static void hda_tegra_shutdown(struct platform_device *pdev)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 46f88dc7b7e8..73d7042ff884 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1865,7 +1865,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1865 hda_nid_t pin_nid; 1865 hda_nid_t pin_nid;
1866 struct snd_pcm_runtime *runtime = substream->runtime; 1866 struct snd_pcm_runtime *runtime = substream->runtime;
1867 bool non_pcm; 1867 bool non_pcm;
1868 int pinctl; 1868 int pinctl, stripe;
1869 int err = 0; 1869 int err = 0;
1870 1870
1871 mutex_lock(&spec->pcm_lock); 1871 mutex_lock(&spec->pcm_lock);
@@ -1909,6 +1909,14 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1909 per_pin->channels = substream->runtime->channels; 1909 per_pin->channels = substream->runtime->channels;
1910 per_pin->setup = true; 1910 per_pin->setup = true;
1911 1911
1912 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) {
1913 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core,
1914 substream);
1915 snd_hda_codec_write(codec, cvt_nid, 0,
1916 AC_VERB_SET_STRIPE_CONTROL,
1917 stripe);
1918 }
1919
1912 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); 1920 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm);
1913 mutex_unlock(&per_pin->lock); 1921 mutex_unlock(&per_pin->lock);
1914 if (spec->dyn_pin_out) { 1922 if (spec->dyn_pin_out) {
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b4f472157ebd..e9dc9408d9bc 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -117,6 +117,7 @@ struct alc_spec {
117 int codec_variant; /* flag for other variants */ 117 int codec_variant; /* flag for other variants */
118 unsigned int has_alc5505_dsp:1; 118 unsigned int has_alc5505_dsp:1;
119 unsigned int no_depop_delay:1; 119 unsigned int no_depop_delay:1;
120 unsigned int done_hp_init:1;
120 121
121 /* for PLL fix */ 122 /* for PLL fix */
122 hda_nid_t pll_nid; 123 hda_nid_t pll_nid;
@@ -3372,6 +3373,50 @@ static void alc_default_shutup(struct hda_codec *codec)
3372 snd_hda_shutup_pins(codec); 3373 snd_hda_shutup_pins(codec);
3373} 3374}
3374 3375
3376static void alc294_hp_init(struct hda_codec *codec)
3377{
3378 struct alc_spec *spec = codec->spec;
3379 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3380 int i, val;
3381
3382 if (!hp_pin)
3383 return;
3384
3385 snd_hda_codec_write(codec, hp_pin, 0,
3386 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3387
3388 msleep(100);
3389
3390 snd_hda_codec_write(codec, hp_pin, 0,
3391 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3392
3393 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3394 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3395
3396 /* Wait for depop procedure finish */
3397 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3398 for (i = 0; i < 20 && val & 0x0080; i++) {
3399 msleep(50);
3400 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3401 }
3402 /* Set HP depop to auto mode */
3403 alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3404 msleep(50);
3405}
3406
3407static void alc294_init(struct hda_codec *codec)
3408{
3409 struct alc_spec *spec = codec->spec;
3410
3411 /* required only at boot or S4 resume time */
3412 if (!spec->done_hp_init ||
3413 codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3414 alc294_hp_init(codec);
3415 spec->done_hp_init = true;
3416 }
3417 alc_default_init(codec);
3418}
3419
3375static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg, 3420static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3376 unsigned int val) 3421 unsigned int val)
3377{ 3422{
@@ -7373,37 +7418,6 @@ static void alc269_fill_coef(struct hda_codec *codec)
7373 alc_update_coef_idx(codec, 0x4, 0, 1<<11); 7418 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
7374} 7419}
7375 7420
7376static void alc294_hp_init(struct hda_codec *codec)
7377{
7378 struct alc_spec *spec = codec->spec;
7379 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
7380 int i, val;
7381
7382 if (!hp_pin)
7383 return;
7384
7385 snd_hda_codec_write(codec, hp_pin, 0,
7386 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
7387
7388 msleep(100);
7389
7390 snd_hda_codec_write(codec, hp_pin, 0,
7391 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
7392
7393 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
7394 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
7395
7396 /* Wait for depop procedure finish */
7397 val = alc_read_coefex_idx(codec, 0x58, 0x01);
7398 for (i = 0; i < 20 && val & 0x0080; i++) {
7399 msleep(50);
7400 val = alc_read_coefex_idx(codec, 0x58, 0x01);
7401 }
7402 /* Set HP depop to auto mode */
7403 alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
7404 msleep(50);
7405}
7406
7407/* 7421/*
7408 */ 7422 */
7409static int patch_alc269(struct hda_codec *codec) 7423static int patch_alc269(struct hda_codec *codec)
@@ -7529,7 +7543,7 @@ static int patch_alc269(struct hda_codec *codec)
7529 spec->codec_variant = ALC269_TYPE_ALC294; 7543 spec->codec_variant = ALC269_TYPE_ALC294;
7530 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */ 7544 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
7531 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */ 7545 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
7532 alc294_hp_init(codec); 7546 spec->init_hook = alc294_init;
7533 break; 7547 break;
7534 case 0x10ec0300: 7548 case 0x10ec0300:
7535 spec->codec_variant = ALC269_TYPE_ALC300; 7549 spec->codec_variant = ALC269_TYPE_ALC300;
@@ -7541,7 +7555,7 @@ static int patch_alc269(struct hda_codec *codec)
7541 spec->codec_variant = ALC269_TYPE_ALC700; 7555 spec->codec_variant = ALC269_TYPE_ALC700;
7542 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */ 7556 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
7543 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */ 7557 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
7544 alc294_hp_init(codec); 7558 spec->init_hook = alc294_init;
7545 break; 7559 break;
7546 7560
7547 } 7561 }
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index b8af747ecb43..7646c93e8268 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -826,7 +826,12 @@ static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg
826 826
827 snd_i2c_lock(ice->i2c); 827 snd_i2c_lock(ice->i2c);
828 byte = reg; 828 byte = reg;
829 snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1); 829 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1)) {
830 snd_i2c_unlock(ice->i2c);
831 dev_err(ice->card->dev, "cannot send pca\n");
832 return -EIO;
833 }
834
830 byte = 0; 835 byte = 0;
831 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) { 836 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
832 snd_i2c_unlock(ice->i2c); 837 snd_i2c_unlock(ice->i2c);
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index f1fe497c2f9d..fa7d90ee6e2d 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -1603,10 +1603,7 @@ static void snd_ice1712_proc_read(struct snd_info_entry *entry,
1603 1603
1604static void snd_ice1712_proc_init(struct snd_ice1712 *ice) 1604static void snd_ice1712_proc_init(struct snd_ice1712 *ice)
1605{ 1605{
1606 struct snd_info_entry *entry; 1606 snd_card_ro_proc_new(ice->card, "ice1712", ice, snd_ice1712_proc_read);
1607
1608 if (!snd_card_proc_new(ice->card, "ice1712", &entry))
1609 snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
1610} 1607}
1611 1608
1612/* 1609/*
@@ -2792,9 +2789,6 @@ static int snd_ice1712_suspend(struct device *dev)
2792 2789
2793 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2790 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2794 2791
2795 snd_pcm_suspend_all(ice->pcm);
2796 snd_pcm_suspend_all(ice->pcm_pro);
2797 snd_pcm_suspend_all(ice->pcm_ds);
2798 snd_ac97_suspend(ice->ac97); 2792 snd_ac97_suspend(ice->ac97);
2799 2793
2800 spin_lock_irq(&ice->reg_lock); 2794 spin_lock_irq(&ice->reg_lock);
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 057c2f394ea7..a7d640ee4a17 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -1571,10 +1571,7 @@ static void snd_vt1724_proc_read(struct snd_info_entry *entry,
1571 1571
1572static void snd_vt1724_proc_init(struct snd_ice1712 *ice) 1572static void snd_vt1724_proc_init(struct snd_ice1712 *ice)
1573{ 1573{
1574 struct snd_info_entry *entry; 1574 snd_card_ro_proc_new(ice->card, "ice1724", ice, snd_vt1724_proc_read);
1575
1576 if (!snd_card_proc_new(ice->card, "ice1724", &entry))
1577 snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read);
1578} 1575}
1579 1576
1580/* 1577/*
@@ -2804,9 +2801,6 @@ static int snd_vt1724_suspend(struct device *dev)
2804 2801
2805 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2802 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2806 2803
2807 snd_pcm_suspend_all(ice->pcm);
2808 snd_pcm_suspend_all(ice->pcm_pro);
2809 snd_pcm_suspend_all(ice->pcm_ds);
2810 snd_ac97_suspend(ice->ac97); 2804 snd_ac97_suspend(ice->ac97);
2811 2805
2812 spin_lock_irq(&ice->reg_lock); 2806 spin_lock_irq(&ice->reg_lock);
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 93b8cfc6636f..f499f1e8d0c9 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -659,12 +659,8 @@ static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
659 659
660static void wm_proc_init(struct snd_ice1712 *ice) 660static void wm_proc_init(struct snd_ice1712 *ice)
661{ 661{
662 struct snd_info_entry *entry; 662 snd_card_rw_proc_new(ice->card, "wm_codec", ice, wm_proc_regs_read,
663 if (! snd_card_proc_new(ice->card, "wm_codec", &entry)) { 663 wm_proc_regs_write);
664 snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
665 entry->mode |= 0200;
666 entry->c.text.write = wm_proc_regs_write;
667 }
668} 664}
669 665
670static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 666static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
@@ -684,9 +680,7 @@ static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
684 680
685static void cs_proc_init(struct snd_ice1712 *ice) 681static void cs_proc_init(struct snd_ice1712 *ice)
686{ 682{
687 struct snd_info_entry *entry; 683 snd_card_ro_proc_new(ice->card, "cs_codec", ice, cs_proc_regs_read);
688 if (! snd_card_proc_new(ice->card, "cs_codec", &entry))
689 snd_info_set_text_ops(entry, ice, cs_proc_regs_read);
690} 684}
691 685
692 686
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 3919aed39ca0..d243309029d3 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -651,9 +651,8 @@ static void stac9460_proc_regs_read(struct snd_info_entry *entry,
651 651
652static void stac9460_proc_init(struct snd_ice1712 *ice) 652static void stac9460_proc_init(struct snd_ice1712 *ice)
653{ 653{
654 struct snd_info_entry *entry; 654 snd_card_ro_proc_new(ice->card, "stac9460_codec", ice,
655 if (!snd_card_proc_new(ice->card, "stac9460_codec", &entry)) 655 stac9460_proc_regs_read);
656 snd_info_set_text_ops(entry, ice, stac9460_proc_regs_read);
657} 656}
658 657
659 658
diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c
index c97b5528e4b8..72f252c936e5 100644
--- a/sound/pci/ice1712/prodigy_hifi.c
+++ b/sound/pci/ice1712/prodigy_hifi.c
@@ -904,12 +904,8 @@ static void wm_proc_regs_read(struct snd_info_entry *entry,
904 904
905static void wm_proc_init(struct snd_ice1712 *ice) 905static void wm_proc_init(struct snd_ice1712 *ice)
906{ 906{
907 struct snd_info_entry *entry; 907 snd_card_rw_proc_new(ice->card, "wm_codec", ice, wm_proc_regs_read,
908 if (!snd_card_proc_new(ice->card, "wm_codec", &entry)) { 908 wm_proc_regs_write);
909 snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
910 entry->mode |= 0200;
911 entry->c.text.write = wm_proc_regs_write;
912 }
913} 909}
914 910
915static int prodigy_hifi_add_controls(struct snd_ice1712 *ice) 911static int prodigy_hifi_add_controls(struct snd_ice1712 *ice)
diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c
index 5bc836241c97..8ad964ee0b65 100644
--- a/sound/pci/ice1712/quartet.c
+++ b/sound/pci/ice1712/quartet.c
@@ -502,9 +502,7 @@ static void proc_regs_read(struct snd_info_entry *entry,
502 502
503static void proc_init(struct snd_ice1712 *ice) 503static void proc_init(struct snd_ice1712 *ice)
504{ 504{
505 struct snd_info_entry *entry; 505 snd_card_ro_proc_new(ice->card, "quartet", ice, proc_regs_read);
506 if (!snd_card_proc_new(ice->card, "quartet", &entry))
507 snd_info_set_text_ops(entry, ice, proc_regs_read);
508} 506}
509 507
510static int qtet_mute_get(struct snd_kcontrol *kcontrol, 508static int qtet_mute_get(struct snd_kcontrol *kcontrol,
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index ffddcdfe0c66..2784bf48cf5a 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2614,8 +2614,6 @@ static int intel8x0_suspend(struct device *dev)
2614 int i; 2614 int i;
2615 2615
2616 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2616 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2617 for (i = 0; i < chip->pcm_devs; i++)
2618 snd_pcm_suspend_all(chip->pcm[i]);
2619 for (i = 0; i < chip->ncodecs; i++) 2617 for (i = 0; i < chip->ncodecs; i++)
2620 snd_ac97_suspend(chip->ac97[i]); 2618 snd_ac97_suspend(chip->ac97[i]);
2621 if (chip->device_type == DEVICE_INTEL_ICH4) 2619 if (chip->device_type == DEVICE_INTEL_ICH4)
@@ -2865,10 +2863,8 @@ static void snd_intel8x0_proc_read(struct snd_info_entry * entry,
2865 2863
2866static void snd_intel8x0_proc_init(struct intel8x0 *chip) 2864static void snd_intel8x0_proc_init(struct intel8x0 *chip)
2867{ 2865{
2868 struct snd_info_entry *entry; 2866 snd_card_ro_proc_new(chip->card, "intel8x0", chip,
2869 2867 snd_intel8x0_proc_read);
2870 if (! snd_card_proc_new(chip->card, "intel8x0", &entry))
2871 snd_info_set_text_ops(entry, chip, snd_intel8x0_proc_read);
2872} 2868}
2873 2869
2874static int snd_intel8x0_dev_free(struct snd_device *device) 2870static int snd_intel8x0_dev_free(struct snd_device *device)
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index c84629190cba..43c654e15452 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1025,11 +1025,8 @@ static int intel8x0m_suspend(struct device *dev)
1025{ 1025{
1026 struct snd_card *card = dev_get_drvdata(dev); 1026 struct snd_card *card = dev_get_drvdata(dev);
1027 struct intel8x0m *chip = card->private_data; 1027 struct intel8x0m *chip = card->private_data;
1028 int i;
1029 1028
1030 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1029 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1031 for (i = 0; i < chip->pcm_devs; i++)
1032 snd_pcm_suspend_all(chip->pcm[i]);
1033 snd_ac97_suspend(chip->ac97); 1030 snd_ac97_suspend(chip->ac97);
1034 if (chip->irq >= 0) { 1031 if (chip->irq >= 0) {
1035 free_irq(chip->irq, chip); 1032 free_irq(chip->irq, chip);
@@ -1087,10 +1084,8 @@ static void snd_intel8x0m_proc_read(struct snd_info_entry * entry,
1087 1084
1088static void snd_intel8x0m_proc_init(struct intel8x0m *chip) 1085static void snd_intel8x0m_proc_init(struct intel8x0m *chip)
1089{ 1086{
1090 struct snd_info_entry *entry; 1087 snd_card_ro_proc_new(chip->card, "intel8x0m", chip,
1091 1088 snd_intel8x0m_proc_read);
1092 if (! snd_card_proc_new(chip->card, "intel8x0m", &entry))
1093 snd_info_set_text_ops(entry, chip, snd_intel8x0m_proc_read);
1094} 1089}
1095 1090
1096static int snd_intel8x0m_dev_free(struct snd_device *device) 1091static int snd_intel8x0m_dev_free(struct snd_device *device)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 4e189a93f475..fe4aba8a08ea 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2090,10 +2090,8 @@ static void snd_korg1212_proc_read(struct snd_info_entry *entry,
2090 2090
2091static void snd_korg1212_proc_init(struct snd_korg1212 *korg1212) 2091static void snd_korg1212_proc_init(struct snd_korg1212 *korg1212)
2092{ 2092{
2093 struct snd_info_entry *entry; 2093 snd_card_ro_proc_new(korg1212->card, "korg1212", korg1212,
2094 2094 snd_korg1212_proc_read);
2095 if (! snd_card_proc_new(korg1212->card, "korg1212", &entry))
2096 snd_info_set_text_ops(entry, korg1212, snd_korg1212_proc_read);
2097} 2095}
2098 2096
2099static int 2097static int
diff --git a/sound/pci/lola/lola_proc.c b/sound/pci/lola/lola_proc.c
index 904e3c4f4dfe..1603f9c81897 100644
--- a/sound/pci/lola/lola_proc.c
+++ b/sound/pci/lola/lola_proc.c
@@ -208,15 +208,9 @@ static void lola_proc_regs_read(struct snd_info_entry *entry,
208 208
209void lola_proc_debug_new(struct lola *chip) 209void lola_proc_debug_new(struct lola *chip)
210{ 210{
211 struct snd_info_entry *entry; 211 snd_card_ro_proc_new(chip->card, "codec", chip, lola_proc_codec_read);
212 212 snd_card_rw_proc_new(chip->card, "codec_rw", chip,
213 if (!snd_card_proc_new(chip->card, "codec", &entry)) 213 lola_proc_codec_rw_read,
214 snd_info_set_text_ops(entry, chip, lola_proc_codec_read); 214 lola_proc_codec_rw_write);
215 if (!snd_card_proc_new(chip->card, "codec_rw", &entry)) { 215 snd_card_ro_proc_new(chip->card, "regs", chip, lola_proc_regs_read);
216 snd_info_set_text_ops(entry, chip, lola_proc_codec_rw_read);
217 entry->mode |= 0200;
218 entry->c.text.write = lola_proc_codec_rw_write;
219 }
220 if (!snd_card_proc_new(chip->card, "regs", &entry))
221 snd_info_set_text_ops(entry, chip, lola_proc_regs_read);
222} 216}
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 54f6252faca6..ae23a2dfbdea 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -854,11 +854,9 @@ static int lx_pcm_create(struct lx6464es *chip)
854 pcm->nonatomic = true; 854 pcm->nonatomic = true;
855 strcpy(pcm->name, card_name); 855 strcpy(pcm->name, card_name);
856 856
857 err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 857 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
858 snd_dma_pci_data(chip->pci), 858 snd_dma_pci_data(chip->pci),
859 size, size); 859 size, size);
860 if (err < 0)
861 return err;
862 860
863 chip->pcm = pcm; 861 chip->pcm = pcm;
864 chip->capture_stream.is_capture = 1; 862 chip->capture_stream.is_capture = 1;
@@ -948,13 +946,7 @@ static void lx_proc_levels_read(struct snd_info_entry *entry,
948 946
949static int lx_proc_create(struct snd_card *card, struct lx6464es *chip) 947static int lx_proc_create(struct snd_card *card, struct lx6464es *chip)
950{ 948{
951 struct snd_info_entry *entry; 949 return snd_card_ro_proc_new(card, "levels", chip, lx_proc_levels_read);
952 int err = snd_card_proc_new(card, "levels", &entry);
953 if (err < 0)
954 return err;
955
956 snd_info_set_text_ops(entry, chip, lx_proc_levels_read);
957 return 0;
958} 950}
959 951
960 952
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 62962178a9d7..1a9468c14aaf 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2422,7 +2422,6 @@ static int m3_suspend(struct device *dev)
2422 chip->in_suspend = 1; 2422 chip->in_suspend = 1;
2423 cancel_work_sync(&chip->hwvol_work); 2423 cancel_work_sync(&chip->hwvol_work);
2424 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2424 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2425 snd_pcm_suspend_all(chip->pcm);
2426 snd_ac97_suspend(chip->ac97); 2425 snd_ac97_suspend(chip->ac97);
2427 2426
2428 msleep(10); /* give the assp a chance to idle.. */ 2427 msleep(10); /* give the assp a chance to idle.. */
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 9cd297a42f24..92f616df3863 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1220,10 +1220,8 @@ static void snd_mixart_proc_init(struct snd_mixart *chip)
1220 struct snd_info_entry *entry; 1220 struct snd_info_entry *entry;
1221 1221
1222 /* text interface to read perf and temp meters */ 1222 /* text interface to read perf and temp meters */
1223 if (! snd_card_proc_new(chip->card, "board_info", &entry)) { 1223 snd_card_ro_proc_new(chip->card, "board_info", chip,
1224 entry->private_data = chip; 1224 snd_mixart_proc_read);
1225 entry->c.text.read = snd_mixart_proc_read;
1226 }
1227 1225
1228 if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) { 1226 if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) {
1229 entry->content = SNDRV_INFO_CONTENT_DATA; 1227 entry->content = SNDRV_INFO_CONTENT_DATA;
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index b97f4ea6b56c..85e46ff44ac3 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1413,7 +1413,6 @@ static int nm256_suspend(struct device *dev)
1413 struct nm256 *chip = card->private_data; 1413 struct nm256 *chip = card->private_data;
1414 1414
1415 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1415 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1416 snd_pcm_suspend_all(chip->pcm);
1417 snd_ac97_suspend(chip->ac97); 1416 snd_ac97_suspend(chip->ac97);
1418 chip->coeffs_current = 0; 1417 chip->coeffs_current = 0;
1419 return 0; 1418 return 0;
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index b4ef5804212d..3ae9dd4b39e8 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -244,10 +244,7 @@ static void oxygen_proc_read(struct snd_info_entry *entry,
244 244
245static void oxygen_proc_init(struct oxygen *chip) 245static void oxygen_proc_init(struct oxygen *chip)
246{ 246{
247 struct snd_info_entry *entry; 247 snd_card_ro_proc_new(chip->card, "oxygen", chip, oxygen_proc_read);
248
249 if (!snd_card_proc_new(chip->card, "oxygen", &entry))
250 snd_info_set_text_ops(entry, chip, oxygen_proc_read);
251} 248}
252 249
253static const struct pci_device_id * 250static const struct pci_device_id *
@@ -373,7 +370,7 @@ static void oxygen_init(struct oxygen *chip)
373 for (i = 0; i < 8; ++i) 370 for (i = 0; i < 8; ++i)
374 chip->dac_volume[i] = chip->model.dac_volume_min; 371 chip->dac_volume[i] = chip->model.dac_volume_min;
375 chip->dac_mute = 1; 372 chip->dac_mute = 1;
376 chip->spdif_playback_enable = 1; 373 chip->spdif_playback_enable = 0;
377 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | 374 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
378 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT); 375 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT);
379 chip->spdif_pcm_bits = chip->spdif_bits; 376 chip->spdif_pcm_bits = chip->spdif_bits;
@@ -744,13 +741,10 @@ static int oxygen_pci_suspend(struct device *dev)
744{ 741{
745 struct snd_card *card = dev_get_drvdata(dev); 742 struct snd_card *card = dev_get_drvdata(dev);
746 struct oxygen *chip = card->private_data; 743 struct oxygen *chip = card->private_data;
747 unsigned int i, saved_interrupt_mask; 744 unsigned int saved_interrupt_mask;
748 745
749 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 746 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
750 747
751 for (i = 0; i < PCM_COUNT; ++i)
752 snd_pcm_suspend(chip->streams[i]);
753
754 if (chip->model.suspend) 748 if (chip->model.suspend)
755 chip->model.suspend(chip); 749 chip->model.suspend(chip);
756 750
diff --git a/sound/pci/oxygen/pcm1796.h b/sound/pci/oxygen/pcm1796.h
index 34d07dd2d22e..d5dcb09e44cd 100644
--- a/sound/pci/oxygen/pcm1796.h
+++ b/sound/pci/oxygen/pcm1796.h
@@ -10,7 +10,6 @@
10#define PCM1796_MUTE 0x01 10#define PCM1796_MUTE 0x01
11#define PCM1796_DME 0x02 11#define PCM1796_DME 0x02
12#define PCM1796_DMF_MASK 0x0c 12#define PCM1796_DMF_MASK 0x0c
13#define PCM1796_DMF_DISABLED 0x00
14#define PCM1796_DMF_48 0x04 13#define PCM1796_DMF_48 0x04
15#define PCM1796_DMF_441 0x08 14#define PCM1796_DMF_441 0x08
16#define PCM1796_DMF_32 0x0c 15#define PCM1796_DMF_32 0x0c
diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c
index 24109d37ca09..a1c6b98b191e 100644
--- a/sound/pci/oxygen/xonar_pcm179x.c
+++ b/sound/pci/oxygen/xonar_pcm179x.c
@@ -331,7 +331,7 @@ static void pcm1796_init(struct oxygen *chip)
331 struct xonar_pcm179x *data = chip->model_data; 331 struct xonar_pcm179x *data = chip->model_data;
332 332
333 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = 333 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] =
334 PCM1796_DMF_DISABLED | PCM1796_FMT_24_I2S | PCM1796_ATLD; 334 PCM1796_FMT_24_I2S | PCM1796_ATLD;
335 if (!data->broken_i2c) 335 if (!data->broken_i2c)
336 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] |= PCM1796_MUTE; 336 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] |= PCM1796_MUTE;
337 data->pcm1796_regs[0][19 - PCM1796_REG_BASE] = 337 data->pcm1796_regs[0][19 - PCM1796_REG_BASE] =
@@ -621,6 +621,23 @@ static void update_pcm1796_oversampling(struct oxygen *chip)
621 pcm1796_write_cached(chip, i, 20, reg); 621 pcm1796_write_cached(chip, i, 20, reg);
622} 622}
623 623
624static void update_pcm1796_deemph(struct oxygen *chip)
625{
626 struct xonar_pcm179x *data = chip->model_data;
627 unsigned int i;
628 u8 reg;
629
630 reg = data->pcm1796_regs[0][18 - PCM1796_REG_BASE] & ~PCM1796_DMF_MASK;
631 if (data->current_rate == 48000)
632 reg |= PCM1796_DMF_48;
633 else if (data->current_rate == 44100)
634 reg |= PCM1796_DMF_441;
635 else if (data->current_rate == 32000)
636 reg |= PCM1796_DMF_32;
637 for (i = 0; i < data->dacs; ++i)
638 pcm1796_write_cached(chip, i, 18, reg);
639}
640
624static void set_pcm1796_params(struct oxygen *chip, 641static void set_pcm1796_params(struct oxygen *chip,
625 struct snd_pcm_hw_params *params) 642 struct snd_pcm_hw_params *params)
626{ 643{
@@ -629,6 +646,7 @@ static void set_pcm1796_params(struct oxygen *chip,
629 msleep(1); 646 msleep(1);
630 data->current_rate = params_rate(params); 647 data->current_rate = params_rate(params);
631 update_pcm1796_oversampling(chip); 648 update_pcm1796_oversampling(chip);
649 update_pcm1796_deemph(chip);
632} 650}
633 651
634static void update_pcm1796_volume(struct oxygen *chip) 652static void update_pcm1796_volume(struct oxygen *chip)
@@ -653,9 +671,11 @@ static void update_pcm1796_mute(struct oxygen *chip)
653 unsigned int i; 671 unsigned int i;
654 u8 value; 672 u8 value;
655 673
656 value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_I2S | PCM1796_ATLD; 674 value = data->pcm1796_regs[0][18 - PCM1796_REG_BASE];
657 if (chip->dac_mute) 675 if (chip->dac_mute)
658 value |= PCM1796_MUTE; 676 value |= PCM1796_MUTE;
677 else
678 value &= ~PCM1796_MUTE;
659 for (i = 0; i < data->dacs; ++i) 679 for (i = 0; i < data->dacs; ++i)
660 pcm1796_write_cached(chip, i, 18, value); 680 pcm1796_write_cached(chip, i, 18, value);
661} 681}
@@ -777,6 +797,49 @@ static const struct snd_kcontrol_new rolloff_control = {
777 .put = rolloff_put, 797 .put = rolloff_put,
778}; 798};
779 799
800static int deemph_get(struct snd_kcontrol *ctl,
801 struct snd_ctl_elem_value *value)
802{
803 struct oxygen *chip = ctl->private_data;
804 struct xonar_pcm179x *data = chip->model_data;
805
806 value->value.integer.value[0] =
807 !!(data->pcm1796_regs[0][18 - PCM1796_REG_BASE] & PCM1796_DME);
808 return 0;
809}
810
811static int deemph_put(struct snd_kcontrol *ctl,
812 struct snd_ctl_elem_value *value)
813{
814 struct oxygen *chip = ctl->private_data;
815 struct xonar_pcm179x *data = chip->model_data;
816 unsigned int i;
817 int changed;
818 u8 reg;
819
820 mutex_lock(&chip->mutex);
821 reg = data->pcm1796_regs[0][18 - PCM1796_REG_BASE];
822 if (!value->value.integer.value[0])
823 reg &= ~PCM1796_DME;
824 else
825 reg |= PCM1796_DME;
826 changed = reg != data->pcm1796_regs[0][18 - PCM1796_REG_BASE];
827 if (changed) {
828 for (i = 0; i < data->dacs; ++i)
829 pcm1796_write(chip, i, 18, reg);
830 }
831 mutex_unlock(&chip->mutex);
832 return changed;
833}
834
835static const struct snd_kcontrol_new deemph_control = {
836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
837 .name = "De-emphasis Playback Switch",
838 .info = snd_ctl_boolean_mono_info,
839 .get = deemph_get,
840 .put = deemph_put,
841};
842
780static const struct snd_kcontrol_new hdav_hdmi_control = { 843static const struct snd_kcontrol_new hdav_hdmi_control = {
781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
782 .name = "HDMI Playback Switch", 845 .name = "HDMI Playback Switch",
@@ -1011,6 +1074,10 @@ static int add_pcm1796_controls(struct oxygen *chip)
1011 snd_ctl_new1(&rolloff_control, chip)); 1074 snd_ctl_new1(&rolloff_control, chip));
1012 if (err < 0) 1075 if (err < 0)
1013 return err; 1076 return err;
1077 err = snd_ctl_add(chip->card,
1078 snd_ctl_new1(&deemph_control, chip));
1079 if (err < 0)
1080 return err;
1014 } 1081 }
1015 return 0; 1082 return 0;
1016} 1083}
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index e57da4036231..4ab7efc6e9f7 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1454,21 +1454,14 @@ static void pcxhr_proc_ltc(struct snd_info_entry *entry,
1454 1454
1455static void pcxhr_proc_init(struct snd_pcxhr *chip) 1455static void pcxhr_proc_init(struct snd_pcxhr *chip)
1456{ 1456{
1457 struct snd_info_entry *entry; 1457 snd_card_ro_proc_new(chip->card, "info", chip, pcxhr_proc_info);
1458 1458 snd_card_ro_proc_new(chip->card, "sync", chip, pcxhr_proc_sync);
1459 if (! snd_card_proc_new(chip->card, "info", &entry))
1460 snd_info_set_text_ops(entry, chip, pcxhr_proc_info);
1461 if (! snd_card_proc_new(chip->card, "sync", &entry))
1462 snd_info_set_text_ops(entry, chip, pcxhr_proc_sync);
1463 /* gpio available on stereo sound cards only */ 1459 /* gpio available on stereo sound cards only */
1464 if (chip->mgr->is_hr_stereo && 1460 if (chip->mgr->is_hr_stereo)
1465 !snd_card_proc_new(chip->card, "gpio", &entry)) { 1461 snd_card_rw_proc_new(chip->card, "gpio", chip,
1466 snd_info_set_text_ops(entry, chip, pcxhr_proc_gpio_read); 1462 pcxhr_proc_gpio_read,
1467 entry->c.text.write = pcxhr_proc_gpo_write; 1463 pcxhr_proc_gpo_write);
1468 entry->mode |= 0200; 1464 snd_card_ro_proc_new(chip->card, "ltc", chip, pcxhr_proc_ltc);
1469 }
1470 if (!snd_card_proc_new(chip->card, "ltc", &entry))
1471 snd_info_set_text_ops(entry, chip, pcxhr_proc_ltc);
1472} 1465}
1473/* end of proc interface */ 1466/* end of proc interface */
1474 1467
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 23017e3bc76c..8d1a56a9bcfd 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1158,7 +1158,6 @@ static int riptide_suspend(struct device *dev)
1158 1158
1159 chip->in_suspend = 1; 1159 chip->in_suspend = 1;
1160 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1160 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1161 snd_pcm_suspend_all(chip->pcm);
1162 snd_ac97_suspend(chip->ac97); 1161 snd_ac97_suspend(chip->ac97);
1163 return 0; 1162 return 0;
1164} 1163}
@@ -1974,10 +1973,8 @@ snd_riptide_proc_read(struct snd_info_entry *entry,
1974 1973
1975static void snd_riptide_proc_init(struct snd_riptide *chip) 1974static void snd_riptide_proc_init(struct snd_riptide *chip)
1976{ 1975{
1977 struct snd_info_entry *entry; 1976 snd_card_ro_proc_new(chip->card, "riptide", chip,
1978 1977 snd_riptide_proc_read);
1979 if (!snd_card_proc_new(chip->card, "riptide", &entry))
1980 snd_info_set_text_ops(entry, chip, snd_riptide_proc_read);
1981} 1978}
1982 1979
1983static int snd_riptide_mixer(struct snd_riptide *chip) 1980static int snd_riptide_mixer(struct snd_riptide *chip)
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 3ac8c71d567c..c6bcc0715716 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1568,10 +1568,7 @@ snd_rme32_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffe
1568 1568
1569static void snd_rme32_proc_init(struct rme32 *rme32) 1569static void snd_rme32_proc_init(struct rme32 *rme32)
1570{ 1570{
1571 struct snd_info_entry *entry; 1571 snd_card_ro_proc_new(rme32->card, "rme32", rme32, snd_rme32_proc_read);
1572
1573 if (! snd_card_proc_new(rme32->card, "rme32", &entry))
1574 snd_info_set_text_ops(entry, rme32, snd_rme32_proc_read);
1575} 1572}
1576 1573
1577/* 1574/*
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index dcfa4d7a73e2..42c6b5e09072 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -1868,10 +1868,7 @@ snd_rme96_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer
1868 1868
1869static void snd_rme96_proc_init(struct rme96 *rme96) 1869static void snd_rme96_proc_init(struct rme96 *rme96)
1870{ 1870{
1871 struct snd_info_entry *entry; 1871 snd_card_ro_proc_new(rme96->card, "rme96", rme96, snd_rme96_proc_read);
1872
1873 if (! snd_card_proc_new(rme96->card, "rme96", &entry))
1874 snd_info_set_text_ops(entry, rme96, snd_rme96_proc_read);
1875} 1872}
1876 1873
1877/* 1874/*
@@ -2388,8 +2385,6 @@ static int rme96_suspend(struct device *dev)
2388 struct rme96 *rme96 = card->private_data; 2385 struct rme96 *rme96 = card->private_data;
2389 2386
2390 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2387 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2391 snd_pcm_suspend(rme96->playback_substream);
2392 snd_pcm_suspend(rme96->capture_substream);
2393 2388
2394 /* save capture & playback pointers */ 2389 /* save capture & playback pointers */
2395 rme96->playback_pointer = readl(rme96->iobase + RME96_IO_GET_PLAY_POS) 2390 rme96->playback_pointer = readl(rme96->iobase + RME96_IO_GET_PLAY_POS)
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index ba99ff0e93e0..29bef48a3af3 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -3708,10 +3708,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3708 3708
3709static void snd_hdsp_proc_init(struct hdsp *hdsp) 3709static void snd_hdsp_proc_init(struct hdsp *hdsp)
3710{ 3710{
3711 struct snd_info_entry *entry; 3711 snd_card_ro_proc_new(hdsp->card, "hdsp", hdsp, snd_hdsp_proc_read);
3712
3713 if (! snd_card_proc_new(hdsp->card, "hdsp", &entry))
3714 snd_info_set_text_ops(entry, hdsp, snd_hdsp_proc_read);
3715} 3712}
3716 3713
3717static void snd_hdsp_free_buffers(struct hdsp *hdsp) 3714static void snd_hdsp_free_buffers(struct hdsp *hdsp)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 679ad0415e3b..1209cf0b05e0 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -5287,44 +5287,35 @@ static void snd_hdspm_proc_ports_out(struct snd_info_entry *entry,
5287 5287
5288static void snd_hdspm_proc_init(struct hdspm *hdspm) 5288static void snd_hdspm_proc_init(struct hdspm *hdspm)
5289{ 5289{
5290 struct snd_info_entry *entry; 5290 void (*read)(struct snd_info_entry *, struct snd_info_buffer *) = NULL;
5291 5291
5292 if (!snd_card_proc_new(hdspm->card, "hdspm", &entry)) { 5292 switch (hdspm->io_type) {
5293 switch (hdspm->io_type) { 5293 case AES32:
5294 case AES32: 5294 read = snd_hdspm_proc_read_aes32;
5295 snd_info_set_text_ops(entry, hdspm, 5295 break;
5296 snd_hdspm_proc_read_aes32); 5296 case MADI:
5297 break; 5297 read = snd_hdspm_proc_read_madi;
5298 case MADI: 5298 break;
5299 snd_info_set_text_ops(entry, hdspm, 5299 case MADIface:
5300 snd_hdspm_proc_read_madi); 5300 /* read = snd_hdspm_proc_read_madiface; */
5301 break; 5301 break;
5302 case MADIface: 5302 case RayDAT:
5303 /* snd_info_set_text_ops(entry, hdspm, 5303 read = snd_hdspm_proc_read_raydat;
5304 snd_hdspm_proc_read_madiface); */ 5304 break;
5305 break; 5305 case AIO:
5306 case RayDAT: 5306 break;
5307 snd_info_set_text_ops(entry, hdspm,
5308 snd_hdspm_proc_read_raydat);
5309 break;
5310 case AIO:
5311 break;
5312 }
5313 }
5314
5315 if (!snd_card_proc_new(hdspm->card, "ports.in", &entry)) {
5316 snd_info_set_text_ops(entry, hdspm, snd_hdspm_proc_ports_in);
5317 } 5307 }
5318 5308
5319 if (!snd_card_proc_new(hdspm->card, "ports.out", &entry)) { 5309 snd_card_ro_proc_new(hdspm->card, "hdspm", hdspm, read);
5320 snd_info_set_text_ops(entry, hdspm, snd_hdspm_proc_ports_out); 5310 snd_card_ro_proc_new(hdspm->card, "ports.in", hdspm,
5321 } 5311 snd_hdspm_proc_ports_in);
5312 snd_card_ro_proc_new(hdspm->card, "ports.out", hdspm,
5313 snd_hdspm_proc_ports_out);
5322 5314
5323#ifdef CONFIG_SND_DEBUG 5315#ifdef CONFIG_SND_DEBUG
5324 /* debug file to read all hdspm registers */ 5316 /* debug file to read all hdspm registers */
5325 if (!snd_card_proc_new(hdspm->card, "debug", &entry)) 5317 snd_card_ro_proc_new(hdspm->card, "debug", hdspm,
5326 snd_info_set_text_ops(entry, hdspm, 5318 snd_hdspm_proc_read_debug);
5327 snd_hdspm_proc_read_debug);
5328#endif 5319#endif
5329} 5320}
5330 5321
@@ -6411,7 +6402,6 @@ static int snd_hdspm_create_hwdep(struct snd_card *card,
6411 ------------------------------------------------------------*/ 6402 ------------------------------------------------------------*/
6412static int snd_hdspm_preallocate_memory(struct hdspm *hdspm) 6403static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
6413{ 6404{
6414 int err;
6415 struct snd_pcm *pcm; 6405 struct snd_pcm *pcm;
6416 size_t wanted; 6406 size_t wanted;
6417 6407
@@ -6419,21 +6409,10 @@ static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
6419 6409
6420 wanted = HDSPM_DMA_AREA_BYTES; 6410 wanted = HDSPM_DMA_AREA_BYTES;
6421 6411
6422 err = 6412 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
6423 snd_pcm_lib_preallocate_pages_for_all(pcm, 6413 snd_dma_pci_data(hdspm->pci),
6424 SNDRV_DMA_TYPE_DEV_SG, 6414 wanted, wanted);
6425 snd_dma_pci_data(hdspm->pci), 6415 dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted);
6426 wanted,
6427 wanted);
6428 if (err < 0) {
6429 dev_dbg(hdspm->card->dev,
6430 "Could not preallocate %zd Bytes\n", wanted);
6431
6432 return err;
6433 } else
6434 dev_dbg(hdspm->card->dev,
6435 " Preallocated %zd Bytes\n", wanted);
6436
6437 return 0; 6416 return 0;
6438} 6417}
6439 6418
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index edd765e22377..5228b982da5a 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -1737,10 +1737,8 @@ snd_rme9652_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buff
1737 1737
1738static void snd_rme9652_proc_init(struct snd_rme9652 *rme9652) 1738static void snd_rme9652_proc_init(struct snd_rme9652 *rme9652)
1739{ 1739{
1740 struct snd_info_entry *entry; 1740 snd_card_ro_proc_new(rme9652->card, "rme9652", rme9652,
1741 1741 snd_rme9652_proc_read);
1742 if (! snd_card_proc_new(rme9652->card, "rme9652", &entry))
1743 snd_info_set_text_ops(entry, rme9652, snd_rme9652_proc_read);
1744} 1742}
1745 1743
1746static void snd_rme9652_free_buffers(struct snd_rme9652 *rme9652) 1744static void snd_rme9652_free_buffers(struct snd_rme9652 *rme9652)
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 964acf302479..6b27980d77a8 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1214,7 +1214,6 @@ static int sis_suspend(struct device *dev)
1214 int i; 1214 int i;
1215 1215
1216 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1216 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1217 snd_pcm_suspend_all(sis->pcm);
1218 if (sis->codecs_present & SIS_PRIMARY_CODEC_PRESENT) 1217 if (sis->codecs_present & SIS_PRIMARY_CODEC_PRESENT)
1219 snd_ac97_suspend(sis->ac97[0]); 1218 snd_ac97_suspend(sis->ac97[0]);
1220 if (sis->codecs_present & SIS_SECONDARY_CODEC_PRESENT) 1219 if (sis->codecs_present & SIS_SECONDARY_CODEC_PRESENT)
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 7218f38b59db..71d5ad3cffd6 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1171,10 +1171,8 @@ static void snd_sonicvibes_proc_read(struct snd_info_entry *entry,
1171 1171
1172static void snd_sonicvibes_proc_init(struct sonicvibes *sonic) 1172static void snd_sonicvibes_proc_init(struct sonicvibes *sonic)
1173{ 1173{
1174 struct snd_info_entry *entry; 1174 snd_card_ro_proc_new(sonic->card, "sonicvibes", sonic,
1175 1175 snd_sonicvibes_proc_read);
1176 if (! snd_card_proc_new(sonic->card, "sonicvibes", &entry))
1177 snd_info_set_text_ops(entry, sonic, snd_sonicvibes_proc_read);
1178} 1176}
1179 1177
1180/* 1178/*
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 5523e193d556..0ff32d3f5d3b 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3320,13 +3320,11 @@ static void snd_trident_proc_read(struct snd_info_entry *entry,
3320 3320
3321static void snd_trident_proc_init(struct snd_trident *trident) 3321static void snd_trident_proc_init(struct snd_trident *trident)
3322{ 3322{
3323 struct snd_info_entry *entry;
3324 const char *s = "trident"; 3323 const char *s = "trident";
3325 3324
3326 if (trident->device == TRIDENT_DEVICE_ID_SI7018) 3325 if (trident->device == TRIDENT_DEVICE_ID_SI7018)
3327 s = "sis7018"; 3326 s = "sis7018";
3328 if (! snd_card_proc_new(trident->card, s, &entry)) 3327 snd_card_ro_proc_new(trident->card, s, trident, snd_trident_proc_read);
3329 snd_info_set_text_ops(entry, trident, snd_trident_proc_read);
3330} 3328}
3331 3329
3332static int snd_trident_dev_free(struct snd_device *device) 3330static int snd_trident_dev_free(struct snd_device *device)
@@ -3915,10 +3913,6 @@ static int snd_trident_suspend(struct device *dev)
3915 3913
3916 trident->in_suspend = 1; 3914 trident->in_suspend = 1;
3917 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3915 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3918 snd_pcm_suspend_all(trident->pcm);
3919 snd_pcm_suspend_all(trident->foldback);
3920 snd_pcm_suspend_all(trident->spdif);
3921
3922 snd_ac97_suspend(trident->ac97); 3916 snd_ac97_suspend(trident->ac97);
3923 snd_ac97_suspend(trident->ac97_sec); 3917 snd_ac97_suspend(trident->ac97_sec);
3924 return 0; 3918 return 0;
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index c488c5afa195..dee1c487d6ba 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2144,10 +2144,8 @@ static void snd_via82xx_proc_read(struct snd_info_entry *entry,
2144 2144
2145static void snd_via82xx_proc_init(struct via82xx *chip) 2145static void snd_via82xx_proc_init(struct via82xx *chip)
2146{ 2146{
2147 struct snd_info_entry *entry; 2147 snd_card_ro_proc_new(chip->card, "via82xx", chip,
2148 2148 snd_via82xx_proc_read);
2149 if (! snd_card_proc_new(chip->card, "via82xx", &entry))
2150 snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read);
2151} 2149}
2152 2150
2153/* 2151/*
@@ -2278,8 +2276,6 @@ static int snd_via82xx_suspend(struct device *dev)
2278 int i; 2276 int i;
2279 2277
2280 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2278 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2281 for (i = 0; i < 2; i++)
2282 snd_pcm_suspend_all(chip->pcms[i]);
2283 for (i = 0; i < chip->num_devs; i++) 2279 for (i = 0; i < chip->num_devs; i++)
2284 snd_via82xx_channel_reset(chip, &chip->devs[i]); 2280 snd_via82xx_channel_reset(chip, &chip->devs[i]);
2285 synchronize_irq(chip->irq); 2281 synchronize_irq(chip->irq);
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index b13c8688cc8d..7e0bebce7b77 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -865,11 +865,9 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip)
865 init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); 865 init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
866 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); 866 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
867 867
868 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 868 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
869 snd_dma_pci_data(chip->pci), 869 snd_dma_pci_data(chip->pci),
870 64*1024, 128*1024)) < 0) 870 64*1024, 128*1024);
871 return err;
872
873 return 0; 871 return 0;
874} 872}
875 873
@@ -937,10 +935,8 @@ static void snd_via82xx_proc_read(struct snd_info_entry *entry, struct snd_info_
937 935
938static void snd_via82xx_proc_init(struct via82xx_modem *chip) 936static void snd_via82xx_proc_init(struct via82xx_modem *chip)
939{ 937{
940 struct snd_info_entry *entry; 938 snd_card_ro_proc_new(chip->card, "via82xx", chip,
941 939 snd_via82xx_proc_read);
942 if (! snd_card_proc_new(chip->card, "via82xx", &entry))
943 snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read);
944} 940}
945 941
946/* 942/*
@@ -1038,8 +1034,6 @@ static int snd_via82xx_suspend(struct device *dev)
1038 int i; 1034 int i;
1039 1035
1040 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1036 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1041 for (i = 0; i < 2; i++)
1042 snd_pcm_suspend_all(chip->pcms[i]);
1043 for (i = 0; i < chip->num_devs; i++) 1037 for (i = 0; i < chip->num_devs; i++)
1044 snd_via82xx_channel_reset(chip, &chip->devs[i]); 1038 snd_via82xx_channel_reset(chip, &chip->devs[i]);
1045 synchronize_irq(chip->irq); 1039 synchronize_irq(chip->irq);
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index a4926fb03991..4d48877f211f 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -1985,11 +1985,7 @@ static void snd_ymfpci_proc_read(struct snd_info_entry *entry,
1985 1985
1986static int snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) 1986static int snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip)
1987{ 1987{
1988 struct snd_info_entry *entry; 1988 return snd_card_ro_proc_new(card, "ymfpci", chip, snd_ymfpci_proc_read);
1989
1990 if (! snd_card_proc_new(card, "ymfpci", &entry))
1991 snd_info_set_text_ops(entry, chip, snd_ymfpci_proc_read);
1992 return 0;
1993} 1989}
1994 1990
1995/* 1991/*
@@ -2304,10 +2300,6 @@ static int snd_ymfpci_suspend(struct device *dev)
2304 unsigned int i; 2300 unsigned int i;
2305 2301
2306 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2302 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2307 snd_pcm_suspend_all(chip->pcm);
2308 snd_pcm_suspend_all(chip->pcm2);
2309 snd_pcm_suspend_all(chip->pcm_spdif);
2310 snd_pcm_suspend_all(chip->pcm_4ch);
2311 snd_ac97_suspend(chip->ac97); 2303 snd_ac97_suspend(chip->ac97);
2312 for (i = 0; i < YDSXGR_NUM_SAVED_REGS; i++) 2304 for (i = 0; i < YDSXGR_NUM_SAVED_REGS; i++)
2313 chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]); 2305 chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]);
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
index d724ab0653cf..910478275fd9 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
@@ -148,10 +148,7 @@ static void pdacf_proc_read(struct snd_info_entry * entry,
148 148
149static void pdacf_proc_init(struct snd_pdacf *chip) 149static void pdacf_proc_init(struct snd_pdacf *chip)
150{ 150{
151 struct snd_info_entry *entry; 151 snd_card_ro_proc_new(chip->card, "pdaudiocf", chip, pdacf_proc_read);
152
153 if (! snd_card_proc_new(chip->card, "pdaudiocf", &entry))
154 snd_info_set_text_ops(entry, chip, pdacf_proc_read);
155} 152}
156 153
157struct snd_pdacf *snd_pdacf_create(struct snd_card *card) 154struct snd_pdacf *snd_pdacf_create(struct snd_card *card)
@@ -265,7 +262,6 @@ int snd_pdacf_suspend(struct snd_pdacf *chip)
265 u16 val; 262 u16 val;
266 263
267 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); 264 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
268 snd_pcm_suspend_all(chip->pcm);
269 /* disable interrupts, but use direct write to preserve old register value in chip->regmap */ 265 /* disable interrupts, but use direct write to preserve old register value in chip->regmap */
270 val = inw(chip->port + PDAUDIOCF_REG_IER); 266 val = inw(chip->port + PDAUDIOCF_REG_IER);
271 val &= ~(PDAUDIOCF_IRQOVREN|PDAUDIOCF_IRQAKMEN|PDAUDIOCF_IRQLVLEN0|PDAUDIOCF_IRQLVLEN1); 267 val &= ~(PDAUDIOCF_IRQOVREN|PDAUDIOCF_IRQAKMEN|PDAUDIOCF_IRQLVLEN0|PDAUDIOCF_IRQLVLEN1);
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index d692e4070167..6d420bd3ae17 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1365,7 +1365,6 @@ void snd_pmac_suspend(struct snd_pmac *chip)
1365 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); 1365 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
1366 if (chip->suspend) 1366 if (chip->suspend)
1367 chip->suspend(chip); 1367 chip->suspend(chip);
1368 snd_pcm_suspend_all(chip->pcm);
1369 spin_lock_irqsave(&chip->reg_lock, flags); 1368 spin_lock_irqsave(&chip->reg_lock, flags);
1370 snd_pmac_beep_stop(chip); 1369 snd_pmac_beep_stop(chip);
1371 spin_unlock_irqrestore(&chip->reg_lock, flags); 1370 spin_unlock_irqrestore(&chip->reg_lock, flags);
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
index abe031c9d592..521236efcc4d 100644
--- a/sound/ppc/snd_ps3.c
+++ b/sound/ppc/snd_ps3.c
@@ -1024,15 +1024,11 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
1024 1024
1025 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; 1025 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED;
1026 /* pre-alloc PCM DMA buffer*/ 1026 /* pre-alloc PCM DMA buffer*/
1027 ret = snd_pcm_lib_preallocate_pages_for_all(the_card.pcm, 1027 snd_pcm_lib_preallocate_pages_for_all(the_card.pcm,
1028 SNDRV_DMA_TYPE_DEV, 1028 SNDRV_DMA_TYPE_DEV,
1029 &dev->core, 1029 &dev->core,
1030 SND_PS3_PCM_PREALLOC_SIZE, 1030 SND_PS3_PCM_PREALLOC_SIZE,
1031 SND_PS3_PCM_PREALLOC_SIZE); 1031 SND_PS3_PCM_PREALLOC_SIZE);
1032 if (ret < 0) {
1033 pr_info("%s: prealloc failed\n", __func__);
1034 goto clean_card;
1035 }
1036 1032
1037 /* 1033 /*
1038 * allocate null buffer 1034 * allocate null buffer
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 2b26311405a4..e7fef3fce44a 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -464,14 +464,12 @@ static int __init snd_aicapcmchip(struct snd_card_aica
464 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 464 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
465 &snd_aicapcm_playback_ops); 465 &snd_aicapcm_playback_ops);
466 /* Allocate the DMA buffers */ 466 /* Allocate the DMA buffers */
467 err = 467 snd_pcm_lib_preallocate_pages_for_all(pcm,
468 snd_pcm_lib_preallocate_pages_for_all(pcm, 468 SNDRV_DMA_TYPE_CONTINUOUS,
469 SNDRV_DMA_TYPE_CONTINUOUS, 469 snd_dma_continuous_data(GFP_KERNEL),
470 snd_dma_continuous_data 470 AICA_BUFFER_SIZE,
471 (GFP_KERNEL), 471 AICA_BUFFER_SIZE);
472 AICA_BUFFER_SIZE, 472 return 0;
473 AICA_BUFFER_SIZE);
474 return err;
475} 473}
476 474
477/* Mixer controls */ 475/* Mixer controls */
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index f4011bebc7ec..2391c7f1dd2d 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -1142,7 +1142,6 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd)
1142 1142
1143static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) 1143static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
1144{ 1144{
1145 int ret;
1146 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, 1145 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd,
1147 DRV_NAME); 1146 DRV_NAME);
1148 struct audio_drv_data *adata = dev_get_drvdata(component->dev); 1147 struct audio_drv_data *adata = dev_get_drvdata(component->dev);
@@ -1150,24 +1149,21 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
1150 1149
1151 switch (adata->asic_type) { 1150 switch (adata->asic_type) {
1152 case CHIP_STONEY: 1151 case CHIP_STONEY:
1153 ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 1152 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
1154 SNDRV_DMA_TYPE_DEV, 1153 SNDRV_DMA_TYPE_DEV,
1155 parent, 1154 parent,
1156 ST_MIN_BUFFER, 1155 ST_MIN_BUFFER,
1157 ST_MAX_BUFFER); 1156 ST_MAX_BUFFER);
1158 break; 1157 break;
1159 default: 1158 default:
1160 ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 1159 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
1161 SNDRV_DMA_TYPE_DEV, 1160 SNDRV_DMA_TYPE_DEV,
1162 parent, 1161 parent,
1163 MIN_BUFFER, 1162 MIN_BUFFER,
1164 MAX_BUFFER); 1163 MAX_BUFFER);
1165 break; 1164 break;
1166 } 1165 }
1167 if (ret < 0) 1166 return 0;
1168 dev_err(component->dev,
1169 "buffer preallocation failure error:%d\n", ret);
1170 return ret;
1171} 1167}
1172 1168
1173static int acp_dma_close(struct snd_pcm_substream *substream) 1169static int acp_dma_close(struct snd_pcm_substream *substream)
diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 3d58338fa3cf..1a2e15ff1456 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -367,10 +367,10 @@ static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_pcm_substream *substream)
367 367
368static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd) 368static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd)
369{ 369{
370 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 370 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
371 SNDRV_DMA_TYPE_DEV, 371 rtd->pcm->card->dev,
372 NULL, MIN_BUFFER, 372 MIN_BUFFER, MAX_BUFFER);
373 MAX_BUFFER); 373 return 0;
374} 374}
375 375
376static int acp3x_dma_hw_free(struct snd_pcm_substream *substream) 376static int acp3x_dma_hw_free(struct snd_pcm_substream *substream)
diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c
index 2cc9632024fc..a9ae91c4597f 100644
--- a/sound/soc/dwc/dwc-pcm.c
+++ b/sound/soc/dwc/dwc-pcm.c
@@ -249,9 +249,10 @@ static int dw_pcm_new(struct snd_soc_pcm_runtime *rtd)
249{ 249{
250 size_t size = dw_pcm_hardware.buffer_bytes_max; 250 size_t size = dw_pcm_hardware.buffer_bytes_max;
251 251
252 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 252 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
253 SNDRV_DMA_TYPE_CONTINUOUS, 253 SNDRV_DMA_TYPE_CONTINUOUS,
254 snd_dma_continuous_data(GFP_KERNEL), size, size); 254 snd_dma_continuous_data(GFP_KERNEL), size, size);
255 return 0;
255} 256}
256 257
257static void dw_pcm_free(struct snd_pcm *pcm) 258static void dw_pcm_free(struct snd_pcm *pcm)
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index b0873fea23ab..08cea5b5cda9 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -687,20 +687,15 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
687{ 687{
688 struct snd_soc_dai *dai = rtd->cpu_dai; 688 struct snd_soc_dai *dai = rtd->cpu_dai;
689 struct snd_pcm *pcm = rtd->pcm; 689 struct snd_pcm *pcm = rtd->pcm;
690 int retval = 0;
691 690
692 if (dai->driver->playback.channels_min || 691 if (dai->driver->playback.channels_min ||
693 dai->driver->capture.channels_min) { 692 dai->driver->capture.channels_min) {
694 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, 693 snd_pcm_lib_preallocate_pages_for_all(pcm,
695 SNDRV_DMA_TYPE_CONTINUOUS, 694 SNDRV_DMA_TYPE_CONTINUOUS,
696 snd_dma_continuous_data(GFP_DMA), 695 snd_dma_continuous_data(GFP_DMA),
697 SST_MIN_BUFFER, SST_MAX_BUFFER); 696 SST_MIN_BUFFER, SST_MAX_BUFFER);
698 if (retval) {
699 dev_err(rtd->dev, "dma buffer allocation failure\n");
700 return retval;
701 }
702 } 697 }
703 return retval; 698 return 0;
704} 699}
705 700
706static int sst_soc_probe(struct snd_soc_component *component) 701static int sst_soc_probe(struct snd_soc_component *component)
diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
index 498fb5346f1a..5373605de0af 100644
--- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c
+++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
@@ -327,23 +327,16 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd)
327 size_t size; 327 size_t size;
328 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); 328 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
329 struct sst_pdata *pdata = dev_get_platdata(component->dev); 329 struct sst_pdata *pdata = dev_get_platdata(component->dev);
330 int ret = 0;
331 330
332 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || 331 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
333 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 332 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
334 size = sst_byt_pcm_hardware.buffer_bytes_max; 333 size = sst_byt_pcm_hardware.buffer_bytes_max;
335 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 334 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
336 SNDRV_DMA_TYPE_DEV, 335 pdata->dma_dev,
337 pdata->dma_dev, 336 size, size);
338 size, size);
339 if (ret) {
340 dev_err(rtd->dev, "dma buffer allocation failed %d\n",
341 ret);
342 return ret;
343 }
344 } 337 }
345 338
346 return ret; 339 return 0;
347} 340}
348 341
349static struct snd_soc_dai_driver byt_dais[] = { 342static struct snd_soc_dai_driver byt_dais[] = {
diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c
index 2debcc2ed99a..e023c4c3e5a9 100644
--- a/sound/soc/intel/haswell/sst-haswell-pcm.c
+++ b/sound/soc/intel/haswell/sst-haswell-pcm.c
@@ -946,27 +946,21 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
946 struct sst_pdata *pdata = dev_get_platdata(component->dev); 946 struct sst_pdata *pdata = dev_get_platdata(component->dev);
947 struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); 947 struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev);
948 struct device *dev = pdata->dma_dev; 948 struct device *dev = pdata->dma_dev;
949 int ret = 0;
950 949
951 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || 950 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
952 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 951 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
953 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 952 snd_pcm_lib_preallocate_pages_for_all(pcm,
954 SNDRV_DMA_TYPE_DEV_SG, 953 SNDRV_DMA_TYPE_DEV_SG,
955 dev, 954 dev,
956 hsw_pcm_hardware.buffer_bytes_max, 955 hsw_pcm_hardware.buffer_bytes_max,
957 hsw_pcm_hardware.buffer_bytes_max); 956 hsw_pcm_hardware.buffer_bytes_max);
958 if (ret) {
959 dev_err(rtd->dev, "dma buffer allocation failed %d\n",
960 ret);
961 return ret;
962 }
963 } 957 }
964 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) 958 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
965 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm; 959 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm;
966 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) 960 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream)
967 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm; 961 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm;
968 962
969 return ret; 963 return 0;
970} 964}
971 965
972#define HSW_FORMATS \ 966#define HSW_FORMATS \
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 8e589d698c58..088e6b2fb1bc 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1289,7 +1289,6 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1289 struct hdac_bus *bus = dev_get_drvdata(dai->dev); 1289 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1290 struct snd_pcm *pcm = rtd->pcm; 1290 struct snd_pcm *pcm = rtd->pcm;
1291 unsigned int size; 1291 unsigned int size;
1292 int retval = 0;
1293 struct skl *skl = bus_to_skl(bus); 1292 struct skl *skl = bus_to_skl(bus);
1294 1293
1295 if (dai->driver->playback.channels_min || 1294 if (dai->driver->playback.channels_min ||
@@ -1298,17 +1297,13 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1298 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024; 1297 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1299 if (size > MAX_PREALLOC_SIZE) 1298 if (size > MAX_PREALLOC_SIZE)
1300 size = MAX_PREALLOC_SIZE; 1299 size = MAX_PREALLOC_SIZE;
1301 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, 1300 snd_pcm_lib_preallocate_pages_for_all(pcm,
1302 SNDRV_DMA_TYPE_DEV_SG, 1301 SNDRV_DMA_TYPE_DEV_SG,
1303 snd_dma_pci_data(skl->pci), 1302 snd_dma_pci_data(skl->pci),
1304 size, MAX_PREALLOC_SIZE); 1303 size, MAX_PREALLOC_SIZE);
1305 if (retval) {
1306 dev_err(dai->dev, "dma buffer allocation fail\n");
1307 return retval;
1308 }
1309 } 1304 }
1310 1305
1311 return retval; 1306 return 0;
1312} 1307}
1313 1308
1314static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) 1309static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
index 697aa50aff9a..3ce527ce30ce 100644
--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
@@ -126,9 +126,9 @@ int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
126 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); 126 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
127 127
128 size = afe->mtk_afe_hardware->buffer_bytes_max; 128 size = afe->mtk_afe_hardware->buffer_bytes_max;
129 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 129 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
130 afe->dev, 130 afe->dev, size, size);
131 size, size); 131 return 0;
132} 132}
133EXPORT_SYMBOL_GPL(mtk_afe_pcm_new); 133EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);
134 134
diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
index 0e4f65e654c4..75e5e480fda2 100644
--- a/sound/soc/meson/axg-fifo.c
+++ b/sound/soc/meson/axg-fifo.c
@@ -267,9 +267,10 @@ int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type)
267 struct snd_card *card = rtd->card->snd_card; 267 struct snd_card *card = rtd->card->snd_card;
268 size_t size = axg_fifo_hw.buffer_bytes_max; 268 size_t size = axg_fifo_hw.buffer_bytes_max;
269 269
270 return snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream, 270 snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream,
271 SNDRV_DMA_TYPE_DEV, card->dev, 271 SNDRV_DMA_TYPE_DEV, card->dev,
272 size, size); 272 size, size);
273 return 0;
273} 274}
274EXPORT_SYMBOL_GPL(axg_fifo_pcm_new); 275EXPORT_SYMBOL_GPL(axg_fifo_pcm_new);
275 276
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index aa7e902f0c02..285afbafa662 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -1768,11 +1768,12 @@ static const struct snd_pcm_ops fsi_pcm_ops = {
1768 1768
1769static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) 1769static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
1770{ 1770{
1771 return snd_pcm_lib_preallocate_pages_for_all( 1771 snd_pcm_lib_preallocate_pages_for_all(
1772 rtd->pcm, 1772 rtd->pcm,
1773 SNDRV_DMA_TYPE_DEV, 1773 SNDRV_DMA_TYPE_DEV,
1774 rtd->card->snd_card->dev, 1774 rtd->card->snd_card->dev,
1775 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); 1775 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1776 return 0;
1776} 1777}
1777 1778
1778/* 1779/*
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 9834474684b1..022996d2db13 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1573,7 +1573,6 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
1573 struct rsnd_priv *priv = rsnd_io_to_priv(io); 1573 struct rsnd_priv *priv = rsnd_io_to_priv(io);
1574 struct device *dev = rsnd_priv_to_dev(priv); 1574 struct device *dev = rsnd_priv_to_dev(priv);
1575 struct snd_pcm_substream *substream; 1575 struct snd_pcm_substream *substream;
1576 int err;
1577 1576
1578 /* 1577 /*
1579 * use Audio-DMAC dev if we can use IPMMU 1578 * use Audio-DMAC dev if we can use IPMMU
@@ -1586,12 +1585,10 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
1586 for (substream = rtd->pcm->streams[stream].substream; 1585 for (substream = rtd->pcm->streams[stream].substream;
1587 substream; 1586 substream;
1588 substream = substream->next) { 1587 substream = substream->next) {
1589 err = snd_pcm_lib_preallocate_pages(substream, 1588 snd_pcm_lib_preallocate_pages(substream,
1590 SNDRV_DMA_TYPE_DEV, 1589 SNDRV_DMA_TYPE_DEV,
1591 dev, 1590 dev,
1592 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); 1591 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1593 if (err < 0)
1594 return err;
1595 } 1592 }
1596 1593
1597 return 0; 1594 return 0;
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c
index e263757e4a69..78c3145b4109 100644
--- a/sound/soc/sh/siu_pcm.c
+++ b/sound/soc/sh/siu_pcm.c
@@ -541,15 +541,9 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)
541 if (ret < 0) 541 if (ret < 0)
542 return ret; 542 return ret;
543 543
544 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 544 snd_pcm_lib_preallocate_pages_for_all(pcm,
545 SNDRV_DMA_TYPE_DEV, NULL, 545 SNDRV_DMA_TYPE_DEV, card->dev,
546 SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX); 546 SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX);
547 if (ret < 0) {
548 dev_err(card->dev,
549 "snd_pcm_lib_preallocate_pages_for_all() err=%d",
550 ret);
551 goto fail;
552 }
553 547
554 (*port_info)->pcm = pcm; 548 (*port_info)->pcm = pcm;
555 549
@@ -562,11 +556,6 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)
562 556
563 dev_info(card->dev, "SuperH SIU driver initialized.\n"); 557 dev_info(card->dev, "SuperH SIU driver initialized.\n");
564 return 0; 558 return 0;
565
566fail:
567 siu_free_port(siu_ports[pdev->id]);
568 dev_err(card->dev, "SIU: failed to initialize.\n");
569 return ret;
570} 559}
571 560
572static void siu_pcm_free(struct snd_pcm *pcm) 561static void siu_pcm_free(struct snd_pcm *pcm)
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 30e791a53352..46252b13d3b3 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -270,7 +270,6 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
270 size_t prealloc_buffer_size; 270 size_t prealloc_buffer_size;
271 size_t max_buffer_size; 271 size_t max_buffer_size;
272 unsigned int i; 272 unsigned int i;
273 int ret;
274 273
275 if (config && config->prealloc_buffer_size) { 274 if (config && config->prealloc_buffer_size) {
276 prealloc_buffer_size = config->prealloc_buffer_size; 275 prealloc_buffer_size = config->prealloc_buffer_size;
@@ -303,13 +302,11 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
303 return -EINVAL; 302 return -EINVAL;
304 } 303 }
305 304
306 ret = snd_pcm_lib_preallocate_pages(substream, 305 snd_pcm_lib_preallocate_pages(substream,
307 SNDRV_DMA_TYPE_DEV_IRAM, 306 SNDRV_DMA_TYPE_DEV_IRAM,
308 dmaengine_dma_dev(pcm, substream), 307 dmaengine_dma_dev(pcm, substream),
309 prealloc_buffer_size, 308 prealloc_buffer_size,
310 max_buffer_size); 309 max_buffer_size);
311 if (ret)
312 return ret;
313 310
314 if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i])) 311 if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i]))
315 pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE; 312 pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index a5b40e82dea4..0d5ec68a1e50 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -3159,6 +3159,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
3159 } 3159 }
3160 3160
3161 pcm->private_free = soc_pcm_private_free; 3161 pcm->private_free = soc_pcm_private_free;
3162 pcm->no_device_suspend = true;
3162out: 3163out:
3163 dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", 3164 dev_info(rtd->card->dev, "%s <-> %s mapping ok\n",
3164 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name, 3165 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name,
diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 706ff005234f..47901983a6ff 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -262,8 +262,9 @@ static int stm32_adfsdm_pcm_new(struct snd_soc_pcm_runtime *rtd)
262 snd_soc_dai_get_drvdata(rtd->cpu_dai); 262 snd_soc_dai_get_drvdata(rtd->cpu_dai);
263 unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE; 263 unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE;
264 264
265 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 265 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
266 priv->dev, size, size); 266 priv->dev, size, size);
267 return 0;
267} 268}
268 269
269static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm) 270static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm)
diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c
index 8d31fe628e2f..089bd7518606 100644
--- a/sound/soc/txx9/txx9aclc.c
+++ b/sound/soc/txx9/txx9aclc.c
@@ -313,8 +313,10 @@ static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd)
313 if (ret) 313 if (ret)
314 goto exit; 314 goto exit;
315 } 315 }
316 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 316
317 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
317 card->dev, 64 * 1024, 4 * 1024 * 1024); 318 card->dev, 64 * 1024, 4 * 1024 * 1024);
319 return 0;
318 320
319exit: 321exit:
320 for (i = 0; i < 2; i++) { 322 for (i = 0; i < 2; i++) {
diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c
index 4ec6b65bfb44..fa001d3c1a88 100644
--- a/sound/soc/uniphier/aio-dma.c
+++ b/sound/soc/uniphier/aio-dma.c
@@ -235,10 +235,11 @@ static int uniphier_aiodma_new(struct snd_soc_pcm_runtime *rtd)
235 if (ret) 235 if (ret)
236 return ret; 236 return ret;
237 237
238 return snd_pcm_lib_preallocate_pages_for_all(pcm, 238 snd_pcm_lib_preallocate_pages_for_all(pcm,
239 SNDRV_DMA_TYPE_DEV, dev, 239 SNDRV_DMA_TYPE_DEV, dev,
240 uniphier_aiodma_hw.buffer_bytes_max, 240 uniphier_aiodma_hw.buffer_bytes_max,
241 uniphier_aiodma_hw.buffer_bytes_max); 241 uniphier_aiodma_hw.buffer_bytes_max);
242 return 0;
242} 243}
243 244
244static void uniphier_aiodma_free(struct snd_pcm *pcm) 245static void uniphier_aiodma_free(struct snd_pcm *pcm)
diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c
index 503560916620..2f20a02c8d46 100644
--- a/sound/soc/xtensa/xtfpga-i2s.c
+++ b/sound/soc/xtensa/xtfpga-i2s.c
@@ -469,9 +469,9 @@ static int xtfpga_pcm_new(struct snd_soc_pcm_runtime *rtd)
469 struct snd_card *card = rtd->card->snd_card; 469 struct snd_card *card = rtd->card->snd_card;
470 size_t size = xtfpga_pcm_hardware.buffer_bytes_max; 470 size_t size = xtfpga_pcm_hardware.buffer_bytes_max;
471 471
472 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 472 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
473 SNDRV_DMA_TYPE_DEV, 473 card->dev, size, size);
474 card->dev, size, size); 474 return 0;
475} 475}
476 476
477static const struct snd_pcm_ops xtfpga_pcm_ops = { 477static const struct snd_pcm_ops xtfpga_pcm_ops = {
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 9e71d7cda999..2b8ef5fe6688 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -2243,12 +2243,9 @@ static int snd_dbri_pcm(struct snd_card *card)
2243 pcm->info_flags = 0; 2243 pcm->info_flags = 0;
2244 strcpy(pcm->name, card->shortname); 2244 strcpy(pcm->name, card->shortname);
2245 2245
2246 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, 2246 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
2247 SNDRV_DMA_TYPE_CONTINUOUS, 2247 snd_dma_continuous_data(GFP_KERNEL),
2248 snd_dma_continuous_data(GFP_KERNEL), 2248 64 * 1024, 64 * 1024);
2249 64 * 1024, 64 * 1024)) < 0)
2250 return err;
2251
2252 return 0; 2249 return 0;
2253} 2250}
2254 2251
@@ -2510,16 +2507,10 @@ static void dbri_debug_read(struct snd_info_entry *entry,
2510static void snd_dbri_proc(struct snd_card *card) 2507static void snd_dbri_proc(struct snd_card *card)
2511{ 2508{
2512 struct snd_dbri *dbri = card->private_data; 2509 struct snd_dbri *dbri = card->private_data;
2513 struct snd_info_entry *entry;
2514
2515 if (!snd_card_proc_new(card, "regs", &entry))
2516 snd_info_set_text_ops(entry, dbri, dbri_regs_read);
2517 2510
2511 snd_card_ro_proc_new(card, "regs", dbri, dbri_regs_read);
2518#ifdef DBRI_DEBUG 2512#ifdef DBRI_DEBUG
2519 if (!snd_card_proc_new(card, "debug", &entry)) { 2513 snd_card_ro_proc_new(card, "debug", dbri, dbri_debug_read);
2520 snd_info_set_text_ops(entry, dbri, dbri_debug_read);
2521 entry->mode = S_IFREG | 0444; /* Readable only. */
2522 }
2523#endif 2514#endif
2524} 2515}
2525 2516
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 1ef52edeb538..8707e0108471 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -350,7 +350,7 @@ static int snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device)
350 350
351 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops); 351 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops);
352 352
353 retval = snd_pcm_lib_preallocate_pages_for_all(chip->pcm, 353 snd_pcm_lib_preallocate_pages_for_all(chip->pcm,
354 SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev, 354 SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev,
355 64 * 1024, 64 * 1024); 355 64 * 1024, 64 * 1024);
356out: 356out:
diff --git a/sound/synth/emux/emux_proc.c b/sound/synth/emux/emux_proc.c
index a82b4053bee8..c14781ac7941 100644
--- a/sound/synth/emux/emux_proc.c
+++ b/sound/synth/emux/emux_proc.c
@@ -115,10 +115,6 @@ void snd_emux_proc_init(struct snd_emux *emu, struct snd_card *card, int device)
115 entry->content = SNDRV_INFO_CONTENT_TEXT; 115 entry->content = SNDRV_INFO_CONTENT_TEXT;
116 entry->private_data = emu; 116 entry->private_data = emu;
117 entry->c.text.read = snd_emux_proc_info_read; 117 entry->c.text.read = snd_emux_proc_info_read;
118 if (snd_info_register(entry) < 0)
119 snd_info_free_entry(entry);
120 else
121 emu->proc = entry;
122} 118}
123 119
124void snd_emux_proc_free(struct snd_emux *emu) 120void snd_emux_proc_free(struct snd_emux *emu)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 746a72e23cf9..719e10034553 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -811,7 +811,6 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
811 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); 811 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
812 if (!chip->num_suspended_intf++) { 812 if (!chip->num_suspended_intf++) {
813 list_for_each_entry(as, &chip->pcm_list, list) { 813 list_for_each_entry(as, &chip->pcm_list, list) {
814 snd_pcm_suspend_all(as->pcm);
815 snd_usb_pcm_suspend(as); 814 snd_usb_pcm_suspend(as);
816 as->substream[0].need_setup_ep = 815 as->substream[0].need_setup_ep =
817 as->substream[1].need_setup_ep = true; 816 as->substream[1].need_setup_ep = true;
diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
index c1376bfdc90b..7afe8fae4939 100644
--- a/sound/usb/line6/driver.c
+++ b/sound/usb/line6/driver.c
@@ -849,10 +849,8 @@ int line6_suspend(struct usb_interface *interface, pm_message_t message)
849 if (line6->properties->capabilities & LINE6_CAP_CONTROL) 849 if (line6->properties->capabilities & LINE6_CAP_CONTROL)
850 line6_stop_listen(line6); 850 line6_stop_listen(line6);
851 851
852 if (line6pcm != NULL) { 852 if (line6pcm != NULL)
853 snd_pcm_suspend_all(line6pcm->pcm);
854 line6pcm->flags = 0; 853 line6pcm->flags = 0;
855 }
856 854
857 return 0; 855 return 0;
858} 856}
diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c
index 020c81818951..ce45b6dab651 100644
--- a/sound/usb/line6/pod.c
+++ b/sound/usb/line6/pod.c
@@ -320,7 +320,8 @@ static void pod_startup4(struct work_struct *work)
320 line6_read_serial_number(&pod->line6, &pod->serial_number); 320 line6_read_serial_number(&pod->line6, &pod->serial_number);
321 321
322 /* ALSA audio interface: */ 322 /* ALSA audio interface: */
323 snd_card_register(line6->card); 323 if (snd_card_register(line6->card))
324 dev_err(line6->ifcdev, "Failed to register POD card.\n");
324} 325}
325 326
326/* POD special files: */ 327/* POD special files: */
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index e7d441d0e839..73d7dff425c1 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1835,7 +1835,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
1835{ 1835{
1836 int channels, i, j; 1836 int channels, i, j;
1837 struct usb_audio_term iterm; 1837 struct usb_audio_term iterm;
1838 unsigned int master_bits, first_ch_bits; 1838 unsigned int master_bits;
1839 int err, csize; 1839 int err, csize;
1840 struct uac_feature_unit_descriptor *hdr = _ftr; 1840 struct uac_feature_unit_descriptor *hdr = _ftr;
1841 __u8 *bmaControls; 1841 __u8 *bmaControls;
@@ -1926,10 +1926,6 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
1926 break; 1926 break;
1927 1927
1928 } 1928 }
1929 if (channels > 0)
1930 first_ch_bits = snd_usb_combine_bytes(bmaControls + csize, csize);
1931 else
1932 first_ch_bits = 0;
1933 1929
1934 if (state->mixer->protocol == UAC_VERSION_1) { 1930 if (state->mixer->protocol == UAC_VERSION_1) {
1935 /* check all control types */ 1931 /* check all control types */
@@ -3445,7 +3441,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
3445 .dev_free = snd_usb_mixer_dev_free 3441 .dev_free = snd_usb_mixer_dev_free
3446 }; 3442 };
3447 struct usb_mixer_interface *mixer; 3443 struct usb_mixer_interface *mixer;
3448 struct snd_info_entry *entry;
3449 int err; 3444 int err;
3450 3445
3451 strcpy(chip->card->mixername, "USB Mixer"); 3446 strcpy(chip->card->mixername, "USB Mixer");
@@ -3501,9 +3496,9 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
3501 if (err < 0) 3496 if (err < 0)
3502 goto _error; 3497 goto _error;
3503 3498
3504 if (list_empty(&chip->mixer_list) && 3499 if (list_empty(&chip->mixer_list))
3505 !snd_card_proc_new(chip->card, "usbmixer", &entry)) 3500 snd_card_ro_proc_new(chip->card, "usbmixer", chip,
3506 snd_info_set_text_ops(entry, chip, snd_usb_mixer_proc_read); 3501 snd_usb_mixer_proc_read);
3507 3502
3508 list_add(&mixer->list, &chip->mixer_list); 3503 list_add(&mixer->list, &chip->mixer_list);
3509 return 0; 3504 return 0;
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 85ae0ff2382a..a751a18ca4c2 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2195,7 +2195,6 @@ static int snd_rme_controls_create(struct usb_mixer_interface *mixer)
2195int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) 2195int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
2196{ 2196{
2197 int err = 0; 2197 int err = 0;
2198 struct snd_info_entry *entry;
2199 2198
2200 err = snd_usb_soundblaster_remote_init(mixer); 2199 err = snd_usb_soundblaster_remote_init(mixer);
2201 if (err < 0) 2200 if (err < 0)
@@ -2214,9 +2213,8 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
2214 err = snd_audigy2nx_controls_create(mixer); 2213 err = snd_audigy2nx_controls_create(mixer);
2215 if (err < 0) 2214 if (err < 0)
2216 break; 2215 break;
2217 if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry)) 2216 snd_card_ro_proc_new(mixer->chip->card, "audigy2nx",
2218 snd_info_set_text_ops(entry, mixer, 2217 mixer, snd_audigy2nx_proc_read);
2219 snd_audigy2nx_proc_read);
2220 break; 2218 break;
2221 2219
2222 /* EMU0204 */ 2220 /* EMU0204 */
diff --git a/sound/usb/proc.c b/sound/usb/proc.c
index 0ac89e294d31..e80c9d0749c9 100644
--- a/sound/usb/proc.c
+++ b/sound/usb/proc.c
@@ -61,11 +61,10 @@ static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_
61 61
62void snd_usb_audio_create_proc(struct snd_usb_audio *chip) 62void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
63{ 63{
64 struct snd_info_entry *entry; 64 snd_card_ro_proc_new(chip->card, "usbbus", chip,
65 if (!snd_card_proc_new(chip->card, "usbbus", &entry)) 65 proc_audio_usbbus_read);
66 snd_info_set_text_ops(entry, chip, proc_audio_usbbus_read); 66 snd_card_ro_proc_new(chip->card, "usbid", chip,
67 if (!snd_card_proc_new(chip->card, "usbid", &entry)) 67 proc_audio_usbid_read);
68 snd_info_set_text_ops(entry, chip, proc_audio_usbid_read);
69} 68}
70 69
71/* 70/*
@@ -167,12 +166,10 @@ static void proc_pcm_format_read(struct snd_info_entry *entry, struct snd_info_b
167 166
168void snd_usb_proc_pcm_format_add(struct snd_usb_stream *stream) 167void snd_usb_proc_pcm_format_add(struct snd_usb_stream *stream)
169{ 168{
170 struct snd_info_entry *entry;
171 char name[32]; 169 char name[32];
172 struct snd_card *card = stream->chip->card; 170 struct snd_card *card = stream->chip->card;
173 171
174 sprintf(name, "stream%d", stream->pcm_index); 172 sprintf(name, "stream%d", stream->pcm_index);
175 if (!snd_card_proc_new(card, name, &entry)) 173 snd_card_ro_proc_new(card, name, stream, proc_pcm_format_read);
176 snd_info_set_text_ops(entry, stream, proc_pcm_format_read);
177} 174}
178 175
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index ebbadb3a7094..ef67d19117c4 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1479,10 +1479,6 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1479 /* XMOS based USB DACs */ 1479 /* XMOS based USB DACs */
1480 switch (chip->usb_id) { 1480 switch (chip->usb_id) {
1481 case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */ 1481 case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */
1482 case USB_ID(0x20b1, 0x0002): /* Wyred 4 Sound DAC-2 DSD */
1483 case USB_ID(0x20b1, 0x2004): /* Matrix Audio X-SPDIF 2 */
1484 case USB_ID(0x20b1, 0x2008): /* Matrix Audio X-Sabre */
1485 case USB_ID(0x20b1, 0x300a): /* Matrix Audio Mini-i Pro */
1486 case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */ 1482 case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */
1487 case USB_ID(0x22d9, 0x0436): /* OPPO Sonica */ 1483 case USB_ID(0x22d9, 0x0436): /* OPPO Sonica */
1488 case USB_ID(0x22d9, 0x0461): /* OPPO UDP-205 */ 1484 case USB_ID(0x22d9, 0x0461): /* OPPO UDP-205 */
@@ -1492,22 +1488,13 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1492 return SNDRV_PCM_FMTBIT_DSD_U32_BE; 1488 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1493 break; 1489 break;
1494 1490
1495 case USB_ID(0x152a, 0x85de): /* SMSL D1 DAC */
1496 case USB_ID(0x16d0, 0x09dd): /* Encore mDSD */
1497 case USB_ID(0x0d8c, 0x0316): /* Hegel HD12 DSD */ 1491 case USB_ID(0x0d8c, 0x0316): /* Hegel HD12 DSD */
1492 case USB_ID(0x10cb, 0x0103): /* The Bit Opus #3; with fp->dsd_raw */
1498 case USB_ID(0x16b0, 0x06b2): /* NuPrime DAC-10 */ 1493 case USB_ID(0x16b0, 0x06b2): /* NuPrime DAC-10 */
1494 case USB_ID(0x16d0, 0x09dd): /* Encore mDSD */
1499 case USB_ID(0x16d0, 0x0733): /* Furutech ADL Stratos */ 1495 case USB_ID(0x16d0, 0x0733): /* Furutech ADL Stratos */
1500 case USB_ID(0x16d0, 0x09db): /* NuPrime Audio DAC-9 */ 1496 case USB_ID(0x16d0, 0x09db): /* NuPrime Audio DAC-9 */
1501 case USB_ID(0x1db5, 0x0003): /* Bryston BDA3 */ 1497 case USB_ID(0x1db5, 0x0003): /* Bryston BDA3 */
1502 case USB_ID(0x20b1, 0x000a): /* Gustard DAC-X20U */
1503 case USB_ID(0x20b1, 0x2005): /* Denafrips Ares DAC */
1504 case USB_ID(0x20b1, 0x2009): /* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
1505 case USB_ID(0x20b1, 0x2023): /* JLsounds I2SoverUSB */
1506 case USB_ID(0x20b1, 0x3021): /* Eastern El. MiniMax Tube DAC Supreme */
1507 case USB_ID(0x20b1, 0x3023): /* Aune X1S 32BIT/384 DSD DAC */
1508 case USB_ID(0x20b1, 0x302d): /* Unison Research Unico CD Due */
1509 case USB_ID(0x20b1, 0x307b): /* CH Precision C1 DAC */
1510 case USB_ID(0x20b1, 0x3086): /* Singxer F-1 converter board */
1511 case USB_ID(0x22d9, 0x0426): /* OPPO HA-2 */ 1498 case USB_ID(0x22d9, 0x0426): /* OPPO HA-2 */
1512 case USB_ID(0x22e1, 0xca01): /* HDTA Serenade DSD */ 1499 case USB_ID(0x22e1, 0xca01): /* HDTA Serenade DSD */
1513 case USB_ID(0x249c, 0x9326): /* M2Tech Young MkIII */ 1500 case USB_ID(0x249c, 0x9326): /* M2Tech Young MkIII */
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 2b833054e3b0..58974d094b27 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -981,18 +981,17 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
981 981
982 sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs); 982 sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
983 983
984 if ((playback_endpoint && 984 if (playback_endpoint) {
985 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 985 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
986 SNDRV_DMA_TYPE_CONTINUOUS, 986 SNDRV_DMA_TYPE_CONTINUOUS,
987 snd_dma_continuous_data(GFP_KERNEL), 987 snd_dma_continuous_data(GFP_KERNEL),
988 64*1024, 128*1024))) || 988 64*1024, 128*1024);
989 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
990 SNDRV_DMA_TYPE_CONTINUOUS,
991 snd_dma_continuous_data(GFP_KERNEL),
992 64*1024, 128*1024))) {
993 snd_usX2Y_pcm_private_free(pcm);
994 return err;
995 } 989 }
990
991 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
992 SNDRV_DMA_TYPE_CONTINUOUS,
993 snd_dma_continuous_data(GFP_KERNEL),
994 64*1024, 128*1024);
996 usX2Y(card)->pcm_devs++; 995 usX2Y(card)->pcm_devs++;
997 996
998 return 0; 997 return 0;
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
index 4fd9276b8e50..714cf50d4a4c 100644
--- a/sound/usb/usx2y/usx2yhwdeppcm.c
+++ b/sound/usb/usx2y/usx2yhwdeppcm.c
@@ -736,17 +736,14 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card)
736 pcm->info_flags = 0; 736 pcm->info_flags = 0;
737 737
738 sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); 738 sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio");
739 if (0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 739 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
740 SNDRV_DMA_TYPE_CONTINUOUS, 740 SNDRV_DMA_TYPE_CONTINUOUS,
741 snd_dma_continuous_data(GFP_KERNEL), 741 snd_dma_continuous_data(GFP_KERNEL),
742 64*1024, 128*1024)) || 742 64*1024, 128*1024);
743 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 743 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
744 SNDRV_DMA_TYPE_CONTINUOUS, 744 SNDRV_DMA_TYPE_CONTINUOUS,
745 snd_dma_continuous_data(GFP_KERNEL), 745 snd_dma_continuous_data(GFP_KERNEL),
746 64*1024, 128*1024))) { 746 64*1024, 128*1024);
747 return err;
748 }
749
750 747
751 return 0; 748 return 0;
752} 749}
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 00c92eb854ce..80f79ecffc71 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1651,18 +1651,6 @@ static int had_create_jack(struct snd_intelhad *ctx,
1651static int __maybe_unused hdmi_lpe_audio_suspend(struct device *dev) 1651static int __maybe_unused hdmi_lpe_audio_suspend(struct device *dev)
1652{ 1652{
1653 struct snd_intelhad_card *card_ctx = dev_get_drvdata(dev); 1653 struct snd_intelhad_card *card_ctx = dev_get_drvdata(dev);
1654 int port;
1655
1656 for_each_port(card_ctx, port) {
1657 struct snd_intelhad *ctx = &card_ctx->pcm_ctx[port];
1658 struct snd_pcm_substream *substream;
1659
1660 substream = had_substream_get(ctx);
1661 if (substream) {
1662 snd_pcm_suspend(substream);
1663 had_substream_put(ctx);
1664 }
1665 }
1666 1654
1667 snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D3hot); 1655 snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D3hot);
1668 1656
@@ -1824,7 +1812,8 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
1824 * try to allocate 600k buffer as default which is large enough 1812 * try to allocate 600k buffer as default which is large enough
1825 */ 1813 */
1826 snd_pcm_lib_preallocate_pages_for_all(pcm, 1814 snd_pcm_lib_preallocate_pages_for_all(pcm,
1827 SNDRV_DMA_TYPE_DEV_UC, NULL, 1815 SNDRV_DMA_TYPE_DEV_UC,
1816 card->dev,
1828 HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER); 1817 HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER);
1829 1818
1830 /* create controls */ 1819 /* create controls */