aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-01-12 03:59:14 -0500
committerTakashi Iwai <tiwai@suse.de>2012-01-12 03:59:14 -0500
commit627b79628f56c3deeb17dec1edf6899b49552fa4 (patch)
treedeac8b2cce5d70708fa944a270ee031f069226d8
parent29abceb67f8a230da806db4ed73899595bd2ae76 (diff)
parent8c3f5d8a9b7d0d8506bc2a0525e012eae02b1853 (diff)
Merge branch 'topic/misc' into for-linus
-rw-r--r--Documentation/DocBook/writing-an-alsa-driver.tmpl2
-rw-r--r--Documentation/sound/alsa/compress_offload.txt188
-rw-r--r--include/sound/Kbuild2
-rw-r--r--include/sound/compress_driver.h167
-rw-r--r--include/sound/compress_offload.h161
-rw-r--r--include/sound/compress_params.h397
-rw-r--r--include/sound/core.h1
-rw-r--r--include/sound/minors.h4
-rw-r--r--sound/arm/pxa2xx-ac97.c13
-rw-r--r--sound/core/Kconfig10
-rw-r--r--sound/core/Makefile4
-rw-r--r--sound/core/compress_offload.c765
-rw-r--r--sound/core/oss/pcm_oss.c2
-rw-r--r--sound/core/seq/seq_dummy.c2
-rw-r--r--sound/core/sound.c1
-rw-r--r--sound/drivers/aloop.c2
-rw-r--r--sound/drivers/dummy.c6
-rw-r--r--sound/drivers/ml403-ac97cr.c15
-rw-r--r--sound/drivers/mpu401/mpu401.c6
-rw-r--r--sound/drivers/mts64.c2
-rw-r--r--sound/drivers/opl3/opl3_midi.c2
-rw-r--r--sound/drivers/opl3/opl3_seq.c2
-rw-r--r--sound/drivers/pcsp/pcsp.c4
-rw-r--r--sound/drivers/pcsp/pcsp_lib.c2
-rw-r--r--sound/drivers/portman2x4.c2
-rw-r--r--sound/drivers/serial-u16550.c4
-rw-r--r--sound/drivers/virmidi.c2
-rw-r--r--sound/isa/ad1816a/ad1816a.c2
-rw-r--r--sound/isa/ad1848/ad1848.c4
-rw-r--r--sound/isa/adlib.c2
-rw-r--r--sound/isa/als100.c2
-rw-r--r--sound/isa/azt2320.c2
-rw-r--r--sound/isa/cmi8330.c4
-rw-r--r--sound/isa/cs423x/cs4231.c2
-rw-r--r--sound/isa/cs423x/cs4236.c4
-rw-r--r--sound/isa/es1688/es1688.c4
-rw-r--r--sound/isa/es18xx.c4
-rw-r--r--sound/isa/galaxy/galaxy.c2
-rw-r--r--sound/isa/gus/gusclassic.c2
-rw-r--r--sound/isa/gus/gusextreme.c2
-rw-r--r--sound/isa/gus/gusmax.c2
-rw-r--r--sound/isa/gus/interwave.c4
-rw-r--r--sound/isa/msnd/msnd_pinnacle.c2
-rw-r--r--sound/isa/opl3sa2.c4
-rw-r--r--sound/isa/opti9xx/miro.c2
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c2
-rw-r--r--sound/isa/sb/jazz16.c2
-rw-r--r--sound/isa/sb/sb16.c4
-rw-r--r--sound/isa/sb/sb8.c2
-rw-r--r--sound/isa/sc6000.c2
-rw-r--r--sound/isa/wavefront/wavefront.c6
-rw-r--r--sound/mips/hal2.c13
-rw-r--r--sound/mips/sgio2audio.c13
-rw-r--r--sound/oss/ad1848.c8
-rw-r--r--sound/oss/msnd_pinnacle.c2
-rw-r--r--sound/oss/pas2_card.c12
-rw-r--r--sound/oss/pss.c10
-rw-r--r--sound/oss/trix.c2
-rw-r--r--sound/pci/ac97/ac97_codec.c2
-rw-r--r--sound/pci/ad1889.c2
-rw-r--r--sound/pci/ali5451/ali5451.c4
-rw-r--r--sound/pci/als300.c9
-rw-r--r--sound/pci/als4000.c2
-rw-r--r--sound/pci/asihpi/asihpi.c294
-rw-r--r--sound/pci/asihpi/hpi.h74
-rw-r--r--sound/pci/asihpi/hpi6000.c61
-rw-r--r--sound/pci/asihpi/hpi6000.h2
-rw-r--r--sound/pci/asihpi/hpi6205.c57
-rw-r--r--sound/pci/asihpi/hpi_internal.h115
-rw-r--r--sound/pci/asihpi/hpi_version.h32
-rw-r--r--sound/pci/asihpi/hpicmn.c32
-rw-r--r--sound/pci/asihpi/hpicmn.h13
-rw-r--r--sound/pci/asihpi/hpidebug.c2
-rw-r--r--sound/pci/asihpi/hpidebug.h2
-rw-r--r--sound/pci/asihpi/hpidspcd.c30
-rw-r--r--sound/pci/asihpi/hpidspcd.h4
-rw-r--r--sound/pci/asihpi/hpifunc.c10
-rw-r--r--sound/pci/asihpi/hpimsginit.c2
-rw-r--r--sound/pci/asihpi/hpimsginit.h2
-rw-r--r--sound/pci/asihpi/hpimsgx.c3
-rw-r--r--sound/pci/asihpi/hpimsgx.h2
-rw-r--r--sound/pci/asihpi/hpioctl.c63
-rw-r--r--sound/pci/asihpi/hpioctl.h2
-rw-r--r--sound/pci/asihpi/hpios.c2
-rw-r--r--sound/pci/asihpi/hpios.h16
-rw-r--r--sound/pci/asihpi/hpipcida.h2
-rw-r--r--sound/pci/atiixp.c4
-rw-r--r--sound/pci/atiixp_modem.c2
-rw-r--r--sound/pci/au88x0/au88x0.c2
-rw-r--r--sound/pci/au88x0/au88x0_core.c10
-rw-r--r--sound/pci/au88x0/au88x0_pcm.c7
-rw-r--r--sound/pci/au88x0/au88x0_xtalk.c151
-rw-r--r--sound/pci/aw2/aw2-alsa.c2
-rw-r--r--sound/pci/azt3328.c2
-rw-r--r--sound/pci/bt87x.c4
-rw-r--r--sound/pci/ca0106/ca0106_main.c2
-rw-r--r--sound/pci/cmipci.c4
-rw-r--r--sound/pci/cs4281.c4
-rw-r--r--sound/pci/cs46xx/cs46xx.c8
-rw-r--r--sound/pci/cs5530.c9
-rw-r--r--sound/pci/cs5535audio/cs5535audio.c2
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pcm.c2
-rw-r--r--sound/pci/ctxfi/ctsrc.c2
-rw-r--r--sound/pci/ctxfi/cttimer.c4
-rw-r--r--sound/pci/ctxfi/xfi.c2
-rw-r--r--sound/pci/echoaudio/echoaudio.c2
-rw-r--r--sound/pci/emu10k1/emu10k1.c4
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c12
-rw-r--r--sound/pci/emu10k1/emu10k1x.c2
-rw-r--r--sound/pci/ens1370.c4
-rw-r--r--sound/pci/es1938.c2
-rw-r--r--sound/pci/es1968.c4
-rw-r--r--sound/pci/fm801.c2
-rw-r--r--sound/pci/hda/hda_codec.c6
-rw-r--r--sound/pci/hda/hda_eld.c28
-rw-r--r--sound/pci/hda/hda_intel.c9
-rw-r--r--sound/pci/hda/patch_cirrus.c32
-rw-r--r--sound/pci/hda/patch_hdmi.c16
-rw-r--r--sound/pci/hda/patch_realtek.c34
-rw-r--r--sound/pci/hda/patch_sigmatel.c24
-rw-r--r--sound/pci/hda/patch_via.c76
-rw-r--r--sound/pci/ice1712/amp.c7
-rw-r--r--sound/pci/ice1712/envy24ht.h1
-rw-r--r--sound/pci/ice1712/ice1712.c4
-rw-r--r--sound/pci/ice1712/ice1724.c65
-rw-r--r--sound/pci/intel8x0.c6
-rw-r--r--sound/pci/intel8x0m.c2
-rw-r--r--sound/pci/korg1212/korg1212.c2
-rw-r--r--sound/pci/lola/lola.c2
-rw-r--r--sound/pci/lx6464es/lx6464es.c2
-rw-r--r--sound/pci/lx6464es/lx_core.c23
-rw-r--r--sound/pci/lx6464es/lx_core.h3
-rw-r--r--sound/pci/maestro3.c4
-rw-r--r--sound/pci/mixart/mixart.c2
-rw-r--r--sound/pci/nm256/nm256.c12
-rw-r--r--sound/pci/oxygen/oxygen.c2
-rw-r--r--sound/pci/oxygen/virtuoso.c2
-rw-r--r--sound/pci/oxygen/xonar_cs43xx.c1
-rw-r--r--sound/pci/oxygen/xonar_dg.c3
-rw-r--r--sound/pci/oxygen/xonar_wm87x6.c6
-rw-r--r--sound/pci/pcxhr/pcxhr.c4
-rw-r--r--sound/pci/riptide/riptide.c2
-rw-r--r--sound/pci/rme32.c4
-rw-r--r--sound/pci/rme96.c2
-rw-r--r--sound/pci/rme9652/hdsp.c5
-rw-r--r--sound/pci/rme9652/hdspm.c34
-rw-r--r--sound/pci/rme9652/rme9652.c4
-rw-r--r--sound/pci/sis7019.c89
-rw-r--r--sound/pci/sonicvibes.c6
-rw-r--r--sound/pci/trident/trident.c2
-rw-r--r--sound/pci/via82xx.c4
-rw-r--r--sound/pci/via82xx_modem.c2
-rw-r--r--sound/pci/vx222/vx222.c4
-rw-r--r--sound/pci/ymfpci/ymfpci.c4
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.c2
-rw-r--r--sound/pcmcia/vx/vxpocket.c2
-rw-r--r--sound/ppc/powermac.c2
-rw-r--r--sound/sh/aica.c2
-rw-r--r--sound/sh/sh_dac_audio.c13
-rw-r--r--sound/sparc/amd7930.c2
-rw-r--r--sound/sparc/cs4231.c15
-rw-r--r--sound/sparc/dbri.c16
-rw-r--r--sound/usb/6fire/chip.c2
-rw-r--r--sound/usb/caiaq/device.c2
-rw-r--r--sound/usb/card.c6
-rw-r--r--sound/usb/endpoint.c5
-rw-r--r--sound/usb/format.c8
-rw-r--r--sound/usb/misc/ua101.c2
-rw-r--r--sound/usb/quirks-table.h67
-rw-r--r--sound/usb/usx2y/us122l.c2
-rw-r--r--sound/usb/usx2y/usb_stream.c6
-rw-r--r--sound/usb/usx2y/usbusx2y.c2
172 files changed, 2775 insertions, 913 deletions
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl
index 5de23c007078..cab4ec58e46e 100644
--- a/Documentation/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl
@@ -404,7 +404,7 @@
404 /* SNDRV_CARDS: maximum number of cards supported by this module */ 404 /* SNDRV_CARDS: maximum number of cards supported by this module */
405 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 405 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
406 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 406 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
407 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 407 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
408 408
409 /* definition of the chip-specific record */ 409 /* definition of the chip-specific record */
410 struct mychip { 410 struct mychip {
diff --git a/Documentation/sound/alsa/compress_offload.txt b/Documentation/sound/alsa/compress_offload.txt
new file mode 100644
index 000000000000..c83a835350f0
--- /dev/null
+++ b/Documentation/sound/alsa/compress_offload.txt
@@ -0,0 +1,188 @@
1 compress_offload.txt
2 =====================
3 Pierre-Louis.Bossart <pierre-louis.bossart@linux.intel.com>
4 Vinod Koul <vinod.koul@linux.intel.com>
5
6Overview
7
8Since its early days, the ALSA API was defined with PCM support or
9constant bitrates payloads such as IEC61937 in mind. Arguments and
10returned values in frames are the norm, making it a challenge to
11extend the existing API to compressed data streams.
12
13In recent years, audio digital signal processors (DSP) were integrated
14in system-on-chip designs, and DSPs are also integrated in audio
15codecs. Processing compressed data on such DSPs results in a dramatic
16reduction of power consumption compared to host-based
17processing. Support for such hardware has not been very good in Linux,
18mostly because of a lack of a generic API available in the mainline
19kernel.
20
21Rather than requiring a compability break with an API change of the
22ALSA PCM interface, a new 'Compressed Data' API is introduced to
23provide a control and data-streaming interface for audio DSPs.
24
25The design of this API was inspired by the 2-year experience with the
26Intel Moorestown SOC, with many corrections required to upstream the
27API in the mainline kernel instead of the staging tree and make it
28usable by others.
29
30Requirements
31
32The main requirements are:
33
34- separation between byte counts and time. Compressed formats may have
35 a header per file, per frame, or no header at all. The payload size
36 may vary from frame-to-frame. As a result, it is not possible to
37 estimate reliably the duration of audio buffers when handling
38 compressed data. Dedicated mechanisms are required to allow for
39 reliable audio-video synchronization, which requires precise
40 reporting of the number of samples rendered at any given time.
41
42- Handling of multiple formats. PCM data only requires a specification
43 of the sampling rate, number of channels and bits per sample. In
44 contrast, compressed data comes in a variety of formats. Audio DSPs
45 may also provide support for a limited number of audio encoders and
46 decoders embedded in firmware, or may support more choices through
47 dynamic download of libraries.
48
49- Focus on main formats. This API provides support for the most
50 popular formats used for audio and video capture and playback. It is
51 likely that as audio compression technology advances, new formats
52 will be added.
53
54- Handling of multiple configurations. Even for a given format like
55 AAC, some implementations may support AAC multichannel but HE-AAC
56 stereo. Likewise WMA10 level M3 may require too much memory and cpu
57 cycles. The new API needs to provide a generic way of listing these
58 formats.
59
60- Rendering/Grabbing only. This API does not provide any means of
61 hardware acceleration, where PCM samples are provided back to
62 user-space for additional processing. This API focuses instead on
63 streaming compressed data to a DSP, with the assumption that the
64 decoded samples are routed to a physical output or logical back-end.
65
66 - Complexity hiding. Existing user-space multimedia frameworks all
67 have existing enums/structures for each compressed format. This new
68 API assumes the existence of a platform-specific compatibility layer
69 to expose, translate and make use of the capabilities of the audio
70 DSP, eg. Android HAL or PulseAudio sinks. By construction, regular
71 applications are not supposed to make use of this API.
72
73
74Design
75
76The new API shares a number of concepts with with the PCM API for flow
77control. Start, pause, resume, drain and stop commands have the same
78semantics no matter what the content is.
79
80The concept of memory ring buffer divided in a set of fragments is
81borrowed from the ALSA PCM API. However, only sizes in bytes can be
82specified.
83
84Seeks/trick modes are assumed to be handled by the host.
85
86The notion of rewinds/forwards is not supported. Data committed to the
87ring buffer cannot be invalidated, except when dropping all buffers.
88
89The Compressed Data API does not make any assumptions on how the data
90is transmitted to the audio DSP. DMA transfers from main memory to an
91embedded audio cluster or to a SPI interface for external DSPs are
92possible. As in the ALSA PCM case, a core set of routines is exposed;
93each driver implementer will have to write support for a set of
94mandatory routines and possibly make use of optional ones.
95
96The main additions are
97
98- get_caps
99This routine returns the list of audio formats supported. Querying the
100codecs on a capture stream will return encoders, decoders will be
101listed for playback streams.
102
103- get_codec_caps For each codec, this routine returns a list of
104capabilities. The intent is to make sure all the capabilities
105correspond to valid settings, and to minimize the risks of
106configuration failures. For example, for a complex codec such as AAC,
107the number of channels supported may depend on a specific profile. If
108the capabilities were exposed with a single descriptor, it may happen
109that a specific combination of profiles/channels/formats may not be
110supported. Likewise, embedded DSPs have limited memory and cpu cycles,
111it is likely that some implementations make the list of capabilities
112dynamic and dependent on existing workloads. In addition to codec
113settings, this routine returns the minimum buffer size handled by the
114implementation. This information can be a function of the DMA buffer
115sizes, the number of bytes required to synchronize, etc, and can be
116used by userspace to define how much needs to be written in the ring
117buffer before playback can start.
118
119- set_params
120This routine sets the configuration chosen for a specific codec. The
121most important field in the parameters is the codec type; in most
122cases decoders will ignore other fields, while encoders will strictly
123comply to the settings
124
125- get_params
126This routines returns the actual settings used by the DSP. Changes to
127the settings should remain the exception.
128
129- get_timestamp
130The timestamp becomes a multiple field structure. It lists the number
131of bytes transferred, the number of samples processed and the number
132of samples rendered/grabbed. All these values can be used to determine
133the avarage bitrate, figure out if the ring buffer needs to be
134refilled or the delay due to decoding/encoding/io on the DSP.
135
136Note that the list of codecs/profiles/modes was derived from the
137OpenMAX AL specification instead of reinventing the wheel.
138Modifications include:
139- Addition of FLAC and IEC formats
140- Merge of encoder/decoder capabilities
141- Profiles/modes listed as bitmasks to make descriptors more compact
142- Addition of set_params for decoders (missing in OpenMAX AL)
143- Addition of AMR/AMR-WB encoding modes (missing in OpenMAX AL)
144- Addition of format information for WMA
145- Addition of encoding options when required (derived from OpenMAX IL)
146- Addition of rateControlSupported (missing in OpenMAX AL)
147
148Not supported:
149
150- Support for VoIP/circuit-switched calls is not the target of this
151 API. Support for dynamic bit-rate changes would require a tight
152 coupling between the DSP and the host stack, limiting power savings.
153
154- Packet-loss concealment is not supported. This would require an
155 additional interface to let the decoder synthesize data when frames
156 are lost during transmission. This may be added in the future.
157
158- Volume control/routing is not handled by this API. Devices exposing a
159 compressed data interface will be considered as regular ALSA devices;
160 volume changes and routing information will be provided with regular
161 ALSA kcontrols.
162
163- Embedded audio effects. Such effects should be enabled in the same
164 manner, no matter if the input was PCM or compressed.
165
166- multichannel IEC encoding. Unclear if this is required.
167
168- Encoding/decoding acceleration is not supported as mentioned
169 above. It is possible to route the output of a decoder to a capture
170 stream, or even implement transcoding capabilities. This routing
171 would be enabled with ALSA kcontrols.
172
173- Audio policy/resource management. This API does not provide any
174 hooks to query the utilization of the audio DSP, nor any premption
175 mechanisms.
176
177- No notion of underun/overrun. Since the bytes written are compressed
178 in nature and data written/read doesn't translate directly to
179 rendered output in time, this does not deal with underrun/overun and
180 maybe dealt in user-library
181
182Credits:
183- Mark Brown and Liam Girdwood for discussions on the need for this API
184- Harsha Priya for her work on intel_sst compressed API
185- Rakesh Ughreja for valuable feedback
186- Sing Nallasellan, Sikkandar Madar and Prasanna Samaga for
187 demonstrating and quantifying the benefits of audio offload on a
188 real platform.
diff --git a/include/sound/Kbuild b/include/sound/Kbuild
index 802947f60915..6df30ed1581c 100644
--- a/include/sound/Kbuild
+++ b/include/sound/Kbuild
@@ -6,3 +6,5 @@ header-y += hdsp.h
6header-y += hdspm.h 6header-y += hdspm.h
7header-y += sb16_csp.h 7header-y += sb16_csp.h
8header-y += sfnt_info.h 8header-y += sfnt_info.h
9header-y += compress_params.h
10header-y += compress_offload.h
diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
new file mode 100644
index 000000000000..48f2a1ff2bbc
--- /dev/null
+++ b/include/sound/compress_driver.h
@@ -0,0 +1,167 @@
1/*
2 * compress_driver.h - compress offload driver definations
3 *
4 * Copyright (C) 2011 Intel Corporation
5 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
6 * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 *
24 */
25#ifndef __COMPRESS_DRIVER_H
26#define __COMPRESS_DRIVER_H
27
28#include <linux/types.h>
29#include <linux/sched.h>
30#include <sound/compress_offload.h>
31#include <sound/asound.h>
32#include <sound/pcm.h>
33
34struct snd_compr_ops;
35
36/**
37 * struct snd_compr_runtime: runtime stream description
38 * @state: stream state
39 * @ops: pointer to DSP callbacks
40 * @buffer: pointer to kernel buffer, valid only when not in mmap mode or
41 * DSP doesn't implement copy
42 * @buffer_size: size of the above buffer
43 * @fragment_size: size of buffer fragment in bytes
44 * @fragments: number of such fragments
45 * @hw_pointer: offset of last location in buffer where DSP copied data
46 * @app_pointer: offset of last location in buffer where app wrote data
47 * @total_bytes_available: cumulative number of bytes made available in
48 * the ring buffer
49 * @total_bytes_transferred: cumulative bytes transferred by offload DSP
50 * @sleep: poll sleep
51 */
52struct snd_compr_runtime {
53 snd_pcm_state_t state;
54 struct snd_compr_ops *ops;
55 void *buffer;
56 u64 buffer_size;
57 u32 fragment_size;
58 u32 fragments;
59 u64 hw_pointer;
60 u64 app_pointer;
61 u64 total_bytes_available;
62 u64 total_bytes_transferred;
63 wait_queue_head_t sleep;
64};
65
66/**
67 * struct snd_compr_stream: compressed stream
68 * @name: device name
69 * @ops: pointer to DSP callbacks
70 * @runtime: pointer to runtime structure
71 * @device: device pointer
72 * @direction: stream direction, playback/recording
73 * @private_data: pointer to DSP private data
74 */
75struct snd_compr_stream {
76 const char *name;
77 struct snd_compr_ops *ops;
78 struct snd_compr_runtime *runtime;
79 struct snd_compr *device;
80 enum snd_compr_direction direction;
81 void *private_data;
82};
83
84/**
85 * struct snd_compr_ops: compressed path DSP operations
86 * @open: Open the compressed stream
87 * This callback is mandatory and shall keep dsp ready to receive the stream
88 * parameter
89 * @free: Close the compressed stream, mandatory
90 * @set_params: Sets the compressed stream parameters, mandatory
91 * This can be called in during stream creation only to set codec params
92 * and the stream properties
93 * @get_params: retrieve the codec parameters, mandatory
94 * @trigger: Trigger operations like start, pause, resume, drain, stop.
95 * This callback is mandatory
96 * @pointer: Retrieve current h/w pointer information. Mandatory
97 * @copy: Copy the compressed data to/from userspace, Optional
98 * Can't be implemented if DSP supports mmap
99 * @mmap: DSP mmap method to mmap DSP memory
100 * @ack: Ack for DSP when data is written to audio buffer, Optional
101 * Not valid if copy is implemented
102 * @get_caps: Retrieve DSP capabilities, mandatory
103 * @get_codec_caps: Retrieve capabilities for a specific codec, mandatory
104 */
105struct snd_compr_ops {
106 int (*open)(struct snd_compr_stream *stream);
107 int (*free)(struct snd_compr_stream *stream);
108 int (*set_params)(struct snd_compr_stream *stream,
109 struct snd_compr_params *params);
110 int (*get_params)(struct snd_compr_stream *stream,
111 struct snd_codec *params);
112 int (*trigger)(struct snd_compr_stream *stream, int cmd);
113 int (*pointer)(struct snd_compr_stream *stream,
114 struct snd_compr_tstamp *tstamp);
115 int (*copy)(struct snd_compr_stream *stream, const char __user *buf,
116 size_t count);
117 int (*mmap)(struct snd_compr_stream *stream,
118 struct vm_area_struct *vma);
119 int (*ack)(struct snd_compr_stream *stream, size_t bytes);
120 int (*get_caps) (struct snd_compr_stream *stream,
121 struct snd_compr_caps *caps);
122 int (*get_codec_caps) (struct snd_compr_stream *stream,
123 struct snd_compr_codec_caps *codec);
124};
125
126/**
127 * struct snd_compr: Compressed device
128 * @name: DSP device name
129 * @dev: Device pointer
130 * @ops: pointer to DSP callbacks
131 * @private_data: pointer to DSP pvt data
132 * @card: sound card pointer
133 * @direction: Playback or capture direction
134 * @lock: device lock
135 * @device: device id
136 */
137struct snd_compr {
138 const char *name;
139 struct device *dev;
140 struct snd_compr_ops *ops;
141 void *private_data;
142 struct snd_card *card;
143 unsigned int direction;
144 struct mutex lock;
145 int device;
146};
147
148/* compress device register APIs */
149int snd_compress_register(struct snd_compr *device);
150int snd_compress_deregister(struct snd_compr *device);
151int snd_compress_new(struct snd_card *card, int device,
152 int type, struct snd_compr *compr);
153
154/* dsp driver callback apis
155 * For playback: driver should call snd_compress_fragment_elapsed() to let the
156 * framework know that a fragment has been consumed from the ring buffer
157 *
158 * For recording: we want to know when a frame is available or when
159 * at least one frame is available so snd_compress_frame_elapsed()
160 * callback should be called when a encodeded frame is available
161 */
162static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream)
163{
164 wake_up(&stream->runtime->sleep);
165}
166
167#endif
diff --git a/include/sound/compress_offload.h b/include/sound/compress_offload.h
new file mode 100644
index 000000000000..05341a43fedf
--- /dev/null
+++ b/include/sound/compress_offload.h
@@ -0,0 +1,161 @@
1/*
2 * compress_offload.h - compress offload header definations
3 *
4 * Copyright (C) 2011 Intel Corporation
5 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
6 * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 *
24 */
25#ifndef __COMPRESS_OFFLOAD_H
26#define __COMPRESS_OFFLOAD_H
27
28#include <linux/types.h>
29#include <sound/asound.h>
30#include <sound/compress_params.h>
31
32
33#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 0)
34/**
35 * struct snd_compressed_buffer: compressed buffer
36 * @fragment_size: size of buffer fragment in bytes
37 * @fragments: number of such fragments
38 */
39struct snd_compressed_buffer {
40 __u32 fragment_size;
41 __u32 fragments;
42};
43
44/**
45 * struct snd_compr_params: compressed stream params
46 * @buffer: buffer description
47 * @codec: codec parameters
48 * @no_wake_mode: dont wake on fragment elapsed
49 */
50struct snd_compr_params {
51 struct snd_compressed_buffer buffer;
52 struct snd_codec codec;
53 __u8 no_wake_mode;
54};
55
56/**
57 * struct snd_compr_tstamp: timestamp descriptor
58 * @byte_offset: Byte offset in ring buffer to DSP
59 * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
60 * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
61 * large steps and should only be used to monitor encoding/decoding
62 * progress. It shall not be used for timing estimates.
63 * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
64 * output/input. This field should be used for A/V sync or time estimates.
65 * @sampling_rate: sampling rate of audio
66 */
67struct snd_compr_tstamp {
68 __u32 byte_offset;
69 __u32 copied_total;
70 snd_pcm_uframes_t pcm_frames;
71 snd_pcm_uframes_t pcm_io_frames;
72 __u32 sampling_rate;
73};
74
75/**
76 * struct snd_compr_avail: avail descriptor
77 * @avail: Number of bytes available in ring buffer for writing/reading
78 * @tstamp: timestamp infomation
79 */
80struct snd_compr_avail {
81 __u64 avail;
82 struct snd_compr_tstamp tstamp;
83};
84
85enum snd_compr_direction {
86 SND_COMPRESS_PLAYBACK = 0,
87 SND_COMPRESS_CAPTURE
88};
89
90/**
91 * struct snd_compr_caps: caps descriptor
92 * @codecs: pointer to array of codecs
93 * @direction: direction supported. Of type snd_compr_direction
94 * @min_fragment_size: minimum fragment supported by DSP
95 * @max_fragment_size: maximum fragment supported by DSP
96 * @min_fragments: min fragments supported by DSP
97 * @max_fragments: max fragments supported by DSP
98 * @num_codecs: number of codecs supported
99 * @reserved: reserved field
100 */
101struct snd_compr_caps {
102 __u32 num_codecs;
103 __u32 direction;
104 __u32 min_fragment_size;
105 __u32 max_fragment_size;
106 __u32 min_fragments;
107 __u32 max_fragments;
108 __u32 codecs[MAX_NUM_CODECS];
109 __u32 reserved[11];
110};
111
112/**
113 * struct snd_compr_codec_caps: query capability of codec
114 * @codec: codec for which capability is queried
115 * @num_descriptors: number of codec descriptors
116 * @descriptor: array of codec capability descriptor
117 */
118struct snd_compr_codec_caps {
119 __u32 codec;
120 __u32 num_descriptors;
121 struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
122};
123
124/**
125 * compress path ioctl definitions
126 * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP
127 * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec
128 * SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters
129 * Note: only codec params can be changed runtime and stream params cant be
130 * SNDRV_COMPRESS_GET_PARAMS: Query codec params
131 * SNDRV_COMPRESS_TSTAMP: get the current timestamp value
132 * SNDRV_COMPRESS_AVAIL: get the current buffer avail value.
133 * This also queries the tstamp properties
134 * SNDRV_COMPRESS_PAUSE: Pause the running stream
135 * SNDRV_COMPRESS_RESUME: resume a paused stream
136 * SNDRV_COMPRESS_START: Start a stream
137 * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content
138 * and the buffers currently with DSP
139 * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that
140 * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version
141 */
142#define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)
143#define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)
144#define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\
145 struct snd_compr_codec_caps)
146#define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)
147#define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)
148#define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)
149#define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)
150#define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)
151#define SNDRV_COMPRESS_RESUME _IO('C', 0x31)
152#define SNDRV_COMPRESS_START _IO('C', 0x32)
153#define SNDRV_COMPRESS_STOP _IO('C', 0x33)
154#define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)
155/*
156 * TODO
157 * 1. add mmap support
158 *
159 */
160#define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */
161#endif
diff --git a/include/sound/compress_params.h b/include/sound/compress_params.h
new file mode 100644
index 000000000000..d97d69f81a7d
--- /dev/null
+++ b/include/sound/compress_params.h
@@ -0,0 +1,397 @@
1/*
2 * compress_params.h - codec types and parameters for compressed data
3 * streaming interface
4 *
5 * Copyright (C) 2011 Intel Corporation
6 * Authors: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
7 * Vinod Koul <vinod.koul@linux.intel.com>
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 *
26 * The definitions in this file are derived from the OpenMAX AL version 1.1
27 * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below.
28 *
29 * Copyright (c) 2007-2010 The Khronos Group Inc.
30 *
31 * Permission is hereby granted, free of charge, to any person obtaining
32 * a copy of this software and/or associated documentation files (the
33 * "Materials "), to deal in the Materials without restriction, including
34 * without limitation the rights to use, copy, modify, merge, publish,
35 * distribute, sublicense, and/or sell copies of the Materials, and to
36 * permit persons to whom the Materials are furnished to do so, subject to
37 * the following conditions:
38 *
39 * The above copyright notice and this permission notice shall be included
40 * in all copies or substantial portions of the Materials.
41 *
42 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
49 *
50 */
51#ifndef __SND_COMPRESS_PARAMS_H
52#define __SND_COMPRESS_PARAMS_H
53
54/* AUDIO CODECS SUPPORTED */
55#define MAX_NUM_CODECS 32
56#define MAX_NUM_CODEC_DESCRIPTORS 32
57#define MAX_NUM_BITRATES 32
58
59/* Codecs are listed linearly to allow for extensibility */
60#define SND_AUDIOCODEC_PCM ((__u32) 0x00000001)
61#define SND_AUDIOCODEC_MP3 ((__u32) 0x00000002)
62#define SND_AUDIOCODEC_AMR ((__u32) 0x00000003)
63#define SND_AUDIOCODEC_AMRWB ((__u32) 0x00000004)
64#define SND_AUDIOCODEC_AMRWBPLUS ((__u32) 0x00000005)
65#define SND_AUDIOCODEC_AAC ((__u32) 0x00000006)
66#define SND_AUDIOCODEC_WMA ((__u32) 0x00000007)
67#define SND_AUDIOCODEC_REAL ((__u32) 0x00000008)
68#define SND_AUDIOCODEC_VORBIS ((__u32) 0x00000009)
69#define SND_AUDIOCODEC_FLAC ((__u32) 0x0000000A)
70#define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
71#define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
72#define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
73
74/*
75 * Profile and modes are listed with bit masks. This allows for a
76 * more compact representation of fields that will not evolve
77 * (in contrast to the list of codecs)
78 */
79
80#define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
81
82/* MP3 modes are only useful for encoders */
83#define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
84#define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
85#define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
86#define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
87
88#define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
89
90/* AMR modes are only useful for encoders */
91#define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
92#define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
93#define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
94
95#define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
96#define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
97#define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
98#define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
99#define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
100#define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
101#define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
102
103#define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
104
105/* AMRWB modes are only useful for encoders */
106#define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
107#define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
108#define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
109
110#define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
111
112#define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
113
114/* AAC modes are required for encoders and decoders */
115#define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
116#define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
117#define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
118#define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
119#define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
120#define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
121#define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
122#define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
123#define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
124#define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
125
126/* AAC formats are required for encoders and decoders */
127#define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
128#define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
129#define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
130#define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
131#define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
132#define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
133#define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
134
135#define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
136#define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
137#define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
138#define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
139
140#define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
141#define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
142#define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
143#define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
144#define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
145#define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
146#define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
147#define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
148
149#define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
150/*
151 * Some implementations strip the ASF header and only send ASF packets
152 * to the DSP
153 */
154#define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
155
156#define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
157
158#define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
159#define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
160#define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
161#define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
162
163#define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
164
165#define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
166
167#define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
168
169/*
170 * Define quality levels for FLAC encoders, from LEVEL0 (fast)
171 * to LEVEL8 (best)
172 */
173#define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
174#define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
175#define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
176#define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
177#define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
178#define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
179#define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
180#define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
181#define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
182
183#define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
184#define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
185
186/* IEC61937 payloads without CUVP and preambles */
187#define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
188/* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
189#define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
190
191/*
192 * IEC modes are mandatory for decoders. Format autodetection
193 * will only happen on the DSP side with mode 0. The PCM mode should
194 * not be used, the PCM codec should be used instead.
195 */
196#define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
197#define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
198#define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
199#define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
200#define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
201#define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
202#define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
203#define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
204#define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
205#define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
206#define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
207#define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
208#define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
209#define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
210#define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
211#define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
212#define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
213#define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
214#define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
215
216#define SND_AUDIOPROFILE_G723_1 ((__u32) 0x00000001)
217
218#define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
219#define SND_AUDIOMODE_G723_1_ANNEX_B ((__u32) 0x00000002)
220#define SND_AUDIOMODE_G723_1_ANNEX_C ((__u32) 0x00000004)
221
222#define SND_AUDIOPROFILE_G729 ((__u32) 0x00000001)
223
224#define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
225#define SND_AUDIOMODE_G729_ANNEX_B ((__u32) 0x00000002)
226
227/* <FIXME: multichannel encoders aren't supported for now. Would need
228 an additional definition of channel arrangement> */
229
230/* VBR/CBR definitions */
231#define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
232#define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
233
234/* Encoder options */
235
236struct snd_enc_wma {
237 __u32 super_block_align; /* WMA Type-specific data */
238};
239
240
241/**
242 * struct snd_enc_vorbis
243 * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
244 * In the default mode of operation, the quality level is 3.
245 * Normal quality range is 0 - 10.
246 * @managed: Boolean. Set bitrate management mode. This turns off the
247 * normal VBR encoding, but allows hard or soft bitrate constraints to be
248 * enforced by the encoder. This mode can be slower, and may also be
249 * lower quality. It is primarily useful for streaming.
250 * @max_bit_rate: Enabled only if managed is TRUE
251 * @min_bit_rate: Enabled only if managed is TRUE
252 * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
253 * non-stereo streams). Useful for lower-bitrate encoding.
254 *
255 * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
256 * properties
257 *
258 * For best quality users should specify VBR mode and set quality levels.
259 */
260
261struct snd_enc_vorbis {
262 __s32 quality;
263 __u32 managed;
264 __u32 max_bit_rate;
265 __u32 min_bit_rate;
266 __u32 downmix;
267};
268
269
270/**
271 * struct snd_enc_real
272 * @quant_bits: number of coupling quantization bits in the stream
273 * @start_region: coupling start region in the stream
274 * @num_regions: number of regions value
275 *
276 * These options were extracted from the OpenMAX IL spec
277 */
278
279struct snd_enc_real {
280 __u32 quant_bits;
281 __u32 start_region;
282 __u32 num_regions;
283};
284
285/**
286 * struct snd_enc_flac
287 * @num: serial number, valid only for OGG formats
288 * needs to be set by application
289 * @gain: Add replay gain tags
290 *
291 * These options were extracted from the FLAC online documentation
292 * at http://flac.sourceforge.net/documentation_tools_flac.html
293 *
294 * To make the API simpler, it is assumed that the user will select quality
295 * profiles. Additional options that affect encoding quality and speed can
296 * be added at a later stage if needed.
297 *
298 * By default the Subset format is used by encoders.
299 *
300 * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
301 * not supported in this API.
302 */
303
304struct snd_enc_flac {
305 __u32 num;
306 __u32 gain;
307};
308
309struct snd_enc_generic {
310 __u32 bw; /* encoder bandwidth */
311 __s32 reserved[15];
312};
313
314union snd_codec_options {
315 struct snd_enc_wma wma;
316 struct snd_enc_vorbis vorbis;
317 struct snd_enc_real real;
318 struct snd_enc_flac flac;
319 struct snd_enc_generic generic;
320};
321
322/** struct snd_codec_desc - description of codec capabilities
323 * @max_ch: Maximum number of audio channels
324 * @sample_rates: Sampling rates in Hz, use SNDRV_PCM_RATE_xxx for this
325 * @bit_rate: Indexed array containing supported bit rates
326 * @num_bitrates: Number of valid values in bit_rate array
327 * @rate_control: value is specified by SND_RATECONTROLMODE defines.
328 * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
329 * @modes: Supported modes. See SND_AUDIOMODE defines
330 * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
331 * @min_buffer: Minimum buffer size handled by codec implementation
332 * @reserved: reserved for future use
333 *
334 * This structure provides a scalar value for profiles, modes and stream
335 * format fields.
336 * If an implementation supports multiple combinations, they will be listed as
337 * codecs with different descriptors, for example there would be 2 descriptors
338 * for AAC-RAW and AAC-ADTS.
339 * This entails some redundancy but makes it easier to avoid invalid
340 * configurations.
341 *
342 */
343
344struct snd_codec_desc {
345 __u32 max_ch;
346 __u32 sample_rates;
347 __u32 bit_rate[MAX_NUM_BITRATES];
348 __u32 num_bitrates;
349 __u32 rate_control;
350 __u32 profiles;
351 __u32 modes;
352 __u32 formats;
353 __u32 min_buffer;
354 __u32 reserved[15];
355};
356
357/** struct snd_codec
358 * @id: Identifies the supported audio encoder/decoder.
359 * See SND_AUDIOCODEC macros.
360 * @ch_in: Number of input audio channels
361 * @ch_out: Number of output channels. In case of contradiction between
362 * this field and the channelMode field, the channelMode field
363 * overrides.
364 * @sample_rate: Audio sample rate of input data
365 * @bit_rate: Bitrate of encoded data. May be ignored by decoders
366 * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
367 * Encoders may rely on profiles for quality levels.
368 * May be ignored by decoders.
369 * @profile: Mandatory for encoders, can be mandatory for specific
370 * decoders as well. See SND_AUDIOPROFILE defines.
371 * @level: Supported level (Only used by WMA at the moment)
372 * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
373 * @format: Format of encoded bistream. Mandatory when defined.
374 * See SND_AUDIOSTREAMFORMAT defines.
375 * @align: Block alignment in bytes of an audio sample.
376 * Only required for PCM or IEC formats.
377 * @options: encoder-specific settings
378 * @reserved: reserved for future use
379 */
380
381struct snd_codec {
382 __u32 id;
383 __u32 ch_in;
384 __u32 ch_out;
385 __u32 sample_rate;
386 __u32 bit_rate;
387 __u32 rate_control;
388 __u32 profile;
389 __u32 level;
390 __u32 ch_mode;
391 __u32 format;
392 __u32 align;
393 union snd_codec_options options;
394 __u32 reserved[3];
395};
396
397#endif
diff --git a/include/sound/core.h b/include/sound/core.h
index 3be5ab782b99..5ab255f196cc 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -62,6 +62,7 @@ typedef int __bitwise snd_device_type_t;
62#define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007) 62#define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007)
63#define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008) 63#define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008)
64#define SNDRV_DEV_JACK ((__force snd_device_type_t) 0x1009) 64#define SNDRV_DEV_JACK ((__force snd_device_type_t) 0x1009)
65#define SNDRV_DEV_COMPRESS ((__force snd_device_type_t) 0x100A)
65#define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000) 66#define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000)
66 67
67typedef int __bitwise snd_device_state_t; 68typedef int __bitwise snd_device_state_t;
diff --git a/include/sound/minors.h b/include/sound/minors.h
index 8f764204a856..5978f9a8c8b2 100644
--- a/include/sound/minors.h
+++ b/include/sound/minors.h
@@ -35,7 +35,7 @@
35#define SNDRV_MINOR_TIMER 33 /* SNDRV_MINOR_GLOBAL + 1 * 32 */ 35#define SNDRV_MINOR_TIMER 33 /* SNDRV_MINOR_GLOBAL + 1 * 32 */
36 36
37#ifndef CONFIG_SND_DYNAMIC_MINORS 37#ifndef CONFIG_SND_DYNAMIC_MINORS
38 /* 2 - 3 (reserved) */ 38#define SNDRV_MINOR_COMPRESS 2 /* 2 - 3 */
39#define SNDRV_MINOR_HWDEP 4 /* 4 - 7 */ 39#define SNDRV_MINOR_HWDEP 4 /* 4 - 7 */
40#define SNDRV_MINOR_RAWMIDI 8 /* 8 - 15 */ 40#define SNDRV_MINOR_RAWMIDI 8 /* 8 - 15 */
41#define SNDRV_MINOR_PCM_PLAYBACK 16 /* 16 - 23 */ 41#define SNDRV_MINOR_PCM_PLAYBACK 16 /* 16 - 23 */
@@ -49,6 +49,7 @@
49#define SNDRV_DEVICE_TYPE_PCM_CAPTURE SNDRV_MINOR_PCM_CAPTURE 49#define SNDRV_DEVICE_TYPE_PCM_CAPTURE SNDRV_MINOR_PCM_CAPTURE
50#define SNDRV_DEVICE_TYPE_SEQUENCER SNDRV_MINOR_SEQUENCER 50#define SNDRV_DEVICE_TYPE_SEQUENCER SNDRV_MINOR_SEQUENCER
51#define SNDRV_DEVICE_TYPE_TIMER SNDRV_MINOR_TIMER 51#define SNDRV_DEVICE_TYPE_TIMER SNDRV_MINOR_TIMER
52#define SNDRV_DEVICE_TYPE_COMPRESS SNDRV_MINOR_COMPRESS
52 53
53#else /* CONFIG_SND_DYNAMIC_MINORS */ 54#else /* CONFIG_SND_DYNAMIC_MINORS */
54 55
@@ -60,6 +61,7 @@ enum {
60 SNDRV_DEVICE_TYPE_RAWMIDI, 61 SNDRV_DEVICE_TYPE_RAWMIDI,
61 SNDRV_DEVICE_TYPE_PCM_PLAYBACK, 62 SNDRV_DEVICE_TYPE_PCM_PLAYBACK,
62 SNDRV_DEVICE_TYPE_PCM_CAPTURE, 63 SNDRV_DEVICE_TYPE_PCM_CAPTURE,
64 SNDRV_DEVICE_TYPE_COMPRESS,
63}; 65};
64 66
65#endif /* CONFIG_SND_DYNAMIC_MINORS */ 67#endif /* CONFIG_SND_DYNAMIC_MINORS */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 5d9411839cd7..3a39626a82d6 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -251,18 +251,7 @@ static struct platform_driver pxa2xx_ac97_driver = {
251 }, 251 },
252}; 252};
253 253
254static int __init pxa2xx_ac97_init(void) 254module_platform_driver(pxa2xx_ac97_driver);
255{
256 return platform_driver_register(&pxa2xx_ac97_driver);
257}
258
259static void __exit pxa2xx_ac97_exit(void)
260{
261 platform_driver_unregister(&pxa2xx_ac97_driver);
262}
263
264module_init(pxa2xx_ac97_init);
265module_exit(pxa2xx_ac97_exit);
266 255
267MODULE_AUTHOR("Nicolas Pitre"); 256MODULE_AUTHOR("Nicolas Pitre");
268MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip"); 257MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index 475455c76610..2dc7776e218c 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -155,6 +155,16 @@ config SND_DYNAMIC_MINORS
155 155
156 If you are unsure about this, say N here. 156 If you are unsure about this, say N here.
157 157
158config SND_COMPRESS_OFFLOAD
159 tristate "ALSA Compressed audio offload support"
160 default n
161 help
162 If you want support for offloading compressed audio and have such
163 a hardware, then you should say Y here and also to the DSP driver
164 of your platform.
165
166 If you are unsure about this, say N here.
167
158config SND_SUPPORT_OLD_API 168config SND_SUPPORT_OLD_API
159 bool "Support old ALSA API" 169 bool "Support old ALSA API"
160 default y 170 default y
diff --git a/sound/core/Makefile b/sound/core/Makefile
index 350a08d277f4..67c8e9336611 100644
--- a/sound/core/Makefile
+++ b/sound/core/Makefile
@@ -21,6 +21,8 @@ snd-hrtimer-objs := hrtimer.o
21snd-rtctimer-objs := rtctimer.o 21snd-rtctimer-objs := rtctimer.o
22snd-hwdep-objs := hwdep.o 22snd-hwdep-objs := hwdep.o
23 23
24snd-compress-objs := compress_offload.o
25
24obj-$(CONFIG_SND) += snd.o 26obj-$(CONFIG_SND) += snd.o
25obj-$(CONFIG_SND_HWDEP) += snd-hwdep.o 27obj-$(CONFIG_SND_HWDEP) += snd-hwdep.o
26obj-$(CONFIG_SND_TIMER) += snd-timer.o 28obj-$(CONFIG_SND_TIMER) += snd-timer.o
@@ -31,3 +33,5 @@ obj-$(CONFIG_SND_RAWMIDI) += snd-rawmidi.o
31 33
32obj-$(CONFIG_SND_OSSEMUL) += oss/ 34obj-$(CONFIG_SND_OSSEMUL) += oss/
33obj-$(CONFIG_SND_SEQUENCER) += seq/ 35obj-$(CONFIG_SND_SEQUENCER) += seq/
36
37obj-$(CONFIG_SND_COMPRESS_OFFLOAD) += snd-compress.o
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
new file mode 100644
index 000000000000..dac3633507c9
--- /dev/null
+++ b/sound/core/compress_offload.c
@@ -0,0 +1,765 @@
1/*
2 * compress_core.c - compress offload core
3 *
4 * Copyright (C) 2011 Intel Corporation
5 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
6 * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 *
24 */
25#define FORMAT(fmt) "%s: %d: " fmt, __func__, __LINE__
26#define pr_fmt(fmt) KBUILD_MODNAME ": " FORMAT(fmt)
27
28#include <linux/file.h>
29#include <linux/fs.h>
30#include <linux/list.h>
31#include <linux/mm.h>
32#include <linux/mutex.h>
33#include <linux/poll.h>
34#include <linux/slab.h>
35#include <linux/sched.h>
36#include <linux/uio.h>
37#include <linux/uaccess.h>
38#include <linux/module.h>
39#include <sound/core.h>
40#include <sound/initval.h>
41#include <sound/compress_params.h>
42#include <sound/compress_offload.h>
43#include <sound/compress_driver.h>
44
45/* TODO:
46 * - add substream support for multiple devices in case of
47 * SND_DYNAMIC_MINORS is not used
48 * - Multiple node representation
49 * driver should be able to register multiple nodes
50 */
51
52static DEFINE_MUTEX(device_mutex);
53
54struct snd_compr_file {
55 unsigned long caps;
56 struct snd_compr_stream stream;
57};
58
59/*
60 * a note on stream states used:
61 * we use follwing states in the compressed core
62 * SNDRV_PCM_STATE_OPEN: When stream has been opened.
63 * SNDRV_PCM_STATE_SETUP: When stream has been initialized. This is done by
64 * calling SNDRV_COMPRESS_SET_PARAMS. running streams will come to this
65 * state at stop by calling SNDRV_COMPRESS_STOP, or at end of drain.
66 * SNDRV_PCM_STATE_RUNNING: When stream has been started and is
67 * decoding/encoding and rendering/capturing data.
68 * SNDRV_PCM_STATE_DRAINING: When stream is draining current data. This is done
69 * by calling SNDRV_COMPRESS_DRAIN.
70 * SNDRV_PCM_STATE_PAUSED: When stream is paused. This is done by calling
71 * SNDRV_COMPRESS_PAUSE. It can be stopped or resumed by calling
72 * SNDRV_COMPRESS_STOP or SNDRV_COMPRESS_RESUME respectively.
73 */
74static int snd_compr_open(struct inode *inode, struct file *f)
75{
76 struct snd_compr *compr;
77 struct snd_compr_file *data;
78 struct snd_compr_runtime *runtime;
79 enum snd_compr_direction dirn;
80 int maj = imajor(inode);
81 int ret;
82
83 if (f->f_flags & O_WRONLY)
84 dirn = SND_COMPRESS_PLAYBACK;
85 else if (f->f_flags & O_RDONLY)
86 dirn = SND_COMPRESS_CAPTURE;
87 else {
88 pr_err("invalid direction\n");
89 return -EINVAL;
90 }
91
92 if (maj == snd_major)
93 compr = snd_lookup_minor_data(iminor(inode),
94 SNDRV_DEVICE_TYPE_COMPRESS);
95 else
96 return -EBADFD;
97
98 if (compr == NULL) {
99 pr_err("no device data!!!\n");
100 return -ENODEV;
101 }
102
103 if (dirn != compr->direction) {
104 pr_err("this device doesn't support this direction\n");
105 return -EINVAL;
106 }
107
108 data = kzalloc(sizeof(*data), GFP_KERNEL);
109 if (!data)
110 return -ENOMEM;
111 data->stream.ops = compr->ops;
112 data->stream.direction = dirn;
113 data->stream.private_data = compr->private_data;
114 data->stream.device = compr;
115 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
116 if (!runtime) {
117 kfree(data);
118 return -ENOMEM;
119 }
120 runtime->state = SNDRV_PCM_STATE_OPEN;
121 init_waitqueue_head(&runtime->sleep);
122 data->stream.runtime = runtime;
123 f->private_data = (void *)data;
124 mutex_lock(&compr->lock);
125 ret = compr->ops->open(&data->stream);
126 mutex_unlock(&compr->lock);
127 if (ret) {
128 kfree(runtime);
129 kfree(data);
130 }
131 return ret;
132}
133
134static int snd_compr_free(struct inode *inode, struct file *f)
135{
136 struct snd_compr_file *data = f->private_data;
137 data->stream.ops->free(&data->stream);
138 kfree(data->stream.runtime->buffer);
139 kfree(data->stream.runtime);
140 kfree(data);
141 return 0;
142}
143
144static void snd_compr_update_tstamp(struct snd_compr_stream *stream,
145 struct snd_compr_tstamp *tstamp)
146{
147 if (!stream->ops->pointer)
148 return;
149 stream->ops->pointer(stream, tstamp);
150 pr_debug("dsp consumed till %d total %d bytes\n",
151 tstamp->byte_offset, tstamp->copied_total);
152 stream->runtime->hw_pointer = tstamp->byte_offset;
153 stream->runtime->total_bytes_transferred = tstamp->copied_total;
154}
155
156static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
157 struct snd_compr_avail *avail)
158{
159 long avail_calc; /*this needs to be signed variable */
160
161 snd_compr_update_tstamp(stream, &avail->tstamp);
162
163 /* FIXME: This needs to be different for capture stream,
164 available is # of compressed data, for playback it's
165 remainder of buffer */
166
167 if (stream->runtime->total_bytes_available == 0 &&
168 stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
169 pr_debug("detected init and someone forgot to do a write\n");
170 return stream->runtime->buffer_size;
171 }
172 pr_debug("app wrote %lld, DSP consumed %lld\n",
173 stream->runtime->total_bytes_available,
174 stream->runtime->total_bytes_transferred);
175 if (stream->runtime->total_bytes_available ==
176 stream->runtime->total_bytes_transferred) {
177 pr_debug("both pointers are same, returning full avail\n");
178 return stream->runtime->buffer_size;
179 }
180
181 /* FIXME: this routine isn't consistent, in one test we use
182 * cumulative values and in the other byte offsets. Do we
183 * really need the byte offsets if the cumulative values have
184 * been updated? In the PCM interface app_ptr and hw_ptr are
185 * already cumulative */
186
187 avail_calc = stream->runtime->buffer_size -
188 (stream->runtime->app_pointer - stream->runtime->hw_pointer);
189 pr_debug("calc avail as %ld, app_ptr %lld, hw+ptr %lld\n", avail_calc,
190 stream->runtime->app_pointer,
191 stream->runtime->hw_pointer);
192 if (avail_calc >= stream->runtime->buffer_size)
193 avail_calc -= stream->runtime->buffer_size;
194 pr_debug("ret avail as %ld\n", avail_calc);
195 avail->avail = avail_calc;
196 return avail_calc;
197}
198
199static inline size_t snd_compr_get_avail(struct snd_compr_stream *stream)
200{
201 struct snd_compr_avail avail;
202
203 return snd_compr_calc_avail(stream, &avail);
204}
205
206static int
207snd_compr_ioctl_avail(struct snd_compr_stream *stream, unsigned long arg)
208{
209 struct snd_compr_avail ioctl_avail;
210 size_t avail;
211
212 avail = snd_compr_calc_avail(stream, &ioctl_avail);
213 ioctl_avail.avail = avail;
214
215 if (copy_to_user((__u64 __user *)arg,
216 &ioctl_avail, sizeof(ioctl_avail)))
217 return -EFAULT;
218 return 0;
219}
220
221static int snd_compr_write_data(struct snd_compr_stream *stream,
222 const char __user *buf, size_t count)
223{
224 void *dstn;
225 size_t copy;
226 struct snd_compr_runtime *runtime = stream->runtime;
227
228 dstn = runtime->buffer + runtime->app_pointer;
229 pr_debug("copying %ld at %lld\n",
230 (unsigned long)count, runtime->app_pointer);
231 if (count < runtime->buffer_size - runtime->app_pointer) {
232 if (copy_from_user(dstn, buf, count))
233 return -EFAULT;
234 runtime->app_pointer += count;
235 } else {
236 copy = runtime->buffer_size - runtime->app_pointer;
237 if (copy_from_user(dstn, buf, copy))
238 return -EFAULT;
239 if (copy_from_user(runtime->buffer, buf + copy, count - copy))
240 return -EFAULT;
241 runtime->app_pointer = count - copy;
242 }
243 /* if DSP cares, let it know data has been written */
244 if (stream->ops->ack)
245 stream->ops->ack(stream, count);
246 return count;
247}
248
249static ssize_t snd_compr_write(struct file *f, const char __user *buf,
250 size_t count, loff_t *offset)
251{
252 struct snd_compr_file *data = f->private_data;
253 struct snd_compr_stream *stream;
254 size_t avail;
255 int retval;
256
257 if (snd_BUG_ON(!data))
258 return -EFAULT;
259
260 stream = &data->stream;
261 mutex_lock(&stream->device->lock);
262 /* write is allowed when stream is running or has been steup */
263 if (stream->runtime->state != SNDRV_PCM_STATE_SETUP &&
264 stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
265 mutex_unlock(&stream->device->lock);
266 return -EBADFD;
267 }
268
269 avail = snd_compr_get_avail(stream);
270 pr_debug("avail returned %ld\n", (unsigned long)avail);
271 /* calculate how much we can write to buffer */
272 if (avail > count)
273 avail = count;
274
275 if (stream->ops->copy)
276 retval = stream->ops->copy(stream, buf, avail);
277 else
278 retval = snd_compr_write_data(stream, buf, avail);
279 if (retval > 0)
280 stream->runtime->total_bytes_available += retval;
281
282 /* while initiating the stream, write should be called before START
283 * call, so in setup move state */
284 if (stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
285 stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
286 pr_debug("stream prepared, Houston we are good to go\n");
287 }
288
289 mutex_unlock(&stream->device->lock);
290 return retval;
291}
292
293
294static ssize_t snd_compr_read(struct file *f, char __user *buf,
295 size_t count, loff_t *offset)
296{
297 return -ENXIO;
298}
299
300static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma)
301{
302 return -ENXIO;
303}
304
305static inline int snd_compr_get_poll(struct snd_compr_stream *stream)
306{
307 if (stream->direction == SND_COMPRESS_PLAYBACK)
308 return POLLOUT | POLLWRNORM;
309 else
310 return POLLIN | POLLRDNORM;
311}
312
313static unsigned int snd_compr_poll(struct file *f, poll_table *wait)
314{
315 struct snd_compr_file *data = f->private_data;
316 struct snd_compr_stream *stream;
317 size_t avail;
318 int retval = 0;
319
320 if (snd_BUG_ON(!data))
321 return -EFAULT;
322 stream = &data->stream;
323 if (snd_BUG_ON(!stream))
324 return -EFAULT;
325
326 mutex_lock(&stream->device->lock);
327 if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED ||
328 stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
329 retval = -EBADFD;
330 goto out;
331 }
332 poll_wait(f, &stream->runtime->sleep, wait);
333
334 avail = snd_compr_get_avail(stream);
335 pr_debug("avail is %ld\n", (unsigned long)avail);
336 /* check if we have at least one fragment to fill */
337 switch (stream->runtime->state) {
338 case SNDRV_PCM_STATE_DRAINING:
339 /* stream has been woken up after drain is complete
340 * draining done so set stream state to stopped
341 */
342 retval = snd_compr_get_poll(stream);
343 stream->runtime->state = SNDRV_PCM_STATE_SETUP;
344 break;
345 case SNDRV_PCM_STATE_RUNNING:
346 case SNDRV_PCM_STATE_PREPARED:
347 case SNDRV_PCM_STATE_PAUSED:
348 if (avail >= stream->runtime->fragment_size)
349 retval = snd_compr_get_poll(stream);
350 break;
351 default:
352 if (stream->direction == SND_COMPRESS_PLAYBACK)
353 retval = POLLOUT | POLLWRNORM | POLLERR;
354 else
355 retval = POLLIN | POLLRDNORM | POLLERR;
356 break;
357 }
358out:
359 mutex_unlock(&stream->device->lock);
360 return retval;
361}
362
363static int
364snd_compr_get_caps(struct snd_compr_stream *stream, unsigned long arg)
365{
366 int retval;
367 struct snd_compr_caps caps;
368
369 if (!stream->ops->get_caps)
370 return -ENXIO;
371
372 retval = stream->ops->get_caps(stream, &caps);
373 if (retval)
374 goto out;
375 if (copy_to_user((void __user *)arg, &caps, sizeof(caps)))
376 retval = -EFAULT;
377out:
378 return retval;
379}
380
381static int
382snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg)
383{
384 int retval;
385 struct snd_compr_codec_caps *caps;
386
387 if (!stream->ops->get_codec_caps)
388 return -ENXIO;
389
390 caps = kmalloc(sizeof(*caps), GFP_KERNEL);
391 if (!caps)
392 return -ENOMEM;
393
394 retval = stream->ops->get_codec_caps(stream, caps);
395 if (retval)
396 goto out;
397 if (copy_to_user((void __user *)arg, caps, sizeof(*caps)))
398 retval = -EFAULT;
399
400out:
401 kfree(caps);
402 return retval;
403}
404
405/* revisit this with snd_pcm_preallocate_xxx */
406static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,
407 struct snd_compr_params *params)
408{
409 unsigned int buffer_size;
410 void *buffer;
411
412 buffer_size = params->buffer.fragment_size * params->buffer.fragments;
413 if (stream->ops->copy) {
414 buffer = NULL;
415 /* if copy is defined the driver will be required to copy
416 * the data from core
417 */
418 } else {
419 buffer = kmalloc(buffer_size, GFP_KERNEL);
420 if (!buffer)
421 return -ENOMEM;
422 }
423 stream->runtime->fragment_size = params->buffer.fragment_size;
424 stream->runtime->fragments = params->buffer.fragments;
425 stream->runtime->buffer = buffer;
426 stream->runtime->buffer_size = buffer_size;
427 return 0;
428}
429
430static int
431snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
432{
433 struct snd_compr_params *params;
434 int retval;
435
436 if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
437 /*
438 * we should allow parameter change only when stream has been
439 * opened not in other cases
440 */
441 params = kmalloc(sizeof(*params), GFP_KERNEL);
442 if (!params)
443 return -ENOMEM;
444 if (copy_from_user(params, (void __user *)arg, sizeof(*params)))
445 return -EFAULT;
446 retval = snd_compr_allocate_buffer(stream, params);
447 if (retval) {
448 kfree(params);
449 return -ENOMEM;
450 }
451 retval = stream->ops->set_params(stream, params);
452 if (retval)
453 goto out;
454 stream->runtime->state = SNDRV_PCM_STATE_SETUP;
455 } else
456 return -EPERM;
457out:
458 kfree(params);
459 return retval;
460}
461
462static int
463snd_compr_get_params(struct snd_compr_stream *stream, unsigned long arg)
464{
465 struct snd_codec *params;
466 int retval;
467
468 if (!stream->ops->get_params)
469 return -EBADFD;
470
471 params = kmalloc(sizeof(*params), GFP_KERNEL);
472 if (!params)
473 return -ENOMEM;
474 retval = stream->ops->get_params(stream, params);
475 if (retval)
476 goto out;
477 if (copy_to_user((char __user *)arg, params, sizeof(*params)))
478 retval = -EFAULT;
479
480out:
481 kfree(params);
482 return retval;
483}
484
485static inline int
486snd_compr_tstamp(struct snd_compr_stream *stream, unsigned long arg)
487{
488 struct snd_compr_tstamp tstamp;
489
490 snd_compr_update_tstamp(stream, &tstamp);
491 return copy_to_user((struct snd_compr_tstamp __user *)arg,
492 &tstamp, sizeof(tstamp)) ? -EFAULT : 0;
493}
494
495static int snd_compr_pause(struct snd_compr_stream *stream)
496{
497 int retval;
498
499 if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
500 return -EPERM;
501 retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_PUSH);
502 if (!retval) {
503 stream->runtime->state = SNDRV_PCM_STATE_PAUSED;
504 wake_up(&stream->runtime->sleep);
505 }
506 return retval;
507}
508
509static int snd_compr_resume(struct snd_compr_stream *stream)
510{
511 int retval;
512
513 if (stream->runtime->state != SNDRV_PCM_STATE_PAUSED)
514 return -EPERM;
515 retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
516 if (!retval)
517 stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
518 return retval;
519}
520
521static int snd_compr_start(struct snd_compr_stream *stream)
522{
523 int retval;
524
525 if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED)
526 return -EPERM;
527 retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START);
528 if (!retval)
529 stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
530 return retval;
531}
532
533static int snd_compr_stop(struct snd_compr_stream *stream)
534{
535 int retval;
536
537 if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
538 stream->runtime->state == SNDRV_PCM_STATE_SETUP)
539 return -EPERM;
540 retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
541 if (!retval) {
542 stream->runtime->state = SNDRV_PCM_STATE_SETUP;
543 wake_up(&stream->runtime->sleep);
544 }
545 return retval;
546}
547
548static int snd_compr_drain(struct snd_compr_stream *stream)
549{
550 int retval;
551
552 if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
553 stream->runtime->state == SNDRV_PCM_STATE_SETUP)
554 return -EPERM;
555 retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
556 if (!retval) {
557 stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
558 wake_up(&stream->runtime->sleep);
559 }
560 return retval;
561}
562
563static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
564{
565 struct snd_compr_file *data = f->private_data;
566 struct snd_compr_stream *stream;
567 int retval = -ENOTTY;
568
569 if (snd_BUG_ON(!data))
570 return -EFAULT;
571 stream = &data->stream;
572 if (snd_BUG_ON(!stream))
573 return -EFAULT;
574 mutex_lock(&stream->device->lock);
575 switch (_IOC_NR(cmd)) {
576 case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
577 put_user(SNDRV_COMPRESS_VERSION,
578 (int __user *)arg) ? -EFAULT : 0;
579 break;
580 case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
581 retval = snd_compr_get_caps(stream, arg);
582 break;
583 case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS):
584 retval = snd_compr_get_codec_caps(stream, arg);
585 break;
586 case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS):
587 retval = snd_compr_set_params(stream, arg);
588 break;
589 case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS):
590 retval = snd_compr_get_params(stream, arg);
591 break;
592 case _IOC_NR(SNDRV_COMPRESS_TSTAMP):
593 retval = snd_compr_tstamp(stream, arg);
594 break;
595 case _IOC_NR(SNDRV_COMPRESS_AVAIL):
596 retval = snd_compr_ioctl_avail(stream, arg);
597 break;
598 case _IOC_NR(SNDRV_COMPRESS_PAUSE):
599 retval = snd_compr_pause(stream);
600 break;
601 case _IOC_NR(SNDRV_COMPRESS_RESUME):
602 retval = snd_compr_resume(stream);
603 break;
604 case _IOC_NR(SNDRV_COMPRESS_START):
605 retval = snd_compr_start(stream);
606 break;
607 case _IOC_NR(SNDRV_COMPRESS_STOP):
608 retval = snd_compr_stop(stream);
609 break;
610 case _IOC_NR(SNDRV_COMPRESS_DRAIN):
611 retval = snd_compr_drain(stream);
612 break;
613 }
614 mutex_unlock(&stream->device->lock);
615 return retval;
616}
617
618static const struct file_operations snd_compr_file_ops = {
619 .owner = THIS_MODULE,
620 .open = snd_compr_open,
621 .release = snd_compr_free,
622 .write = snd_compr_write,
623 .read = snd_compr_read,
624 .unlocked_ioctl = snd_compr_ioctl,
625 .mmap = snd_compr_mmap,
626 .poll = snd_compr_poll,
627};
628
629static int snd_compress_dev_register(struct snd_device *device)
630{
631 int ret = -EINVAL;
632 char str[16];
633 struct snd_compr *compr;
634
635 if (snd_BUG_ON(!device || !device->device_data))
636 return -EBADFD;
637 compr = device->device_data;
638
639 sprintf(str, "comprC%iD%i", compr->card->number, compr->device);
640 pr_debug("reg %s for device %s, direction %d\n", str, compr->name,
641 compr->direction);
642 /* register compressed device */
643 ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card,
644 compr->device, &snd_compr_file_ops, compr, str);
645 if (ret < 0) {
646 pr_err("snd_register_device failed\n %d", ret);
647 return ret;
648 }
649 return ret;
650
651}
652
653static int snd_compress_dev_disconnect(struct snd_device *device)
654{
655 struct snd_compr *compr;
656
657 compr = device->device_data;
658 snd_unregister_device(compr->direction, compr->card, compr->device);
659 return 0;
660}
661
662/*
663 * snd_compress_new: create new compress device
664 * @card: sound card pointer
665 * @device: device number
666 * @dirn: device direction, should be of type enum snd_compr_direction
667 * @compr: compress device pointer
668 */
669int snd_compress_new(struct snd_card *card, int device,
670 int dirn, struct snd_compr *compr)
671{
672 static struct snd_device_ops ops = {
673 .dev_free = NULL,
674 .dev_register = snd_compress_dev_register,
675 .dev_disconnect = snd_compress_dev_disconnect,
676 };
677
678 compr->card = card;
679 compr->device = device;
680 compr->direction = dirn;
681 return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops);
682}
683EXPORT_SYMBOL_GPL(snd_compress_new);
684
685static int snd_compress_add_device(struct snd_compr *device)
686{
687 int ret;
688
689 if (!device->card)
690 return -EINVAL;
691
692 /* register the card */
693 ret = snd_card_register(device->card);
694 if (ret)
695 goto out;
696 return 0;
697
698out:
699 pr_err("failed with %d\n", ret);
700 return ret;
701
702}
703
704static int snd_compress_remove_device(struct snd_compr *device)
705{
706 return snd_card_free(device->card);
707}
708
709/**
710 * snd_compress_register - register compressed device
711 *
712 * @device: compressed device to register
713 */
714int snd_compress_register(struct snd_compr *device)
715{
716 int retval;
717
718 if (device->name == NULL || device->dev == NULL || device->ops == NULL)
719 return -EINVAL;
720
721 pr_debug("Registering compressed device %s\n", device->name);
722 if (snd_BUG_ON(!device->ops->open))
723 return -EINVAL;
724 if (snd_BUG_ON(!device->ops->free))
725 return -EINVAL;
726 if (snd_BUG_ON(!device->ops->set_params))
727 return -EINVAL;
728 if (snd_BUG_ON(!device->ops->trigger))
729 return -EINVAL;
730
731 mutex_init(&device->lock);
732
733 /* register a compressed card */
734 mutex_lock(&device_mutex);
735 retval = snd_compress_add_device(device);
736 mutex_unlock(&device_mutex);
737 return retval;
738}
739EXPORT_SYMBOL_GPL(snd_compress_register);
740
741int snd_compress_deregister(struct snd_compr *device)
742{
743 pr_debug("Removing compressed device %s\n", device->name);
744 mutex_lock(&device_mutex);
745 snd_compress_remove_device(device);
746 mutex_unlock(&device_mutex);
747 return 0;
748}
749EXPORT_SYMBOL_GPL(snd_compress_deregister);
750
751static int __init snd_compress_init(void)
752{
753 return 0;
754}
755
756static void __exit snd_compress_exit(void)
757{
758}
759
760module_init(snd_compress_init);
761module_exit(snd_compress_exit);
762
763MODULE_DESCRIPTION("ALSA Compressed offload framework");
764MODULE_AUTHOR("Vinod Koul <vinod.koul@linux.intel.com>");
765MODULE_LICENSE("GPL v2");
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 3cc4b86dfb7e..08fde0060fd9 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -47,7 +47,7 @@
47 47
48static int dsp_map[SNDRV_CARDS]; 48static int dsp_map[SNDRV_CARDS];
49static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1}; 49static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
50static int nonblock_open = 1; 50static bool nonblock_open = 1;
51 51
52MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>"); 52MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>");
53MODULE_DESCRIPTION("PCM OSS emulation for ALSA."); 53MODULE_DESCRIPTION("PCM OSS emulation for ALSA.");
diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
index b9b2235d9ab1..bbe32d2177d9 100644
--- a/sound/core/seq/seq_dummy.c
+++ b/sound/core/seq/seq_dummy.c
@@ -65,7 +65,7 @@ MODULE_LICENSE("GPL");
65MODULE_ALIAS("snd-seq-client-" __stringify(SNDRV_SEQ_CLIENT_DUMMY)); 65MODULE_ALIAS("snd-seq-client-" __stringify(SNDRV_SEQ_CLIENT_DUMMY));
66 66
67static int ports = 1; 67static int ports = 1;
68static int duplex; 68static bool duplex;
69 69
70module_param(ports, int, 0444); 70module_param(ports, int, 0444);
71MODULE_PARM_DESC(ports, "number of ports to be created"); 71MODULE_PARM_DESC(ports, "number of ports to be created");
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 828af353ea9f..28f35593a750 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -229,6 +229,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
229 case SNDRV_DEVICE_TYPE_RAWMIDI: 229 case SNDRV_DEVICE_TYPE_RAWMIDI:
230 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: 230 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK:
231 case SNDRV_DEVICE_TYPE_PCM_CAPTURE: 231 case SNDRV_DEVICE_TYPE_PCM_CAPTURE:
232 case SNDRV_DEVICE_TYPE_COMPRESS:
232 if (snd_BUG_ON(!card)) 233 if (snd_BUG_ON(!card))
233 return -EINVAL; 234 return -EINVAL;
234 minor = SNDRV_MINOR(card->number, type + dev); 235 minor = SNDRV_MINOR(card->number, type + dev);
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index d83bafc5d8b5..ad079b63b8ba 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -51,7 +51,7 @@ MODULE_SUPPORTED_DEVICE("{{ALSA,Loopback soundcard}}");
51 51
52static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 52static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
53static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 53static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
54static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 54static bool enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
55static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; 55static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
56static int pcm_notify[SNDRV_CARDS]; 56static int pcm_notify[SNDRV_CARDS];
57 57
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 97f1f93ed275..ad9434fd6370 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -60,15 +60,15 @@ MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}");
60 60
61static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 61static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
62static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 62static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
63static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 63static bool enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
64static char *model[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = NULL}; 64static char *model[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = NULL};
65static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 65static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
66static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; 66static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
67//static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 67//static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
68#ifdef CONFIG_HIGH_RES_TIMERS 68#ifdef CONFIG_HIGH_RES_TIMERS
69static int hrtimer = 1; 69static bool hrtimer = 1;
70#endif 70#endif
71static int fake_buffer = 1; 71static bool fake_buffer = 1;
72 72
73module_param_array(index, int, NULL, 0444); 73module_param_array(index, int, NULL, 0444);
74MODULE_PARM_DESC(index, "Index value for dummy soundcard."); 74MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
index 2ee82c5d9ee5..6c83b1aed288 100644
--- a/sound/drivers/ml403-ac97cr.c
+++ b/sound/drivers/ml403-ac97cr.c
@@ -73,7 +73,7 @@ MODULE_SUPPORTED_DEVICE("{{Xilinx,ML403 AC97 Controller Reference}}");
73 73
74static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 74static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
75static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 75static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
76static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; 76static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
77 77
78module_param_array(index, int, NULL, 0444); 78module_param_array(index, int, NULL, 0444);
79MODULE_PARM_DESC(index, "Index value for ML403 AC97 Controller Reference."); 79MODULE_PARM_DESC(index, "Index value for ML403 AC97 Controller Reference.");
@@ -1341,15 +1341,4 @@ static struct platform_driver snd_ml403_ac97cr_driver = {
1341 }, 1341 },
1342}; 1342};
1343 1343
1344static int __init alsa_card_ml403_ac97cr_init(void) 1344module_platform_driver(snd_ml403_ac97cr_driver);
1345{
1346 return platform_driver_register(&snd_ml403_ac97cr_driver);
1347}
1348
1349static void __exit alsa_card_ml403_ac97cr_exit(void)
1350{
1351 platform_driver_unregister(&snd_ml403_ac97cr_driver);
1352}
1353
1354module_init(alsa_card_ml403_ac97cr_init)
1355module_exit(alsa_card_ml403_ac97cr_exit)
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index 257569014f23..86f5fbc2da72 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -35,13 +35,13 @@ MODULE_LICENSE("GPL");
35 35
36static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* exclude the first card */ 36static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* exclude the first card */
37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
38static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 38static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
39#ifdef CONFIG_PNP 39#ifdef CONFIG_PNP
40static int pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 40static bool pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
41#endif 41#endif
42static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */ 42static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */
43static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ 43static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */
44static int uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 44static bool uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
45 45
46module_param_array(index, int, NULL, 0444); 46module_param_array(index, int, NULL, 0444);
47MODULE_PARM_DESC(index, "Index value for MPU-401 device."); 47MODULE_PARM_DESC(index, "Index value for MPU-401 device.");
diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index f24bf9a06cff..621e60e2029f 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -36,7 +36,7 @@
36 36
37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
39static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 39static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
40 40
41static struct platform_device *platform_devices[SNDRV_CARDS]; 41static struct platform_device *platform_devices[SNDRV_CARDS];
42static int device_count; 42static int device_count;
diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c
index 7d722a025d0d..2bfe4bcb7a7d 100644
--- a/sound/drivers/opl3/opl3_midi.c
+++ b/sound/drivers/opl3/opl3_midi.c
@@ -27,7 +27,7 @@
27 27
28extern char snd_opl3_regmap[MAX_OPL2_VOICES][4]; 28extern char snd_opl3_regmap[MAX_OPL2_VOICES][4];
29 29
30extern int use_internal_drums; 30extern bool use_internal_drums;
31 31
32static void snd_opl3_note_off_unsafe(void *p, int note, int vel, 32static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
33 struct snd_midi_channel *chan); 33 struct snd_midi_channel *chan);
diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c
index 723562e34fcc..68399538e435 100644
--- a/sound/drivers/opl3/opl3_seq.c
+++ b/sound/drivers/opl3/opl3_seq.c
@@ -32,7 +32,7 @@ MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
32MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
33MODULE_DESCRIPTION("ALSA driver for OPL3 FM synth"); 33MODULE_DESCRIPTION("ALSA driver for OPL3 FM synth");
34 34
35int use_internal_drums = 0; 35bool use_internal_drums = 0;
36module_param(use_internal_drums, bool, 0444); 36module_param(use_internal_drums, bool, 0444);
37MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); 37MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums.");
38 38
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 946a0cb996a9..99704e6a2e26 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -25,8 +25,8 @@ MODULE_ALIAS("platform:pcspkr");
25 25
26static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 26static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
27static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 27static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
28static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ 28static bool enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
29static int nopcm; /* Disable PCM capability of the driver */ 29static bool nopcm; /* Disable PCM capability of the driver */
30 30
31module_param(index, int, 0444); 31module_param(index, int, 0444);
32MODULE_PARM_DESC(index, "Index value for pcsp soundcard."); 32MODULE_PARM_DESC(index, "Index value for pcsp soundcard.");
diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c
index ce9e7d170c0d..434981dd4a61 100644
--- a/sound/drivers/pcsp/pcsp_lib.c
+++ b/sound/drivers/pcsp/pcsp_lib.c
@@ -14,7 +14,7 @@
14#include <asm/io.h> 14#include <asm/io.h>
15#include "pcsp.h" 15#include "pcsp.h"
16 16
17static int nforce_wa; 17static bool nforce_wa;
18module_param(nforce_wa, bool, 0444); 18module_param(nforce_wa, bool, 0444);
19MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround " 19MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround "
20 "(expect bad sound)"); 20 "(expect bad sound)");
diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
index f664823a9635..3e32bd3d95d9 100644
--- a/sound/drivers/portman2x4.c
+++ b/sound/drivers/portman2x4.c
@@ -55,7 +55,7 @@
55 55
56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
58static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 58static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
59 59
60static struct platform_device *platform_devices[SNDRV_CARDS]; 60static struct platform_device *platform_devices[SNDRV_CARDS];
61static int device_count; 61static int device_count;
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 85aad43f0b1e..b2d0e8e49bed 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -69,7 +69,7 @@ static char *adaptor_names[] = {
69 69
70static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 70static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
71static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 71static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
72static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 72static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
73static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x3f8,0x2f8,0x3e8,0x2e8 */ 73static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x3f8,0x2f8,0x3e8,0x2e8 */
74static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 3,4,5,7,9,10,11,14,15 */ 74static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 3,4,5,7,9,10,11,14,15 */
75static int speed[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 38400}; /* 9600,19200,38400,57600,115200 */ 75static int speed[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 38400}; /* 9600,19200,38400,57600,115200 */
@@ -77,7 +77,7 @@ static int base[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 115200}; /* baud bas
77static int outs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* 1 to 16 */ 77static int outs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* 1 to 16 */
78static int ins[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* 1 to 16 */ 78static int ins[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; /* 1 to 16 */
79static int adaptor[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = SNDRV_SERIAL_SOUNDCANVAS}; 79static int adaptor[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = SNDRV_SERIAL_SOUNDCANVAS};
80static int droponfull[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS -1)] = SNDRV_SERIAL_NORMALBUFF }; 80static bool droponfull[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS -1)] = SNDRV_SERIAL_NORMALBUFF };
81 81
82module_param_array(index, int, NULL, 0444); 82module_param_array(index, int, NULL, 0444);
83MODULE_PARM_DESC(index, "Index value for Serial MIDI."); 83MODULE_PARM_DESC(index, "Index value for Serial MIDI.");
diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
index d79d6edc0f52..9d97478a18b3 100644
--- a/sound/drivers/virmidi.c
+++ b/sound/drivers/virmidi.c
@@ -63,7 +63,7 @@ MODULE_SUPPORTED_DEVICE("{{ALSA,Virtual rawmidi device}}");
63 63
64static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 64static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
65static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 65static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
66static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 66static bool enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
67static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4}; 67static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
68 68
69module_param_array(index, int, NULL, 0444); 69module_param_array(index, int, NULL, 0444);
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index cd44c74207d8..94b83b6e46a3 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -44,7 +44,7 @@ MODULE_SUPPORTED_DEVICE("{{Highscreen,Sound-Boostar 16 3D},"
44 44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */ 45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 47static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
48static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 48static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
49static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 49static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
50static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 50static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 34ab69bdffc0..2af77faefbb1 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -43,11 +43,11 @@ MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848},"
43 43
44static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 44static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
45static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 45static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
46static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 46static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
47static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 47static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
48static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ 48static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
49static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ 49static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
50static int thinkpad[SNDRV_CARDS]; /* Thinkpad special case */ 50static bool thinkpad[SNDRV_CARDS]; /* Thinkpad special case */
51 51
52module_param_array(index, int, NULL, 0444); 52module_param_array(index, int, NULL, 0444);
53MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); 53MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c
index 7465ae036e0b..4d50c69f3290 100644
--- a/sound/isa/adlib.c
+++ b/sound/isa/adlib.c
@@ -18,7 +18,7 @@ MODULE_LICENSE("GPL");
18 18
19static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 19static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
20static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 20static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
21static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; 21static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
22static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 22static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
23 23
24module_param_array(index, int, NULL, 0444); 24module_param_array(index, int, NULL, 0444);
diff --git a/sound/isa/als100.c b/sound/isa/als100.c
index fc5b38fd2652..d1f4351fb6ee 100644
--- a/sound/isa/als100.c
+++ b/sound/isa/als100.c
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
54 54
55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
57static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 57static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
58static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 58static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
59static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 59static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
60static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 60static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c
index e55f3ebe87b9..6a2c78ef1d8f 100644
--- a/sound/isa/azt2320.c
+++ b/sound/isa/azt2320.c
@@ -55,7 +55,7 @@ MODULE_SUPPORTED_DEVICE("{{Aztech Systems,PRO16V},"
55 55
56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
58static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 58static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
59static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 59static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
60static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 60static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
61static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 61static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index c94578d40b1a..7bd5e337ee93 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -69,9 +69,9 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8330,isapnp:{CMI0001,@@@0001,@X@0001}}}");
69 69
70static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 70static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
71static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 71static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
72static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; 72static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
73#ifdef CONFIG_PNP 73#ifdef CONFIG_PNP
74static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 74static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
75#endif 75#endif
76static long sbport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 76static long sbport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
77static int sbirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; 77static int sbirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index 6d81fa75c33d..99dda45e82f5 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -41,7 +41,7 @@ MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}");
41 41
42static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 42static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
43static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 43static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
44static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 44static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
45static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 45static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
46static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 46static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
47static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ 47static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index f5a94b6e6245..740c51a1ed7b 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -74,9 +74,9 @@ MODULE_ALIAS("snd_cs4232");
74 74
75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
77static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 77static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
78#ifdef CONFIG_PNP 78#ifdef CONFIG_PNP
79static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 79static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
80#endif 80#endif
81static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 81static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
82static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 82static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 9a1a6f2c4484..b036e60f62d1 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -51,9 +51,9 @@ MODULE_ALIAS("snd_es968");
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
53#ifdef CONFIG_PNP 53#ifdef CONFIG_PNP
54static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; 54static bool isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
55#endif 55#endif
56static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 56static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
57static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */ 57static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
58static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* Usually 0x388 */ 58static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* Usually 0x388 */
59static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; 59static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 98e3ac1cfa08..c20baafd9b7c 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1964,9 +1964,9 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1868 PnP AudioDrive},"
1964 1964
1965static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 1965static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
1966static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 1966static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
1967static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 1967static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
1968#ifdef CONFIG_PNP 1968#ifdef CONFIG_PNP
1969static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; 1969static bool isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
1970#endif 1970#endif
1971static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ 1971static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */
1972#ifndef CONFIG_PNP 1972#ifndef CONFIG_PNP
diff --git a/sound/isa/galaxy/galaxy.c b/sound/isa/galaxy/galaxy.c
index e51d3244742a..55e20782858d 100644
--- a/sound/isa/galaxy/galaxy.c
+++ b/sound/isa/galaxy/galaxy.c
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
35 35
36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
38static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; 38static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
39 39
40module_param_array(index, int, NULL, 0444); 40module_param_array(index, int, NULL, 0444);
41MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); 41MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index d7296500bce8..bf6333671613 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -42,7 +42,7 @@ MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}");
42 42
43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
45static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 45static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
46static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x230,0x240,0x250,0x260 */ 46static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x230,0x240,0x250,0x260 */
47static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 3,5,9,11,12,15 */ 47static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 3,5,9,11,12,15 */
48static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */ 48static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index 597accdb15d2..bc10cc26e5f9 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -46,7 +46,7 @@ MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}");
46 46
47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
49static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 49static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
50static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */ 50static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
51static long gf1_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x210,0x220,0x230,0x240,0x250,0x260,0x270 */ 51static long gf1_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x210,0x220,0x230,0x240,0x250,0x260,0x270 */
52static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x300,0x310,0x320 */ 52static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x300,0x310,0x320 */
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index 933cb0f4c549..41c3f448745f 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -40,7 +40,7 @@ MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound MAX}}");
40 40
41static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 41static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
42static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 42static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
43static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 43static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
44static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x230,0x240,0x250,0x260 */ 44static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x230,0x240,0x250,0x260 */
45static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 2,3,5,9,11,12,15 */ 45static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 2,3,5,9,11,12,15 */
46static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */ 46static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 8e7e19484dac..a76bc8d27c1d 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -55,9 +55,9 @@ MODULE_SUPPORTED_DEVICE("{{AMD,InterWave STB with TEA6330T}}");
55 55
56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
58static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 58static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
59#ifdef CONFIG_PNP 59#ifdef CONFIG_PNP
60static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 60static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
61#endif 61#endif
62static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x210,0x220,0x230,0x240,0x250,0x260 */ 62static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x210,0x220,0x230,0x240,0x250,0x260 */
63#ifdef SNDRV_STB 63#ifdef SNDRV_STB
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
index 0961e2cf20ca..29cc8e162b02 100644
--- a/sound/isa/msnd/msnd_pinnacle.c
+++ b/sound/isa/msnd/msnd_pinnacle.c
@@ -785,7 +785,7 @@ static int write_ndelay[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 1 };
785static int calibrate_signal; 785static int calibrate_signal;
786 786
787#ifdef CONFIG_PNP 787#ifdef CONFIG_PNP
788static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 788static bool isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
789module_param_array(isapnp, bool, NULL, 0444); 789module_param_array(isapnp, bool, NULL, 0444);
790MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard."); 790MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
791#define has_isapnp(x) isapnp[x] 791#define has_isapnp(x) isapnp[x]
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index 64a9a2177f4b..f6cc0b917ef0 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -46,9 +46,9 @@ MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF719E-S},"
46 46
47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
49static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 49static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
50#ifdef CONFIG_PNP 50#ifdef CONFIG_PNP
51static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 51static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
52#endif 52#endif
53static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0xf86,0x370,0x100 */ 53static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0xf86,0x370,0x100 */
54static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */ 54static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c
index 3785b7a784c9..c24594c866f4 100644
--- a/sound/isa/opti9xx/miro.c
+++ b/sound/isa/opti9xx/miro.c
@@ -61,7 +61,7 @@ static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */
61static int wss; 61static int wss;
62static int ide; 62static int ide;
63#ifdef CONFIG_PNP 63#ifdef CONFIG_PNP
64static int isapnp = 1; /* Enable ISA PnP detection */ 64static bool isapnp = 1; /* Enable ISA PnP detection */
65#endif 65#endif
66 66
67module_param(index, int, 0444); 67module_param(index, int, 0444);
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 97871bebea90..babaedd242f7 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -63,7 +63,7 @@ MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)},"
63 63
64static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 64static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
65static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 65static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
66//static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ 66//static bool enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
67#ifdef CONFIG_PNP 67#ifdef CONFIG_PNP
68static int isapnp = 1; /* Enable ISA PnP detection */ 68static int isapnp = 1; /* Enable ISA PnP detection */
69#endif 69#endif
diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c
index 54e3c2c18060..410758c68090 100644
--- a/sound/isa/sb/jazz16.c
+++ b/sound/isa/sb/jazz16.c
@@ -36,7 +36,7 @@ MODULE_LICENSE("GPL");
36 36
37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
39static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 39static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
40static unsigned long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 40static unsigned long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
41static unsigned long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 41static unsigned long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
42static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; 42static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 115c7748204f..39b8eca15213 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -68,9 +68,9 @@ MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB AWE 32},"
68 68
69static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 69static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
70static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 70static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
71static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 71static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
72#ifdef CONFIG_PNP 72#ifdef CONFIG_PNP
73static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 73static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
74#endif 74#endif
75static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ 75static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */
76static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x330,0x300 */ 76static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x330,0x300 */
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index 453ef283491d..ab5cebea52e1 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -36,7 +36,7 @@ MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB 1.0/SB 2.0/SB Pro}}");
36 36
37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
39static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 39static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
40static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */ 40static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
41static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */ 41static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
42static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3 */ 42static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3 */
diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c
index 207c161f100c..d97d0f381817 100644
--- a/sound/isa/sc6000.c
+++ b/sound/isa/sc6000.c
@@ -48,7 +48,7 @@ MODULE_SUPPORTED_DEVICE("{{Gallant, SC-6000},"
48 48
49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
51static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 51static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
52static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220, 0x240 */ 52static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220, 0x240 */
53static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5, 7, 9, 10, 11 */ 53static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5, 7, 9, 10, 11 */
54static long mss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x530, 0xe80 */ 54static long mss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x530, 0xe80 */
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 150b96b3ea10..e0a73271cb91 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -38,9 +38,9 @@ MODULE_SUPPORTED_DEVICE("{{Turtle Beach,Maui/Tropez/Tropez+}}");
38 38
39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
41static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 41static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
42#ifdef CONFIG_PNP 42#ifdef CONFIG_PNP
43static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 43static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
44#endif 44#endif
45static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 45static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
46static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ 46static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
@@ -51,7 +51,7 @@ static int ics2115_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 2,9,11,12,15 */
51static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 51static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
52static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ 52static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
53static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ 53static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
54static int use_cs4232_midi[SNDRV_CARDS]; 54static bool use_cs4232_midi[SNDRV_CARDS];
55 55
56module_param_array(index, int, NULL, 0444); 56module_param_array(index, int, NULL, 0444);
57MODULE_PARM_DESC(index, "Index value for WaveFront soundcard."); 57MODULE_PARM_DESC(index, "Index value for WaveFront soundcard.");
diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 2e6c85894e0b..5f88d1f09ffe 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -935,15 +935,4 @@ static struct platform_driver hal2_driver = {
935 } 935 }
936}; 936};
937 937
938static int __init alsa_card_hal2_init(void) 938module_platform_driver(hal2_driver);
939{
940 return platform_driver_register(&hal2_driver);
941}
942
943static void __exit alsa_card_hal2_exit(void)
944{
945 platform_driver_unregister(&hal2_driver);
946}
947
948module_init(alsa_card_hal2_init);
949module_exit(alsa_card_hal2_exit);
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c
index 69425d4c91fd..ceaa593ea4ef 100644
--- a/sound/mips/sgio2audio.c
+++ b/sound/mips/sgio2audio.c
@@ -976,15 +976,4 @@ static struct platform_driver sgio2audio_driver = {
976 } 976 }
977}; 977};
978 978
979static int __init alsa_card_sgio2audio_init(void) 979module_platform_driver(sgio2audio_driver);
980{
981 return platform_driver_register(&sgio2audio_driver);
982}
983
984static void __exit alsa_card_sgio2audio_exit(void)
985{
986 platform_driver_unregister(&sgio2audio_driver);
987}
988
989module_init(alsa_card_sgio2audio_init)
990module_exit(alsa_card_sgio2audio_exit)
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
index 8a197fd3c57e..98d23bdcaf21 100644
--- a/sound/oss/ad1848.c
+++ b/sound/oss/ad1848.c
@@ -119,9 +119,9 @@ ad1848_port_info;
119static struct address_info cfg; 119static struct address_info cfg;
120static int nr_ad1848_devs; 120static int nr_ad1848_devs;
121 121
122static int deskpro_xl; 122static bool deskpro_xl;
123static int deskpro_m; 123static bool deskpro_m;
124static int soundpro; 124static bool soundpro;
125 125
126static volatile signed char irq2dev[17] = { 126static volatile signed char irq2dev[17] = {
127 -1, -1, -1, -1, -1, -1, -1, -1, 127 -1, -1, -1, -1, -1, -1, -1, -1,
@@ -177,7 +177,7 @@ static struct {
177#ifdef CONFIG_PNP 177#ifdef CONFIG_PNP
178static int isapnp = 1; 178static int isapnp = 1;
179static int isapnpjump; 179static int isapnpjump;
180static int reverse; 180static bool reverse;
181 181
182static int audio_activated; 182static int audio_activated;
183#else 183#else
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
index 7b5c77b32a90..eba734560f6f 100644
--- a/sound/oss/msnd_pinnacle.c
+++ b/sound/oss/msnd_pinnacle.c
@@ -1701,7 +1701,7 @@ static int joystick_io __initdata = CONFIG_MSNDPIN_JOYSTICK_IO;
1701#ifndef CONFIG_MSNDPIN_DIGITAL 1701#ifndef CONFIG_MSNDPIN_DIGITAL
1702# define CONFIG_MSNDPIN_DIGITAL 0 1702# define CONFIG_MSNDPIN_DIGITAL 0
1703#endif 1703#endif
1704static int digital __initdata = CONFIG_MSNDPIN_DIGITAL; 1704static bool digital __initdata = CONFIG_MSNDPIN_DIGITAL;
1705 1705
1706#endif /* MSND_CLASSIC */ 1706#endif /* MSND_CLASSIC */
1707 1707
diff --git a/sound/oss/pas2_card.c b/sound/oss/pas2_card.c
index 7f377ec3486d..dabf8a871dcc 100644
--- a/sound/oss/pas2_card.c
+++ b/sound/oss/pas2_card.c
@@ -41,19 +41,19 @@ static int pas_irq;
41static int pas_sb_base; 41static int pas_sb_base;
42DEFINE_SPINLOCK(pas_lock); 42DEFINE_SPINLOCK(pas_lock);
43#ifndef CONFIG_PAS_JOYSTICK 43#ifndef CONFIG_PAS_JOYSTICK
44static int joystick; 44static bool joystick;
45#else 45#else
46static int joystick = 1; 46static bool joystick = 1;
47#endif 47#endif
48#ifdef SYMPHONY_PAS 48#ifdef SYMPHONY_PAS
49static int symphony = 1; 49static bool symphony = 1;
50#else 50#else
51static int symphony; 51static bool symphony;
52#endif 52#endif
53#ifdef BROKEN_BUS_CLOCK 53#ifdef BROKEN_BUS_CLOCK
54static int broken_bus_clock = 1; 54static bool broken_bus_clock = 1;
55#else 55#else
56static int broken_bus_clock; 56static bool broken_bus_clock;
57#endif 57#endif
58 58
59static struct address_info cfg; 59static struct address_info cfg;
diff --git a/sound/oss/pss.c b/sound/oss/pss.c
index 2fc0624024b5..0f32a561f15f 100644
--- a/sound/oss/pss.c
+++ b/sound/oss/pss.c
@@ -117,9 +117,9 @@
117 117
118/* If compiled into kernel, it enable or disable pss mixer */ 118/* If compiled into kernel, it enable or disable pss mixer */
119#ifdef CONFIG_PSS_MIXER 119#ifdef CONFIG_PSS_MIXER
120static int pss_mixer = 1; 120static bool pss_mixer = 1;
121#else 121#else
122static int pss_mixer; 122static bool pss_mixer;
123#endif 123#endif
124 124
125 125
@@ -147,7 +147,7 @@ static DEFINE_SPINLOCK(lock);
147static int pss_initialized; 147static int pss_initialized;
148static int nonstandard_microcode; 148static int nonstandard_microcode;
149static int pss_cdrom_port = -1; /* Parameter for the PSS cdrom port */ 149static int pss_cdrom_port = -1; /* Parameter for the PSS cdrom port */
150static int pss_enable_joystick; /* Parameter for enabling the joystick */ 150static bool pss_enable_joystick; /* Parameter for enabling the joystick */
151static coproc_operations pss_coproc_operations; 151static coproc_operations pss_coproc_operations;
152 152
153static void pss_write(pss_confdata *devc, int data) 153static void pss_write(pss_confdata *devc, int data)
@@ -1133,8 +1133,8 @@ static int mss_irq __initdata = -1;
1133static int mss_dma __initdata = -1; 1133static int mss_dma __initdata = -1;
1134static int mpu_io __initdata = -1; 1134static int mpu_io __initdata = -1;
1135static int mpu_irq __initdata = -1; 1135static int mpu_irq __initdata = -1;
1136static int pss_no_sound = 0; /* Just configure non-sound components */ 1136static bool pss_no_sound = 0; /* Just configure non-sound components */
1137static int pss_keep_settings = 1; /* Keep hardware settings at module exit */ 1137static bool pss_keep_settings = 1; /* Keep hardware settings at module exit */
1138static char *pss_firmware = "/etc/sound/pss_synth"; 1138static char *pss_firmware = "/etc/sound/pss_synth";
1139 1139
1140module_param(pss_io, int, 0); 1140module_param(pss_io, int, 0);
diff --git a/sound/oss/trix.c b/sound/oss/trix.c
index e04169e8e3f8..944e0c015485 100644
--- a/sound/oss/trix.c
+++ b/sound/oss/trix.c
@@ -31,7 +31,7 @@
31 31
32static int mpu; 32static int mpu;
33 33
34static int joystick; 34static bool joystick;
35 35
36static unsigned char trix_read(int addr) 36static unsigned char trix_read(int addr)
37{ 37{
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index fac51eef2725..9473fca9681d 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -42,7 +42,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
42MODULE_DESCRIPTION("Universal interface for Audio Codec '97"); 42MODULE_DESCRIPTION("Universal interface for Audio Codec '97");
43MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
44 44
45static int enable_loopback; 45static bool enable_loopback;
46 46
47module_param(enable_loopback, bool, 0444); 47module_param(enable_loopback, bool, 0444);
48MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control"); 48MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control");
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index 6e311184bb10..9d91d61902b4 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -66,7 +66,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
66module_param_array(id, charp, NULL, 0444); 66module_param_array(id, charp, NULL, 0444);
67MODULE_PARM_DESC(id, "ID string for the AD1889 soundcard."); 67MODULE_PARM_DESC(id, "ID string for the AD1889 soundcard.");
68 68
69static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 69static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
70module_param_array(enable, bool, NULL, 0444); 70module_param_array(enable, bool, NULL, 0444);
71MODULE_PARM_DESC(enable, "Enable AD1889 soundcard."); 71MODULE_PARM_DESC(enable, "Enable AD1889 soundcard.");
72 72
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index ef85ac5d9007..bdd6164e9c7e 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -48,7 +48,7 @@ MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}");
48static int index = SNDRV_DEFAULT_IDX1; /* Index */ 48static int index = SNDRV_DEFAULT_IDX1; /* Index */
49static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 49static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
50static int pcm_channels = 32; 50static int pcm_channels = 32;
51static int spdif; 51static bool spdif;
52 52
53module_param(index, int, 0444); 53module_param(index, int, 0444);
54MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio."); 54MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio.");
@@ -60,7 +60,7 @@ module_param(spdif, bool, 0444);
60MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); 60MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
61 61
62/* just for backward compatibility */ 62/* just for backward compatibility */
63static int enable; 63static bool enable;
64module_param(enable, bool, 0444); 64module_param(enable, bool, 0444);
65 65
66 66
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 8dc77a0a5d8b..8196e229b2df 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -115,7 +115,14 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS300},{Avance Logic,ALS300+}}");
115 115
116static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 116static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
117static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 117static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
118static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 118static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
119
120module_param_array(index, int, NULL, 0444);
121MODULE_PARM_DESC(index, "Index value for ALS300 sound card.");
122module_param_array(id, charp, NULL, 0444);
123MODULE_PARM_DESC(id, "ID string for ALS300 sound card.");
124module_param_array(enable, bool, NULL, 0444);
125MODULE_PARM_DESC(enable, "Enable ALS300 sound card.");
119 126
120struct snd_als300 { 127struct snd_als300 {
121 unsigned long port; 128 unsigned long port;
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 28ef40e01cc2..3269b8011ea9 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -90,7 +90,7 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}");
90 90
91static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 91static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
92static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 92static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
93static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 93static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
94#ifdef SUPPORT_JOYSTICK 94#ifdef SUPPORT_JOYSTICK
95static int joystick_port[SNDRV_CARDS]; 95static int joystick_port[SNDRV_CARDS];
96#endif 96#endif
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index f4b9e2b7ae87..e8de831f98bc 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -23,8 +23,11 @@
23 */ 23 */
24 24
25#include "hpi_internal.h" 25#include "hpi_internal.h"
26#include "hpi_version.h"
26#include "hpimsginit.h" 27#include "hpimsginit.h"
27#include "hpioctl.h" 28#include "hpioctl.h"
29#include "hpicmn.h"
30
28 31
29#include <linux/pci.h> 32#include <linux/pci.h>
30#include <linux/init.h> 33#include <linux/init.h>
@@ -44,7 +47,8 @@
44 47
45MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
46MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); 49MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>");
47MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); 50MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx "
51 HPI_VER_STRING);
48 52
49#if defined CONFIG_SND_DEBUG_VERBOSE 53#if defined CONFIG_SND_DEBUG_VERBOSE
50/** 54/**
@@ -63,8 +67,8 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
63 67
64static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ 68static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
65static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 69static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
66static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 70static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
67static int enable_hpi_hwdep = 1; 71static bool enable_hpi_hwdep = 1;
68 72
69module_param_array(index, int, NULL, S_IRUGO); 73module_param_array(index, int, NULL, S_IRUGO);
70MODULE_PARM_DESC(index, "ALSA index value for AudioScience soundcard."); 74MODULE_PARM_DESC(index, "ALSA index value for AudioScience soundcard.");
@@ -119,12 +123,7 @@ struct clk_cache {
119struct snd_card_asihpi { 123struct snd_card_asihpi {
120 struct snd_card *card; 124 struct snd_card *card;
121 struct pci_dev *pci; 125 struct pci_dev *pci;
122 u16 adapter_index; 126 struct hpi_adapter *hpi;
123 u32 serial_number;
124 u16 type;
125 u16 version;
126 u16 num_outstreams;
127 u16 num_instreams;
128 127
129 u32 h_mixer; 128 u32 h_mixer;
130 struct clk_cache cc; 129 struct clk_cache cc;
@@ -135,6 +134,8 @@ struct snd_card_asihpi {
135 u16 update_interval_frames; 134 u16 update_interval_frames;
136 u16 in_max_chans; 135 u16 in_max_chans;
137 u16 out_max_chans; 136 u16 out_max_chans;
137 u16 in_min_chans;
138 u16 out_min_chans;
138}; 139};
139 140
140/* Per stream data */ 141/* Per stream data */
@@ -495,6 +496,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
495 496
496 snd_printdd("stream_host_buffer_attach status 0x%x\n", 497 snd_printdd("stream_host_buffer_attach status 0x%x\n",
497 dpcm->hpi_buffer_attached); 498 dpcm->hpi_buffer_attached);
499
498 } 500 }
499 bytes_per_sec = params_rate(params) * params_channels(params); 501 bytes_per_sec = params_rate(params) * params_channels(params);
500 width = snd_pcm_format_width(params_format(params)); 502 width = snd_pcm_format_width(params_format(params));
@@ -757,8 +759,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
757 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 759 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
758 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; 760 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail;
759 if (state == HPI_STATE_STOPPED) { 761 if (state == HPI_STATE_STOPPED) {
760 if ((bytes_avail == 0) && 762 if (bytes_avail == 0) {
761 (on_card_bytes < ds->pcm_buf_host_rw_ofs)) {
762 hpi_handle_error(hpi_stream_start(ds->h_stream)); 763 hpi_handle_error(hpi_stream_start(ds->h_stream));
763 snd_printdd("P%d start\n", s->number); 764 snd_printdd("P%d start\n", s->number);
764 ds->drained_count = 0; 765 ds->drained_count = 0;
@@ -767,7 +768,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
767 snd_printd(KERN_WARNING "P%d drained\n", 768 snd_printd(KERN_WARNING "P%d drained\n",
768 s->number); 769 s->number);
769 ds->drained_count++; 770 ds->drained_count++;
770 if (ds->drained_count > 2) { 771 if (ds->drained_count > 20) {
771 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); 772 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
772 continue; 773 continue;
773 } 774 }
@@ -888,8 +889,8 @@ static void snd_card_asihpi_timer_function(unsigned long data)
888 pd, xfer2)); 889 pd, xfer2));
889 } 890 }
890 } 891 }
891 ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount; 892 ds->pcm_buf_host_rw_ofs += xfercount;
892 ds->pcm_buf_elapsed_dma_ofs = pcm_buf_dma_ofs; 893 ds->pcm_buf_elapsed_dma_ofs += xfercount;
893 snd_pcm_period_elapsed(s); 894 snd_pcm_period_elapsed(s);
894 } 895 }
895 } 896 }
@@ -902,7 +903,9 @@ static void snd_card_asihpi_timer_function(unsigned long data)
902static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, 903static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream,
903 unsigned int cmd, void *arg) 904 unsigned int cmd, void *arg)
904{ 905{
905 snd_printddd(KERN_INFO "P%d ioctl %d\n", substream->number, cmd); 906 char name[16];
907 snd_pcm_debug_name(substream, name, sizeof(name));
908 snd_printddd(KERN_INFO "%s ioctl %d\n", name, cmd);
906 return snd_pcm_lib_ioctl(substream, cmd, arg); 909 return snd_pcm_lib_ioctl(substream, cmd, arg);
907} 910}
908 911
@@ -927,21 +930,23 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream)
927 struct snd_pcm_runtime *runtime = substream->runtime; 930 struct snd_pcm_runtime *runtime = substream->runtime;
928 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 931 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
929 snd_pcm_uframes_t ptr; 932 snd_pcm_uframes_t ptr;
933 char name[16];
934 snd_pcm_debug_name(substream, name, sizeof(name));
930 935
931 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); 936 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
932 snd_printddd("P%d pointer = 0x%04lx\n", substream->number, (unsigned long)ptr); 937 snd_printddd("%s pointer = 0x%04lx\n", name, (unsigned long)ptr);
933 return ptr; 938 return ptr;
934} 939}
935 940
936static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, 941static u64 snd_card_asihpi_playback_formats(struct snd_card_asihpi *asihpi,
937 u32 h_stream, 942 u32 h_stream)
938 struct snd_pcm_hardware *pcmhw)
939{ 943{
940 struct hpi_format hpi_format; 944 struct hpi_format hpi_format;
941 u16 format; 945 u16 format;
942 u16 err; 946 u16 err;
943 u32 h_control; 947 u32 h_control;
944 u32 sample_rate = 48000; 948 u32 sample_rate = 48000;
949 u64 formats = 0;
945 950
946 /* on cards without SRC, must query at valid rate, 951 /* on cards without SRC, must query at valid rate,
947 * maybe set by external sync 952 * maybe set by external sync
@@ -956,41 +961,29 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi,
956 961
957 for (format = HPI_FORMAT_PCM8_UNSIGNED; 962 for (format = HPI_FORMAT_PCM8_UNSIGNED;
958 format <= HPI_FORMAT_PCM24_SIGNED; format++) { 963 format <= HPI_FORMAT_PCM24_SIGNED; format++) {
959 err = hpi_format_create(&hpi_format, 964 err = hpi_format_create(&hpi_format, asihpi->out_max_chans,
960 2, format, sample_rate, 128000, 0); 965 format, sample_rate, 128000, 0);
961 if (!err) 966 if (!err)
962 err = hpi_outstream_query_format(h_stream, 967 err = hpi_outstream_query_format(h_stream, &hpi_format);
963 &hpi_format);
964 if (!err && (hpi_to_alsa_formats[format] != -1)) 968 if (!err && (hpi_to_alsa_formats[format] != -1))
965 pcmhw->formats |= 969 formats |= (1ULL << hpi_to_alsa_formats[format]);
966 (1ULL << hpi_to_alsa_formats[format]);
967 } 970 }
971 return formats;
968} 972}
969 973
970static struct snd_pcm_hardware snd_card_asihpi_playback = {
971 .channels_min = 1,
972 .channels_max = 2,
973 .buffer_bytes_max = BUFFER_BYTES_MAX,
974 .period_bytes_min = PERIOD_BYTES_MIN,
975 .period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN,
976 .periods_min = PERIODS_MIN,
977 .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN,
978 .fifo_size = 0,
979};
980
981static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) 974static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
982{ 975{
983 struct snd_pcm_runtime *runtime = substream->runtime; 976 struct snd_pcm_runtime *runtime = substream->runtime;
984 struct snd_card_asihpi_pcm *dpcm; 977 struct snd_card_asihpi_pcm *dpcm;
985 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 978 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
979 struct snd_pcm_hardware snd_card_asihpi_playback;
986 int err; 980 int err;
987 981
988 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); 982 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
989 if (dpcm == NULL) 983 if (dpcm == NULL)
990 return -ENOMEM; 984 return -ENOMEM;
991 985
992 err = 986 err = hpi_outstream_open(card->hpi->adapter->index,
993 hpi_outstream_open(card->adapter_index,
994 substream->number, &dpcm->h_stream); 987 substream->number, &dpcm->h_stream);
995 hpi_handle_error(err); 988 hpi_handle_error(err);
996 if (err) 989 if (err)
@@ -1012,12 +1005,19 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1012 runtime->private_data = dpcm; 1005 runtime->private_data = dpcm;
1013 runtime->private_free = snd_card_asihpi_runtime_free; 1006 runtime->private_free = snd_card_asihpi_runtime_free;
1014 1007
1015 snd_card_asihpi_playback.channels_max = card->out_max_chans; 1008 memset(&snd_card_asihpi_playback, 0, sizeof(snd_card_asihpi_playback));
1009 snd_card_asihpi_playback.buffer_bytes_max = BUFFER_BYTES_MAX;
1010 snd_card_asihpi_playback.period_bytes_min = PERIOD_BYTES_MIN;
1016 /*?snd_card_asihpi_playback.period_bytes_min = 1011 /*?snd_card_asihpi_playback.period_bytes_min =
1017 card->out_max_chans * 4096; */ 1012 card->out_max_chans * 4096; */
1018 1013 snd_card_asihpi_playback.period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN;
1019 snd_card_asihpi_playback_format(card, dpcm->h_stream, 1014 snd_card_asihpi_playback.periods_min = PERIODS_MIN;
1020 &snd_card_asihpi_playback); 1015 snd_card_asihpi_playback.periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN;
1016 /* snd_card_asihpi_playback.fifo_size = 0; */
1017 snd_card_asihpi_playback.channels_max = card->out_max_chans;
1018 snd_card_asihpi_playback.channels_min = card->out_min_chans;
1019 snd_card_asihpi_playback.formats =
1020 snd_card_asihpi_playback_formats(card, dpcm->h_stream);
1021 1021
1022 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_playback); 1022 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_playback);
1023 1023
@@ -1029,8 +1029,10 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1029 SNDRV_PCM_INFO_MMAP | 1029 SNDRV_PCM_INFO_MMAP |
1030 SNDRV_PCM_INFO_MMAP_VALID; 1030 SNDRV_PCM_INFO_MMAP_VALID;
1031 1031
1032 if (card->support_grouping) 1032 if (card->support_grouping) {
1033 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_SYNC_START; 1033 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_SYNC_START;
1034 snd_pcm_set_sync(substream);
1035 }
1034 1036
1035 /* struct is copied, so can create initializer dynamically */ 1037 /* struct is copied, so can create initializer dynamically */
1036 runtime->hw = snd_card_asihpi_playback; 1038 runtime->hw = snd_card_asihpi_playback;
@@ -1047,8 +1049,6 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1047 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1049 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1048 card->update_interval_frames * 2, UINT_MAX); 1050 card->update_interval_frames * 2, UINT_MAX);
1049 1051
1050 snd_pcm_set_sync(substream);
1051
1052 snd_printdd("playback open\n"); 1052 snd_printdd("playback open\n");
1053 1053
1054 return 0; 1054 return 0;
@@ -1114,15 +1114,15 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream)
1114 1114
1115 1115
1116 1116
1117static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, 1117static u64 snd_card_asihpi_capture_formats(struct snd_card_asihpi *asihpi,
1118 u32 h_stream, 1118 u32 h_stream)
1119 struct snd_pcm_hardware *pcmhw)
1120{ 1119{
1121 struct hpi_format hpi_format; 1120 struct hpi_format hpi_format;
1122 u16 format; 1121 u16 format;
1123 u16 err; 1122 u16 err;
1124 u32 h_control; 1123 u32 h_control;
1125 u32 sample_rate = 48000; 1124 u32 sample_rate = 48000;
1125 u64 formats = 0;
1126 1126
1127 /* on cards without SRC, must query at valid rate, 1127 /* on cards without SRC, must query at valid rate,
1128 maybe set by external sync */ 1128 maybe set by external sync */
@@ -1137,34 +1137,22 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi,
1137 for (format = HPI_FORMAT_PCM8_UNSIGNED; 1137 for (format = HPI_FORMAT_PCM8_UNSIGNED;
1138 format <= HPI_FORMAT_PCM24_SIGNED; format++) { 1138 format <= HPI_FORMAT_PCM24_SIGNED; format++) {
1139 1139
1140 err = hpi_format_create(&hpi_format, 2, format, 1140 err = hpi_format_create(&hpi_format, asihpi->in_max_chans,
1141 sample_rate, 128000, 0); 1141 format, sample_rate, 128000, 0);
1142 if (!err) 1142 if (!err)
1143 err = hpi_instream_query_format(h_stream, 1143 err = hpi_instream_query_format(h_stream, &hpi_format);
1144 &hpi_format);
1145 if (!err) 1144 if (!err)
1146 pcmhw->formats |= 1145 formats |= (1ULL << hpi_to_alsa_formats[format]);
1147 (1ULL << hpi_to_alsa_formats[format]);
1148 } 1146 }
1147 return formats;
1149} 1148}
1150 1149
1151
1152static struct snd_pcm_hardware snd_card_asihpi_capture = {
1153 .channels_min = 1,
1154 .channels_max = 2,
1155 .buffer_bytes_max = BUFFER_BYTES_MAX,
1156 .period_bytes_min = PERIOD_BYTES_MIN,
1157 .period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN,
1158 .periods_min = PERIODS_MIN,
1159 .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN,
1160 .fifo_size = 0,
1161};
1162
1163static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) 1150static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1164{ 1151{
1165 struct snd_pcm_runtime *runtime = substream->runtime; 1152 struct snd_pcm_runtime *runtime = substream->runtime;
1166 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 1153 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
1167 struct snd_card_asihpi_pcm *dpcm; 1154 struct snd_card_asihpi_pcm *dpcm;
1155 struct snd_pcm_hardware snd_card_asihpi_capture;
1168 int err; 1156 int err;
1169 1157
1170 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); 1158 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
@@ -1172,10 +1160,10 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1172 return -ENOMEM; 1160 return -ENOMEM;
1173 1161
1174 snd_printdd("capture open adapter %d stream %d\n", 1162 snd_printdd("capture open adapter %d stream %d\n",
1175 card->adapter_index, substream->number); 1163 card->hpi->adapter->index, substream->number);
1176 1164
1177 err = hpi_handle_error( 1165 err = hpi_handle_error(
1178 hpi_instream_open(card->adapter_index, 1166 hpi_instream_open(card->hpi->adapter->index,
1179 substream->number, &dpcm->h_stream)); 1167 substream->number, &dpcm->h_stream));
1180 if (err) 1168 if (err)
1181 kfree(dpcm); 1169 kfree(dpcm);
@@ -1184,7 +1172,6 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1184 if (err) 1172 if (err)
1185 return -EIO; 1173 return -EIO;
1186 1174
1187
1188 init_timer(&dpcm->timer); 1175 init_timer(&dpcm->timer);
1189 dpcm->timer.data = (unsigned long) dpcm; 1176 dpcm->timer.data = (unsigned long) dpcm;
1190 dpcm->timer.function = snd_card_asihpi_timer_function; 1177 dpcm->timer.function = snd_card_asihpi_timer_function;
@@ -1192,9 +1179,17 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1192 runtime->private_data = dpcm; 1179 runtime->private_data = dpcm;
1193 runtime->private_free = snd_card_asihpi_runtime_free; 1180 runtime->private_free = snd_card_asihpi_runtime_free;
1194 1181
1182 memset(&snd_card_asihpi_capture, 0, sizeof(snd_card_asihpi_capture));
1183 snd_card_asihpi_capture.buffer_bytes_max = BUFFER_BYTES_MAX;
1184 snd_card_asihpi_capture.period_bytes_min = PERIOD_BYTES_MIN;
1185 snd_card_asihpi_capture.period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN;
1186 snd_card_asihpi_capture.periods_min = PERIODS_MIN;
1187 snd_card_asihpi_capture.periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN;
1188 /* snd_card_asihpi_capture.fifo_size = 0; */
1195 snd_card_asihpi_capture.channels_max = card->in_max_chans; 1189 snd_card_asihpi_capture.channels_max = card->in_max_chans;
1196 snd_card_asihpi_capture_format(card, dpcm->h_stream, 1190 snd_card_asihpi_capture.channels_min = card->in_min_chans;
1197 &snd_card_asihpi_capture); 1191 snd_card_asihpi_capture.formats =
1192 snd_card_asihpi_capture_formats(card, dpcm->h_stream);
1198 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture); 1193 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture);
1199 snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED | 1194 snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED |
1200 SNDRV_PCM_INFO_MMAP | 1195 SNDRV_PCM_INFO_MMAP |
@@ -1240,15 +1235,20 @@ static struct snd_pcm_ops snd_card_asihpi_capture_mmap_ops = {
1240 .pointer = snd_card_asihpi_capture_pointer, 1235 .pointer = snd_card_asihpi_capture_pointer,
1241}; 1236};
1242 1237
1243static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, 1238static int __devinit snd_card_asihpi_pcm_new(
1244 int device, int substreams) 1239 struct snd_card_asihpi *asihpi, int device)
1245{ 1240{
1246 struct snd_pcm *pcm; 1241 struct snd_pcm *pcm;
1247 int err; 1242 int err;
1243 u16 num_instreams, num_outstreams, x16;
1244 u32 x32;
1245
1246 err = hpi_adapter_get_info(asihpi->hpi->adapter->index,
1247 &num_outstreams, &num_instreams,
1248 &x16, &x32, &x16);
1248 1249
1249 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, 1250 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device,
1250 asihpi->num_outstreams, asihpi->num_instreams, 1251 num_outstreams, num_instreams, &pcm);
1251 &pcm);
1252 if (err < 0) 1252 if (err < 0)
1253 return err; 1253 return err;
1254 /* pointer to ops struct is stored, dont change ops afterwards! */ 1254 /* pointer to ops struct is stored, dont change ops afterwards! */
@@ -1314,7 +1314,7 @@ static const char * const asihpi_src_names[] = {
1314 "Analog", 1314 "Analog",
1315 "Adapter", 1315 "Adapter",
1316 "RTP", 1316 "RTP",
1317 "GPI", 1317 "Internal"
1318}; 1318};
1319 1319
1320compile_time_assert( 1320compile_time_assert(
@@ -1332,7 +1332,6 @@ static const char * const asihpi_dst_names[] = {
1332 "Net", 1332 "Net",
1333 "Analog", 1333 "Analog",
1334 "RTP", 1334 "RTP",
1335 "GPO",
1336}; 1335};
1337 1336
1338compile_time_assert( 1337compile_time_assert(
@@ -1410,6 +1409,7 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol,
1410 struct snd_ctl_elem_info *uinfo) 1409 struct snd_ctl_elem_info *uinfo)
1411{ 1410{
1412 u32 h_control = kcontrol->private_value; 1411 u32 h_control = kcontrol->private_value;
1412 u32 count;
1413 u16 err; 1413 u16 err;
1414 /* native gains are in millibels */ 1414 /* native gains are in millibels */
1415 short min_gain_mB; 1415 short min_gain_mB;
@@ -1424,8 +1424,12 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol,
1424 step_gain_mB = VOL_STEP_mB; 1424 step_gain_mB = VOL_STEP_mB;
1425 } 1425 }
1426 1426
1427 err = hpi_meter_query_channels(h_control, &count);
1428 if (err)
1429 count = HPI_MAX_CHANNELS;
1430
1427 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1431 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1428 uinfo->count = 2; 1432 uinfo->count = count;
1429 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB; 1433 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB;
1430 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB; 1434 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB;
1431 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB; 1435 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB;
@@ -2033,8 +2037,15 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi,
2033static int snd_asihpi_meter_info(struct snd_kcontrol *kcontrol, 2037static int snd_asihpi_meter_info(struct snd_kcontrol *kcontrol,
2034 struct snd_ctl_elem_info *uinfo) 2038 struct snd_ctl_elem_info *uinfo)
2035{ 2039{
2040 u32 h_control = kcontrol->private_value;
2041 u32 count;
2042 u16 err;
2043 err = hpi_meter_query_channels(h_control, &count);
2044 if (err)
2045 count = HPI_MAX_CHANNELS;
2046
2036 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 2047 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2037 uinfo->count = HPI_MAX_CHANNELS; 2048 uinfo->count = count;
2038 uinfo->value.integer.min = 0; 2049 uinfo->value.integer.min = 0;
2039 uinfo->value.integer.max = 0x7FFFFFFF; 2050 uinfo->value.integer.max = 0x7FFFFFFF;
2040 return 0; 2051 return 0;
@@ -2248,6 +2259,9 @@ static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol,
2248 valid_modes++; 2259 valid_modes++;
2249 } 2260 }
2250 2261
2262 if (!valid_modes)
2263 return -EINVAL;
2264
2251 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2265 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2252 uinfo->count = 1; 2266 uinfo->count = 1;
2253 uinfo->value.enumerated.items = valid_modes; 2267 uinfo->value.enumerated.items = valid_modes;
@@ -2547,7 +2561,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2547 strcpy(card->mixername, "Asihpi Mixer"); 2561 strcpy(card->mixername, "Asihpi Mixer");
2548 2562
2549 err = 2563 err =
2550 hpi_mixer_open(asihpi->adapter_index, 2564 hpi_mixer_open(asihpi->hpi->adapter->index,
2551 &asihpi->h_mixer); 2565 &asihpi->h_mixer);
2552 hpi_handle_error(err); 2566 hpi_handle_error(err);
2553 if (err) 2567 if (err)
@@ -2665,24 +2679,33 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,
2665 struct snd_info_buffer *buffer) 2679 struct snd_info_buffer *buffer)
2666{ 2680{
2667 struct snd_card_asihpi *asihpi = entry->private_data; 2681 struct snd_card_asihpi *asihpi = entry->private_data;
2668 u16 version;
2669 u32 h_control; 2682 u32 h_control;
2670 u32 rate = 0; 2683 u32 rate = 0;
2671 u16 source = 0; 2684 u16 source = 0;
2685
2686 u16 num_outstreams;
2687 u16 num_instreams;
2688 u16 version;
2689 u32 serial_number;
2690 u16 type;
2691
2672 int err; 2692 int err;
2673 2693
2674 snd_iprintf(buffer, "ASIHPI driver proc file\n"); 2694 snd_iprintf(buffer, "ASIHPI driver proc file\n");
2695
2696 hpi_handle_error(hpi_adapter_get_info(asihpi->hpi->adapter->index,
2697 &num_outstreams, &num_instreams,
2698 &version, &serial_number, &type));
2699
2675 snd_iprintf(buffer, 2700 snd_iprintf(buffer,
2676 "adapter ID=%4X\n_index=%d\n" 2701 "Adapter type ASI%4X\nHardware Index %d\n"
2677 "num_outstreams=%d\n_num_instreams=%d\n", 2702 "%d outstreams\n%d instreams\n",
2678 asihpi->type, asihpi->adapter_index, 2703 type, asihpi->hpi->adapter->index,
2679 asihpi->num_outstreams, asihpi->num_instreams); 2704 num_outstreams, num_instreams);
2680 2705
2681 version = asihpi->version;
2682 snd_iprintf(buffer, 2706 snd_iprintf(buffer,
2683 "serial#=%d\n_hw version %c%d\nDSP code version %03d\n", 2707 "Serial#%d\nHardware version %c%d\nDSP code version %03d\n",
2684 asihpi->serial_number, ((version >> 3) & 0xf) + 'A', 2708 serial_number, ((version >> 3) & 0xf) + 'A', version & 0x7,
2685 version & 0x7,
2686 ((version >> 13) * 100) + ((version >> 7) & 0x3f)); 2709 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
2687 2710
2688 err = hpi_mixer_get_control(asihpi->h_mixer, 2711 err = hpi_mixer_get_control(asihpi->h_mixer,
@@ -2690,18 +2713,15 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,
2690 HPI_CONTROL_SAMPLECLOCK, &h_control); 2713 HPI_CONTROL_SAMPLECLOCK, &h_control);
2691 2714
2692 if (!err) { 2715 if (!err) {
2693 err = hpi_sample_clock_get_sample_rate( 2716 err = hpi_sample_clock_get_sample_rate(h_control, &rate);
2694 h_control, &rate);
2695 err += hpi_sample_clock_get_source(h_control, &source); 2717 err += hpi_sample_clock_get_source(h_control, &source);
2696 2718
2697 if (!err) 2719 if (!err)
2698 snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", 2720 snd_iprintf(buffer, "Sample Clock %dHz, source %s\n",
2699 rate, sampleclock_sources[source]); 2721 rate, sampleclock_sources[source]);
2700 } 2722 }
2701
2702} 2723}
2703 2724
2704
2705static void __devinit snd_asihpi_proc_init(struct snd_card_asihpi *asihpi) 2725static void __devinit snd_asihpi_proc_init(struct snd_card_asihpi *asihpi)
2706{ 2726{
2707 struct snd_info_entry *entry; 2727 struct snd_info_entry *entry;
@@ -2773,35 +2793,34 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2773 const struct pci_device_id *pci_id) 2793 const struct pci_device_id *pci_id)
2774{ 2794{
2775 int err; 2795 int err;
2776 2796 struct hpi_adapter *hpi;
2777 u16 version;
2778 int pcm_substreams;
2779
2780 struct hpi_adapter *hpi_card;
2781 struct snd_card *card; 2797 struct snd_card *card;
2782 struct snd_card_asihpi *asihpi; 2798 struct snd_card_asihpi *asihpi;
2783 2799
2784 u32 h_control; 2800 u32 h_control;
2785 u32 h_stream; 2801 u32 h_stream;
2802 u32 adapter_index;
2786 2803
2787 static int dev; 2804 static int dev;
2788 if (dev >= SNDRV_CARDS) 2805 if (dev >= SNDRV_CARDS)
2789 return -ENODEV; 2806 return -ENODEV;
2790 2807
2791 /* Should this be enable[hpi_card->index] ? */ 2808 /* Should this be enable[hpi->index] ? */
2792 if (!enable[dev]) { 2809 if (!enable[dev]) {
2793 dev++; 2810 dev++;
2794 return -ENOENT; 2811 return -ENOENT;
2795 } 2812 }
2796 2813
2814 /* Initialise low-level HPI driver */
2797 err = asihpi_adapter_probe(pci_dev, pci_id); 2815 err = asihpi_adapter_probe(pci_dev, pci_id);
2798 if (err < 0) 2816 if (err < 0)
2799 return err; 2817 return err;
2800 2818
2801 hpi_card = pci_get_drvdata(pci_dev); 2819 hpi = pci_get_drvdata(pci_dev);
2820 adapter_index = hpi->adapter->index;
2802 /* first try to give the card the same index as its hardware index */ 2821 /* first try to give the card the same index as its hardware index */
2803 err = snd_card_create(hpi_card->index, 2822 err = snd_card_create(adapter_index,
2804 id[hpi_card->index], THIS_MODULE, 2823 id[adapter_index], THIS_MODULE,
2805 sizeof(struct snd_card_asihpi), 2824 sizeof(struct snd_card_asihpi),
2806 &card); 2825 &card);
2807 if (err < 0) { 2826 if (err < 0) {
@@ -2815,50 +2834,32 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2815 return err; 2834 return err;
2816 snd_printk(KERN_WARNING 2835 snd_printk(KERN_WARNING
2817 "**** WARNING **** Adapter index %d->ALSA index %d\n", 2836 "**** WARNING **** Adapter index %d->ALSA index %d\n",
2818 hpi_card->index, card->number); 2837 adapter_index, card->number);
2819 } 2838 }
2820 2839
2821 snd_card_set_dev(card, &pci_dev->dev); 2840 snd_card_set_dev(card, &pci_dev->dev);
2822 2841
2823 asihpi = (struct snd_card_asihpi *) card->private_data; 2842 asihpi = card->private_data;
2824 asihpi->card = card; 2843 asihpi->card = card;
2825 asihpi->pci = pci_dev; 2844 asihpi->pci = pci_dev;
2826 asihpi->adapter_index = hpi_card->index; 2845 asihpi->hpi = hpi;
2827 hpi_handle_error(hpi_adapter_get_info( 2846
2828 asihpi->adapter_index, 2847 snd_printk(KERN_INFO "adapter ID=%4X index=%d\n",
2829 &asihpi->num_outstreams, 2848 asihpi->hpi->adapter->type, adapter_index);
2830 &asihpi->num_instreams, 2849
2831 &asihpi->version, 2850 err = hpi_adapter_get_property(adapter_index,
2832 &asihpi->serial_number, &asihpi->type));
2833
2834 version = asihpi->version;
2835 snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d "
2836 "num_instreams=%d S/N=%d\n"
2837 "Hw Version %c%d DSP code version %03d\n",
2838 asihpi->type, asihpi->adapter_index,
2839 asihpi->num_outstreams,
2840 asihpi->num_instreams, asihpi->serial_number,
2841 ((version >> 3) & 0xf) + 'A',
2842 version & 0x7,
2843 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
2844
2845 pcm_substreams = asihpi->num_outstreams;
2846 if (pcm_substreams < asihpi->num_instreams)
2847 pcm_substreams = asihpi->num_instreams;
2848
2849 err = hpi_adapter_get_property(asihpi->adapter_index,
2850 HPI_ADAPTER_PROPERTY_CAPS1, 2851 HPI_ADAPTER_PROPERTY_CAPS1,
2851 NULL, &asihpi->support_grouping); 2852 NULL, &asihpi->support_grouping);
2852 if (err) 2853 if (err)
2853 asihpi->support_grouping = 0; 2854 asihpi->support_grouping = 0;
2854 2855
2855 err = hpi_adapter_get_property(asihpi->adapter_index, 2856 err = hpi_adapter_get_property(adapter_index,
2856 HPI_ADAPTER_PROPERTY_CAPS2, 2857 HPI_ADAPTER_PROPERTY_CAPS2,
2857 &asihpi->support_mrx, NULL); 2858 &asihpi->support_mrx, NULL);
2858 if (err) 2859 if (err)
2859 asihpi->support_mrx = 0; 2860 asihpi->support_mrx = 0;
2860 2861
2861 err = hpi_adapter_get_property(asihpi->adapter_index, 2862 err = hpi_adapter_get_property(adapter_index,
2862 HPI_ADAPTER_PROPERTY_INTERVAL, 2863 HPI_ADAPTER_PROPERTY_INTERVAL,
2863 NULL, &asihpi->update_interval_frames); 2864 NULL, &asihpi->update_interval_frames);
2864 if (err) 2865 if (err)
@@ -2867,7 +2868,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2867 if (!asihpi->can_dma) 2868 if (!asihpi->can_dma)
2868 asihpi->update_interval_frames *= 2; 2869 asihpi->update_interval_frames *= 2;
2869 2870
2870 hpi_handle_error(hpi_instream_open(asihpi->adapter_index, 2871 hpi_handle_error(hpi_instream_open(adapter_index,
2871 0, &h_stream)); 2872 0, &h_stream));
2872 2873
2873 err = hpi_instream_host_buffer_free(h_stream); 2874 err = hpi_instream_host_buffer_free(h_stream);
@@ -2875,7 +2876,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2875 2876
2876 hpi_handle_error(hpi_instream_close(h_stream)); 2877 hpi_handle_error(hpi_instream_close(h_stream));
2877 2878
2878 err = hpi_adapter_get_property(asihpi->adapter_index, 2879 err = hpi_adapter_get_property(adapter_index,
2879 HPI_ADAPTER_PROPERTY_CURCHANNELS, 2880 HPI_ADAPTER_PROPERTY_CURCHANNELS,
2880 &asihpi->in_max_chans, &asihpi->out_max_chans); 2881 &asihpi->in_max_chans, &asihpi->out_max_chans);
2881 if (err) { 2882 if (err) {
@@ -2883,13 +2884,22 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2883 asihpi->out_max_chans = 2; 2884 asihpi->out_max_chans = 2;
2884 } 2885 }
2885 2886
2886 snd_printk(KERN_INFO "has dma:%d, grouping:%d, mrx:%d\n", 2887 if (asihpi->out_max_chans > 2) { /* assume LL mode */
2888 asihpi->out_min_chans = asihpi->out_max_chans;
2889 asihpi->in_min_chans = asihpi->in_max_chans;
2890 asihpi->support_grouping = 0;
2891 } else {
2892 asihpi->out_min_chans = 1;
2893 asihpi->in_min_chans = 1;
2894 }
2895
2896 snd_printk(KERN_INFO "Has dma:%d, grouping:%d, mrx:%d\n",
2887 asihpi->can_dma, 2897 asihpi->can_dma,
2888 asihpi->support_grouping, 2898 asihpi->support_grouping,
2889 asihpi->support_mrx 2899 asihpi->support_mrx
2890 ); 2900 );
2891 2901
2892 err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); 2902 err = snd_card_asihpi_pcm_new(asihpi, 0);
2893 if (err < 0) { 2903 if (err < 0) {
2894 snd_printk(KERN_ERR "pcm_new failed\n"); 2904 snd_printk(KERN_ERR "pcm_new failed\n");
2895 goto __nodev; 2905 goto __nodev;
@@ -2916,13 +2926,14 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2916 2926
2917 strcpy(card->driver, "ASIHPI"); 2927 strcpy(card->driver, "ASIHPI");
2918 2928
2919 sprintf(card->shortname, "AudioScience ASI%4X", asihpi->type); 2929 sprintf(card->shortname, "AudioScience ASI%4X",
2930 asihpi->hpi->adapter->type);
2920 sprintf(card->longname, "%s %i", 2931 sprintf(card->longname, "%s %i",
2921 card->shortname, asihpi->adapter_index); 2932 card->shortname, adapter_index);
2922 err = snd_card_register(card); 2933 err = snd_card_register(card);
2923 2934
2924 if (!err) { 2935 if (!err) {
2925 hpi_card->snd_card_asihpi = card; 2936 hpi->snd_card = card;
2926 dev++; 2937 dev++;
2927 return 0; 2938 return 0;
2928 } 2939 }
@@ -2935,10 +2946,9 @@ __nodev:
2935 2946
2936static void __devexit snd_asihpi_remove(struct pci_dev *pci_dev) 2947static void __devexit snd_asihpi_remove(struct pci_dev *pci_dev)
2937{ 2948{
2938 struct hpi_adapter *hpi_card = pci_get_drvdata(pci_dev); 2949 struct hpi_adapter *hpi = pci_get_drvdata(pci_dev);
2939 2950 snd_card_free(hpi->snd_card);
2940 snd_card_free(hpi_card->snd_card_asihpi); 2951 hpi->snd_card = NULL;
2941 hpi_card->snd_card_asihpi = NULL;
2942 asihpi_adapter_remove(pci_dev); 2952 asihpi_adapter_remove(pci_dev);
2943} 2953}
2944 2954
diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h
index f20727288994..20887241a3ae 100644
--- a/sound/pci/asihpi/hpi.h
+++ b/sound/pci/asihpi/hpi.h
@@ -30,26 +30,8 @@
30 30
31#ifndef _HPI_H_ 31#ifndef _HPI_H_
32#define _HPI_H_ 32#define _HPI_H_
33/* HPI Version
34If HPI_VER_MINOR is odd then its a development release not intended for the
35public. If HPI_VER_MINOR is even then is a release version
36i.e 3.05.02 is a development version
37*/
38#define HPI_VERSION_CONSTRUCTOR(maj, min, rel) \
39 ((maj << 16) + (min << 8) + rel)
40
41#define HPI_VER_MAJOR(v) ((int)(v >> 16))
42#define HPI_VER_MINOR(v) ((int)((v >> 8) & 0xFF))
43#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
44
45#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 8, 0)
46#define HPI_VER_STRING "4.08.00"
47
48/* Library version as documented in hpi-api-versions.txt */
49#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(10, 0, 0)
50 33
51#include <linux/types.h> 34#include <linux/types.h>
52#define HPI_BUILD_EXCLUDE_DEPRECATED
53#define HPI_BUILD_KERNEL_MODE 35#define HPI_BUILD_KERNEL_MODE
54 36
55/******************************************************************************/ 37/******************************************************************************/
@@ -213,7 +195,7 @@ enum HPI_SOURCENODES {
213 /** RTP stream input node - This node is a destination for 195 /** RTP stream input node - This node is a destination for
214 packets of RTP audio samples from other devices. */ 196 packets of RTP audio samples from other devices. */
215 HPI_SOURCENODE_RTP_DESTINATION = 112, 197 HPI_SOURCENODE_RTP_DESTINATION = 112,
216 HPI_SOURCENODE_GP_IN = 113, /**< general purpose input. */ 198 HPI_SOURCENODE_INTERNAL = 113, /**< node internal to the device. */
217 /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */ 199 /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */
218 HPI_SOURCENODE_LAST_INDEX = 113 /**< largest ID */ 200 HPI_SOURCENODE_LAST_INDEX = 113 /**< largest ID */
219 /* AX6 max sourcenode types = 15 */ 201 /* AX6 max sourcenode types = 15 */
@@ -242,9 +224,8 @@ enum HPI_DESTNODES {
242 /** RTP stream output node - This node is a source for 224 /** RTP stream output node - This node is a source for
243 packets of RTP audio samples that are sent to other devices. */ 225 packets of RTP audio samples that are sent to other devices. */
244 HPI_DESTNODE_RTP_SOURCE = 208, 226 HPI_DESTNODE_RTP_SOURCE = 208,
245 HPI_DESTNODE_GP_OUT = 209, /**< general purpose output node. */
246 /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */ 227 /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */
247 HPI_DESTNODE_LAST_INDEX = 209 /**< largest ID */ 228 HPI_DESTNODE_LAST_INDEX = 208 /**< largest ID */
248 /* AX6 max destnode types = 15 */ 229 /* AX6 max destnode types = 15 */
249}; 230};
250 231
@@ -450,7 +431,19 @@ Indicates that the adapter in it's current mode supports interrupts
450across the host bus. Note, this does not imply that interrupts are 431across the host bus. Note, this does not imply that interrupts are
451enabled. Instead it indicates that they can be enabled. 432enabled. Instead it indicates that they can be enabled.
452*/ 433*/
453 HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272 434 HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272,
435/** Readonly supports firmware updating.
436Indicates that the adapter implements an interface to update firmware
437on the adapter.
438*/
439 HPI_ADAPTER_PROPERTY_SUPPORTS_FW_UPDATE = 273,
440/** Readonly Firmware IDs
441Identifiy firmware independent of individual adapter type.
442May be used as a filter for firmware update images.
443Property 1 = Bootloader ID
444Property 2 = Main program ID
445*/
446 HPI_ADAPTER_PROPERTY_FIRMWARE_ID = 274
454}; 447};
455 448
456/** Adapter mode commands 449/** Adapter mode commands
@@ -638,7 +631,7 @@ enum HPI_MIXER_STORE_COMMAND {
638 HPI_MIXER_STORE_ENABLE = 4, 631 HPI_MIXER_STORE_ENABLE = 4,
639/** Disable auto storage of some control settings. */ 632/** Disable auto storage of some control settings. */
640 HPI_MIXER_STORE_DISABLE = 5, 633 HPI_MIXER_STORE_DISABLE = 5,
641/** Save the attributes of a single control. */ 634/** Unimplemented - save the attributes of a single control. */
642 HPI_MIXER_STORE_SAVE_SINGLE = 6 635 HPI_MIXER_STORE_SAVE_SINGLE = 6
643}; 636};
644 637
@@ -941,7 +934,7 @@ enum HPI_ERROR_CODES {
941 HPI_ERROR_BAD_ADAPTER_NUMBER = 202, 934 HPI_ERROR_BAD_ADAPTER_NUMBER = 202,
942 /** 2 adapters with the same adapter number. */ 935 /** 2 adapters with the same adapter number. */
943 HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203, 936 HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203,
944 /** DSP code failed to bootload. (unused?) */ 937 /** DSP code failed to bootload. Usually a DSP memory test failure. */
945 HPI_ERROR_DSP_BOOTLOAD = 204, 938 HPI_ERROR_DSP_BOOTLOAD = 204,
946 /** Couldn't find or open the DSP code file. */ 939 /** Couldn't find or open the DSP code file. */
947 HPI_ERROR_DSP_FILE_NOT_FOUND = 206, 940 HPI_ERROR_DSP_FILE_NOT_FOUND = 206,
@@ -978,6 +971,9 @@ enum HPI_ERROR_CODES {
978 HPI_ERROR_FLASH_VERIFY = 225, 971 HPI_ERROR_FLASH_VERIFY = 225,
979 HPI_ERROR_FLASH_TYPE = 226, 972 HPI_ERROR_FLASH_TYPE = 226,
980 HPI_ERROR_FLASH_START = 227, 973 HPI_ERROR_FLASH_START = 227,
974 HPI_ERROR_FLASH_READ = 228,
975 HPI_ERROR_FLASH_READ_NO_FILE = 229,
976 HPI_ERROR_FLASH_SIZE = 230,
981 977
982 /** Reserved for OEMs. */ 978 /** Reserved for OEMs. */
983 HPI_ERROR_RESERVED_1 = 290, 979 HPI_ERROR_RESERVED_1 = 290,
@@ -1020,6 +1016,8 @@ enum HPI_ERROR_CODES {
1020 HPI_ERROR_NO_INTERDSP_GROUPS = 315, 1016 HPI_ERROR_NO_INTERDSP_GROUPS = 315,
1021 /** Stream wait cancelled before threshold reached. */ 1017 /** Stream wait cancelled before threshold reached. */
1022 HPI_ERROR_WAIT_CANCELLED = 316, 1018 HPI_ERROR_WAIT_CANCELLED = 316,
1019 /** A character string is invalid. */
1020 HPI_ERROR_INVALID_STRING = 317,
1023 1021
1024 /** Invalid mixer node for this adapter. */ 1022 /** Invalid mixer node for this adapter. */
1025 HPI_ERROR_INVALID_NODE = 400, 1023 HPI_ERROR_INVALID_NODE = 400,
@@ -1046,11 +1044,15 @@ enum HPI_ERROR_CODES {
1046 /** I2C */ 1044 /** I2C */
1047 HPI_ERROR_I2C_BAD_ADR = 460, 1045 HPI_ERROR_I2C_BAD_ADR = 460,
1048 1046
1049 /** Entity errors */ 1047 /** Entity type did not match requested type */
1050 HPI_ERROR_ENTITY_TYPE_MISMATCH = 470, 1048 HPI_ERROR_ENTITY_TYPE_MISMATCH = 470,
1049 /** Entity item count did not match requested count */
1051 HPI_ERROR_ENTITY_ITEM_COUNT = 471, 1050 HPI_ERROR_ENTITY_ITEM_COUNT = 471,
1051 /** Entity type is not one of the valid types */
1052 HPI_ERROR_ENTITY_TYPE_INVALID = 472, 1052 HPI_ERROR_ENTITY_TYPE_INVALID = 472,
1053 /** Entity role is not one of the valid roles */
1053 HPI_ERROR_ENTITY_ROLE_INVALID = 473, 1054 HPI_ERROR_ENTITY_ROLE_INVALID = 473,
1055 /** Entity size doesn't match target size */
1054 HPI_ERROR_ENTITY_SIZE_MISMATCH = 474, 1056 HPI_ERROR_ENTITY_SIZE_MISMATCH = 474,
1055 1057
1056 /* AES18 specific errors were 500..507 */ 1058 /* AES18 specific errors were 500..507 */
@@ -1078,8 +1080,7 @@ enum HPI_ERROR_CODES {
1078/** \defgroup maximums HPI maximum values 1080/** \defgroup maximums HPI maximum values
1079\{ 1081\{
1080*/ 1082*/
1081/** Maximum number of adapters per HPI sub-system 1083/** Maximum number of PCI HPI adapters */
1082 WARNING: modifying this value changes the response structure size.*/
1083#define HPI_MAX_ADAPTERS 20 1084#define HPI_MAX_ADAPTERS 20
1084/** Maximum number of in or out streams per adapter */ 1085/** Maximum number of in or out streams per adapter */
1085#define HPI_MAX_STREAMS 16 1086#define HPI_MAX_STREAMS 16
@@ -1090,6 +1091,9 @@ enum HPI_ERROR_CODES {
1090#define HPI_MAX_ANC_BYTES_PER_FRAME (64) 1091#define HPI_MAX_ANC_BYTES_PER_FRAME (64)
1091#define HPI_STRING_LEN 16 1092#define HPI_STRING_LEN 16
1092 1093
1094/** Networked adapters have index >= 100 */
1095#define HPI_MIN_NETWORK_ADAPTER_IDX 100
1096
1093/** Velocity units */ 1097/** Velocity units */
1094#define HPI_OSTREAM_VELOCITY_UNITS 4096 1098#define HPI_OSTREAM_VELOCITY_UNITS 4096
1095/** OutStream timescale units */ 1099/** OutStream timescale units */
@@ -1111,14 +1115,14 @@ enum HPI_ERROR_CODES {
1111struct hpi_format { 1115struct hpi_format {
1112 u32 sample_rate; 1116 u32 sample_rate;
1113 /**< 11025, 32000, 44100 ... */ 1117 /**< 11025, 32000, 44100 ... */
1114 u32 bit_rate; /**< for MPEG */ 1118 u32 bit_rate; /**< for MPEG */
1115 u32 attributes; 1119 u32 attributes;
1116 /**< Stereo/JointStereo/Mono */ 1120 /**< Stereo/JointStereo/Mono */
1117 u16 mode_legacy; 1121 u16 mode_legacy;
1118 /**< Legacy ancillary mode or idle bit */ 1122 /**< Legacy ancillary mode or idle bit */
1119 u16 unused; /**< Unused */ 1123 u16 unused; /**< Unused */
1120 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ 1124 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
1121 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */ 1125 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */
1122}; 1126};
1123 1127
1124struct hpi_anc_frame { 1128struct hpi_anc_frame {
@@ -1144,9 +1148,6 @@ struct hpi_async_event {
1144 } u; 1148 } u;
1145}; 1149};
1146 1150
1147/* skip host side function declarations for
1148 DSP compile and documentation extraction */
1149
1150#ifndef DISABLE_PRAGMA_PACK1 1151#ifndef DISABLE_PRAGMA_PACK1
1151#pragma pack(pop) 1152#pragma pack(pop)
1152#endif 1153#endif
@@ -1357,7 +1358,7 @@ u16 hpi_volume_get_mute(u32 h_control, u32 *mute);
1357u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB, 1358u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
1358 short *max_gain_01dB, short *step_gain_01dB); 1359 short *max_gain_01dB, short *step_gain_01dB);
1359 1360
1360u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels); 1361u16 hpi_volume_query_channels(const u32 h_control, u32 *p_channels);
1361 1362
1362u16 hpi_volume_auto_fade(u32 h_control, 1363u16 hpi_volume_auto_fade(u32 h_control,
1363 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms); 1364 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms);
@@ -1366,6 +1367,9 @@ u16 hpi_volume_auto_fade_profile(u32 h_control,
1366 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms, 1367 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
1367 u16 profile); 1368 u16 profile);
1368 1369
1370u16 hpi_volume_query_auto_fade_profile(const u32 h_control, const u32 i,
1371 u16 *profile);
1372
1369/*****************/ 1373/*****************/
1370/* Level control */ 1374/* Level control */
1371/*****************/ 1375/*****************/
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index 3cc6f11c20aa..2414d7a2239d 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -231,6 +231,8 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
231static void control_message(struct hpi_adapter_obj *pao, 231static void control_message(struct hpi_adapter_obj *pao,
232 struct hpi_message *phm, struct hpi_response *phr) 232 struct hpi_message *phm, struct hpi_response *phr)
233{ 233{
234 struct hpi_hw_obj *phw = pao->priv;
235
234 switch (phm->function) { 236 switch (phm->function) {
235 case HPI_CONTROL_GET_STATE: 237 case HPI_CONTROL_GET_STATE:
236 if (pao->has_control_cache) { 238 if (pao->has_control_cache) {
@@ -248,17 +250,14 @@ static void control_message(struct hpi_adapter_obj *pao,
248 break; 250 break;
249 } 251 }
250 252
251 if (hpi_check_control_cache(((struct hpi_hw_obj *) 253 if (hpi_check_control_cache(phw->p_cache, phm, phr))
252 pao->priv)->p_cache, phm,
253 phr))
254 break; 254 break;
255 } 255 }
256 hw_message(pao, phm, phr); 256 hw_message(pao, phm, phr);
257 break; 257 break;
258 case HPI_CONTROL_SET_STATE: 258 case HPI_CONTROL_SET_STATE:
259 hw_message(pao, phm, phr); 259 hw_message(pao, phm, phr);
260 hpi_cmn_control_cache_sync_to_msg(((struct hpi_hw_obj *)pao-> 260 hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm, phr);
261 priv)->p_cache, phm, phr);
262 break; 261 break;
263 262
264 case HPI_CONTROL_GET_INFO: 263 case HPI_CONTROL_GET_INFO:
@@ -451,11 +450,11 @@ static void subsys_create_adapter(struct hpi_message *phm,
451 } 450 }
452 451
453 for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) { 452 for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) {
454 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 453 struct hpi_hw_obj *phw = pao->priv;
455 phw->ado[dsp_index].pa_parent_adapter = pao; 454 phw->ado[dsp_index].pa_parent_adapter = pao;
456 } 455 }
457 456
458 phr->u.s.adapter_type = ao.adapter_type; 457 phr->u.s.adapter_type = ao.type;
459 phr->u.s.adapter_index = ao.index; 458 phr->u.s.adapter_index = ao.index;
460 phr->error = 0; 459 phr->error = 0;
461} 460}
@@ -476,7 +475,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
476 u32 dsp_index = 0; 475 u32 dsp_index = 0;
477 u32 control_cache_size = 0; 476 u32 control_cache_size = 0;
478 u32 control_cache_count = 0; 477 u32 control_cache_count = 0;
479 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 478 struct hpi_hw_obj *phw = pao->priv;
480 479
481 /* The PCI2040 has the following address map */ 480 /* The PCI2040 has the following address map */
482 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ 481 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */
@@ -559,7 +558,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
559 if (error) 558 if (error)
560 return error; 559 return error;
561 } 560 }
562 pao->adapter_type = hr0.u.ax.info.adapter_type; 561 pao->type = hr0.u.ax.info.adapter_type;
563 pao->index = hr0.u.ax.info.adapter_index; 562 pao->index = hr0.u.ax.info.adapter_index;
564 } 563 }
565 564
@@ -584,9 +583,8 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
584 pao->has_control_cache = 1; 583 pao->has_control_cache = 1;
585 } 584 }
586 585
587 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", 586 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", pao->type,
588 pao->adapter_type, pao->index); 587 pao->index);
589 pao->open = 0; /* upon creation the adapter is closed */
590 588
591 if (phw->p_cache) 589 if (phw->p_cache)
592 phw->p_cache->adap_idx = pao->index; 590 phw->p_cache->adap_idx = pao->index;
@@ -596,7 +594,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
596 594
597static void delete_adapter_obj(struct hpi_adapter_obj *pao) 595static void delete_adapter_obj(struct hpi_adapter_obj *pao)
598{ 596{
599 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 597 struct hpi_hw_obj *phw = pao->priv;
600 598
601 if (pao->has_control_cache) 599 if (pao->has_control_cache)
602 hpi_free_control_cache(phw->p_cache); 600 hpi_free_control_cache(phw->p_cache);
@@ -639,7 +637,7 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao,
639static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, 637static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
640 u32 *pos_error_code) 638 u32 *pos_error_code)
641{ 639{
642 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 640 struct hpi_hw_obj *phw = pao->priv;
643 short error; 641 short error;
644 u32 timeout; 642 u32 timeout;
645 u32 read = 0; 643 u32 read = 0;
@@ -1220,8 +1218,8 @@ static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
1220static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, 1218static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao,
1221 u16 dsp_index, u32 hpi_address, u32 *source, u32 count) 1219 u16 dsp_index, u32 hpi_address, u32 *source, u32 count)
1222{ 1220{
1223 struct dsp_obj *pdo = 1221 struct hpi_hw_obj *phw = pao->priv;
1224 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1222 struct dsp_obj *pdo = &phw->ado[dsp_index];
1225 u32 time_out = PCI_TIMEOUT; 1223 u32 time_out = PCI_TIMEOUT;
1226 int c6711_burst_size = 128; 1224 int c6711_burst_size = 128;
1227 u32 local_hpi_address = hpi_address; 1225 u32 local_hpi_address = hpi_address;
@@ -1258,8 +1256,8 @@ static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao,
1258static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, 1256static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao,
1259 u16 dsp_index, u32 hpi_address, u32 *dest, u32 count) 1257 u16 dsp_index, u32 hpi_address, u32 *dest, u32 count)
1260{ 1258{
1261 struct dsp_obj *pdo = 1259 struct hpi_hw_obj *phw = pao->priv;
1262 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1260 struct dsp_obj *pdo = &phw->ado[dsp_index];
1263 u32 time_out = PCI_TIMEOUT; 1261 u32 time_out = PCI_TIMEOUT;
1264 int c6711_burst_size = 16; 1262 int c6711_burst_size = 16;
1265 u32 local_hpi_address = hpi_address; 1263 u32 local_hpi_address = hpi_address;
@@ -1298,7 +1296,7 @@ static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao,
1298static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, 1296static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1299 u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr) 1297 u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr)
1300{ 1298{
1301 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 1299 struct hpi_hw_obj *phw = pao->priv;
1302 struct dsp_obj *pdo = &phw->ado[dsp_index]; 1300 struct dsp_obj *pdo = &phw->ado[dsp_index];
1303 u32 timeout; 1301 u32 timeout;
1304 u16 ack; 1302 u16 ack;
@@ -1414,8 +1412,8 @@ static short hpi6000_send_data_check_adr(u32 address, u32 length_in_dwords)
1414static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, 1412static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index,
1415 struct hpi_message *phm, struct hpi_response *phr) 1413 struct hpi_message *phm, struct hpi_response *phr)
1416{ 1414{
1417 struct dsp_obj *pdo = 1415 struct hpi_hw_obj *phw = pao->priv;
1418 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1416 struct dsp_obj *pdo = &phw->ado[dsp_index];
1419 u32 data_sent = 0; 1417 u32 data_sent = 0;
1420 u16 ack; 1418 u16 ack;
1421 u32 length, address; 1419 u32 length, address;
@@ -1487,8 +1485,8 @@ static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index,
1487static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index, 1485static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index,
1488 struct hpi_message *phm, struct hpi_response *phr) 1486 struct hpi_message *phm, struct hpi_response *phr)
1489{ 1487{
1490 struct dsp_obj *pdo = 1488 struct hpi_hw_obj *phw = pao->priv;
1491 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1489 struct dsp_obj *pdo = &phw->ado[dsp_index];
1492 u32 data_got = 0; 1490 u32 data_got = 0;
1493 u16 ack; 1491 u16 ack;
1494 u32 length, address; 1492 u32 length, address;
@@ -1551,8 +1549,8 @@ static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo)
1551static short hpi6000_send_host_command(struct hpi_adapter_obj *pao, 1549static short hpi6000_send_host_command(struct hpi_adapter_obj *pao,
1552 u16 dsp_index, u32 host_cmd) 1550 u16 dsp_index, u32 host_cmd)
1553{ 1551{
1554 struct dsp_obj *pdo = 1552 struct hpi_hw_obj *phw = pao->priv;
1555 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1553 struct dsp_obj *pdo = &phw->ado[dsp_index];
1556 u32 timeout = TIMEOUT; 1554 u32 timeout = TIMEOUT;
1557 1555
1558 /* set command */ 1556 /* set command */
@@ -1577,7 +1575,7 @@ static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao,
1577{ 1575{
1578 u32 hPI_error; 1576 u32 hPI_error;
1579 1577
1580 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 1578 struct hpi_hw_obj *phw = pao->priv;
1581 1579
1582 /* read the error bits from the PCI2040 */ 1580 /* read the error bits from the PCI2040 */
1583 hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT); 1581 hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT);
@@ -1597,8 +1595,8 @@ static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao,
1597static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index, 1595static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index,
1598 u32 ack_value) 1596 u32 ack_value)
1599{ 1597{
1600 struct dsp_obj *pdo = 1598 struct hpi_hw_obj *phw = pao->priv;
1601 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1599 struct dsp_obj *pdo = &phw->ado[dsp_index];
1602 u32 ack = 0L; 1600 u32 ack = 0L;
1603 u32 timeout; 1601 u32 timeout;
1604 u32 hPIC = 0L; 1602 u32 hPIC = 0L;
@@ -1640,7 +1638,7 @@ static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao,
1640 struct hpi_message *phm) 1638 struct hpi_message *phm)
1641{ 1639{
1642 const u16 dsp_index = 0; 1640 const u16 dsp_index = 0;
1643 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 1641 struct hpi_hw_obj *phw = pao->priv;
1644 struct dsp_obj *pdo = &phw->ado[dsp_index]; 1642 struct dsp_obj *pdo = &phw->ado[dsp_index];
1645 u32 timeout; 1643 u32 timeout;
1646 u32 cache_dirty_flag; 1644 u32 cache_dirty_flag;
@@ -1740,7 +1738,8 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
1740{ 1738{
1741 u16 error = 0; 1739 u16 error = 0;
1742 u16 dsp_index = 0; 1740 u16 dsp_index = 0;
1743 u16 num_dsp = ((struct hpi_hw_obj *)pao->priv)->num_dsp; 1741 struct hpi_hw_obj *phw = pao->priv;
1742 u16 num_dsp = phw->num_dsp;
1744 1743
1745 if (num_dsp < 2) 1744 if (num_dsp < 2)
1746 dsp_index = 0; 1745 dsp_index = 0;
diff --git a/sound/pci/asihpi/hpi6000.h b/sound/pci/asihpi/hpi6000.h
index 4c7d507c0ecd..7e0deeff5e7c 100644
--- a/sound/pci/asihpi/hpi6000.h
+++ b/sound/pci/asihpi/hpi6000.h
@@ -1,7 +1,7 @@
1/***************************************************************************** 1/*****************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index e041a6ae1c5a..4f2873880b16 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -45,18 +45,21 @@
45#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016 45#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
46 46
47/* initialization/bootload errors */ 47/* initialization/bootload errors */
48#define HPI6205_ERROR_6205_NO_IRQ 1002 48#define HPI6205_ERROR_6205_NO_IRQ 1002
49#define HPI6205_ERROR_6205_INIT_FAILED 1003 49#define HPI6205_ERROR_6205_INIT_FAILED 1003
50#define HPI6205_ERROR_6205_REG 1006 50#define HPI6205_ERROR_6205_REG 1006
51#define HPI6205_ERROR_6205_DSPPAGE 1007 51#define HPI6205_ERROR_6205_DSPPAGE 1007
52#define HPI6205_ERROR_C6713_HPIC 1009 52#define HPI6205_ERROR_C6713_HPIC 1009
53#define HPI6205_ERROR_C6713_HPIA 1010 53#define HPI6205_ERROR_C6713_HPIA 1010
54#define HPI6205_ERROR_C6713_PLL 1011 54#define HPI6205_ERROR_C6713_PLL 1011
55#define HPI6205_ERROR_DSP_INTMEM 1012 55#define HPI6205_ERROR_DSP_INTMEM 1012
56#define HPI6205_ERROR_DSP_EXTMEM 1013 56#define HPI6205_ERROR_DSP_EXTMEM 1013
57#define HPI6205_ERROR_DSP_PLD 1014 57#define HPI6205_ERROR_DSP_PLD 1014
58#define HPI6205_ERROR_6205_EEPROM 1017 58#define HPI6205_ERROR_6205_EEPROM 1017
59#define HPI6205_ERROR_DSP_EMIF 1018 59#define HPI6205_ERROR_DSP_EMIF1 1018
60#define HPI6205_ERROR_DSP_EMIF2 1019
61#define HPI6205_ERROR_DSP_EMIF3 1020
62#define HPI6205_ERROR_DSP_EMIF4 1021
60 63
61/*****************************************************************************/ 64/*****************************************************************************/
62/* for C6205 PCI i/f */ 65/* for C6205 PCI i/f */
@@ -488,7 +491,7 @@ static void subsys_create_adapter(struct hpi_message *phm,
488 return; 491 return;
489 } 492 }
490 493
491 phr->u.s.adapter_type = ao.adapter_type; 494 phr->u.s.adapter_type = ao.type;
492 phr->u.s.adapter_index = ao.index; 495 phr->u.s.adapter_index = ao.index;
493 phr->error = 0; 496 phr->error = 0;
494} 497}
@@ -503,7 +506,7 @@ static void adapter_delete(struct hpi_adapter_obj *pao,
503 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 506 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
504 return; 507 return;
505 } 508 }
506 phw = (struct hpi_hw_obj *)pao->priv; 509 phw = pao->priv;
507 /* reset adapter h/w */ 510 /* reset adapter h/w */
508 /* Reset C6713 #1 */ 511 /* Reset C6713 #1 */
509 boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); 512 boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0);
@@ -652,7 +655,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
652 if (hr.error) 655 if (hr.error)
653 return hr.error; 656 return hr.error;
654 657
655 pao->adapter_type = hr.u.ax.info.adapter_type; 658 pao->type = hr.u.ax.info.adapter_type;
656 pao->index = hr.u.ax.info.adapter_index; 659 pao->index = hr.u.ax.info.adapter_index;
657 660
658 max_streams = 661 max_streams =
@@ -665,8 +668,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
665 hr.u.ax.info.serial_number); 668 hr.u.ax.info.serial_number);
666 } 669 }
667 670
668 pao->open = 0; /* upon creation the adapter is closed */
669
670 if (phw->p_cache) 671 if (phw->p_cache)
671 phw->p_cache->adap_idx = pao->index; 672 phw->p_cache->adap_idx = pao->index;
672 673
@@ -803,8 +804,8 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
803 obj_index]; 804 obj_index];
804 status->samples_processed = 0; 805 status->samples_processed = 0;
805 status->stream_state = HPI_STATE_STOPPED; 806 status->stream_state = HPI_STATE_STOPPED;
806 status->dSP_index = 0; 807 status->dsp_index = 0;
807 status->host_index = status->dSP_index; 808 status->host_index = status->dsp_index;
808 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 809 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
809 status->auxiliary_data_available = 0; 810 status->auxiliary_data_available = 0;
810 811
@@ -878,7 +879,7 @@ static void outstream_host_buffer_free(struct hpi_adapter_obj *pao,
878static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status) 879static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status)
879{ 880{
880 return status->size_in_bytes - (status->host_index - 881 return status->size_in_bytes - (status->host_index -
881 status->dSP_index); 882 status->dsp_index);
882} 883}
883 884
884static void outstream_write(struct hpi_adapter_obj *pao, 885static void outstream_write(struct hpi_adapter_obj *pao,
@@ -1080,8 +1081,8 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1080 obj_index]; 1081 obj_index];
1081 status->samples_processed = 0; 1082 status->samples_processed = 0;
1082 status->stream_state = HPI_STATE_STOPPED; 1083 status->stream_state = HPI_STATE_STOPPED;
1083 status->dSP_index = 0; 1084 status->dsp_index = 0;
1084 status->host_index = status->dSP_index; 1085 status->host_index = status->dsp_index;
1085 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 1086 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
1086 status->auxiliary_data_available = 0; 1087 status->auxiliary_data_available = 0;
1087 1088
@@ -1162,7 +1163,7 @@ static void instream_start(struct hpi_adapter_obj *pao,
1162 1163
1163static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status) 1164static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status)
1164{ 1165{
1165 return status->dSP_index - status->host_index; 1166 return status->dsp_index - status->host_index;
1166} 1167}
1167 1168
1168static void instream_read(struct hpi_adapter_obj *pao, 1169static void instream_read(struct hpi_adapter_obj *pao,
@@ -1614,7 +1615,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1614 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); 1615 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting);
1615 if (setting != boot_loader_read_mem32(pao, dsp_index, 1616 if (setting != boot_loader_read_mem32(pao, dsp_index,
1616 0x01800008)) 1617 0x01800008))
1617 return HPI6205_ERROR_DSP_EMIF; 1618 return HPI6205_ERROR_DSP_EMIF1;
1618 1619
1619 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ 1620 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */
1620 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1621 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1627,7 +1628,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1627 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); 1628 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting);
1628 if (setting != boot_loader_read_mem32(pao, dsp_index, 1629 if (setting != boot_loader_read_mem32(pao, dsp_index,
1629 0x01800004)) 1630 0x01800004))
1630 return HPI6205_ERROR_DSP_EMIF; 1631 return HPI6205_ERROR_DSP_EMIF2;
1631 1632
1632 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ 1633 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */
1633 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1634 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1639,7 +1640,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1639 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); 1640 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting);
1640 if (setting != boot_loader_read_mem32(pao, dsp_index, 1641 if (setting != boot_loader_read_mem32(pao, dsp_index,
1641 0x01800010)) 1642 0x01800010))
1642 return HPI6205_ERROR_DSP_EMIF; 1643 return HPI6205_ERROR_DSP_EMIF3;
1643 1644
1644 /* EMIF CE3 setup - 32 bit async. */ 1645 /* EMIF CE3 setup - 32 bit async. */
1645 /* This is the PLD on the ASI5000 cards only */ 1646 /* This is the PLD on the ASI5000 cards only */
@@ -1650,7 +1651,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1650 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); 1651 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting);
1651 if (setting != boot_loader_read_mem32(pao, dsp_index, 1652 if (setting != boot_loader_read_mem32(pao, dsp_index,
1652 0x01800014)) 1653 0x01800014))
1653 return HPI6205_ERROR_DSP_EMIF; 1654 return HPI6205_ERROR_DSP_EMIF4;
1654 1655
1655 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ 1656 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */
1656 /* need to use this else DSP code crashes? */ 1657 /* need to use this else DSP code crashes? */
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index d497030c160f..4cc315daeda0 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -25,6 +25,7 @@ HPI internal definitions
25#define _HPI_INTERNAL_H_ 25#define _HPI_INTERNAL_H_
26 26
27#include "hpi.h" 27#include "hpi.h"
28
28/** maximum number of memory regions mapped to an adapter */ 29/** maximum number of memory regions mapped to an adapter */
29#define HPI_MAX_ADAPTER_MEM_SPACES (2) 30#define HPI_MAX_ADAPTER_MEM_SPACES (2)
30 31
@@ -220,8 +221,6 @@ enum HPI_CONTROL_ATTRIBUTES {
220 221
221 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1), 222 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
222 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2), 223 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
223 /*HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3), */
224 /*HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4), */
225 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5), 224 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
226 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6), 225 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
227 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7), 226 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
@@ -241,7 +240,9 @@ enum HPI_CONTROL_ATTRIBUTES {
241 HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5), 240 HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
242 HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6), 241 HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
243 HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7), 242 HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
244 HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8) 243 HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8),
244
245 HPI_UNIVERSAL_ENTITY = HPI_CTL_ATTR(UNIVERSAL, 1)
245}; 246};
246 247
247#define HPI_POLARITY_POSITIVE 0 248#define HPI_POLARITY_POSITIVE 0
@@ -393,14 +394,10 @@ enum HPI_FUNCTION_IDS {
393 HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1), 394 HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
394 HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2), 395 HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
395 HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3), 396 HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
396 /* HPI_SUBSYS_FIND_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 4), */
397 HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5), 397 HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
398 HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6), 398 HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
399 /* HPI_SUBSYS_DELETE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 7), */
400 HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8), 399 HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
401 HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9), 400 HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
402 /* HPI_SUBSYS_READ_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 10), */
403 /* HPI_SUBSYS_WRITE_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 11), */
404 HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12), 401 HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
405 HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13), 402 HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
406 HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14), 403 HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
@@ -430,7 +427,10 @@ enum HPI_FUNCTION_IDS {
430 HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19), 427 HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19),
431 HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20), 428 HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20),
432 HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21), 429 HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21),
433#define HPI_ADAPTER_FUNCTION_COUNT 21 430 HPI_ADAPTER_READ_FLASH = HPI_FUNC_ID(ADAPTER, 22),
431 HPI_ADAPTER_END_FLASH = HPI_FUNC_ID(ADAPTER, 23),
432 HPI_ADAPTER_FILESTORE_DELETE_ALL = HPI_FUNC_ID(ADAPTER, 24),
433#define HPI_ADAPTER_FUNCTION_COUNT 24
434 434
435 HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1), 435 HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
436 HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2), 436 HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
@@ -495,7 +495,9 @@ enum HPI_FUNCTION_IDS {
495 HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10), 495 HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
496 HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11), 496 HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
497 HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12), 497 HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12),
498#define HPI_MIXER_FUNCTION_COUNT 12 498 HPI_MIXER_GET_BLOCK_HANDLE = HPI_FUNC_ID(MIXER, 13),
499 HPI_MIXER_GET_PARAMETER_HANDLE = HPI_FUNC_ID(MIXER, 14),
500#define HPI_MIXER_FUNCTION_COUNT 14
499 501
500 HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1), 502 HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
501 HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2), 503 HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
@@ -618,7 +620,7 @@ struct hpi_hostbuffer_status {
618 u32 auxiliary_data_available; 620 u32 auxiliary_data_available;
619 u32 stream_state; 621 u32 stream_state;
620 /* DSP index in to the host bus master buffer. */ 622 /* DSP index in to the host bus master buffer. */
621 u32 dSP_index; 623 u32 dsp_index;
622 /* Host index in to the host bus master buffer. */ 624 /* Host index in to the host bus master buffer. */
623 u32 host_index; 625 u32 host_index;
624 u32 size_in_bytes; 626 u32 size_in_bytes;
@@ -661,13 +663,6 @@ union hpi_adapterx_msg {
661 u16 index; 663 u16 index;
662 } module_info; 664 } module_info;
663 struct { 665 struct {
664 u32 checksum;
665 u16 sequence;
666 u16 length;
667 u16 offset; /**< offset from start of msg to data */
668 u16 unused;
669 } program_flash;
670 struct {
671 u16 index; 666 u16 index;
672 u16 what; 667 u16 what;
673 u16 property_index; 668 u16 property_index;
@@ -678,25 +673,18 @@ union hpi_adapterx_msg {
678 u16 parameter2; 673 u16 parameter2;
679 } property_set; 674 } property_set;
680 struct { 675 struct {
681 u32 offset;
682 } query_flash;
683 struct {
684 u32 pad32; 676 u32 pad32;
685 u16 key1; 677 u16 key1;
686 u16 key2; 678 u16 key2;
687 } restart; 679 } restart;
688 struct { 680 struct {
689 u32 offset;
690 u32 length;
691 u32 key;
692 } start_flash;
693 struct {
694 u32 pad32; 681 u32 pad32;
695 u16 value; 682 u16 value;
696 } test_assert; 683 } test_assert;
697 struct { 684 struct {
698 u32 yes; 685 u32 yes;
699 } irq_query; 686 } irq_query;
687 u32 pad[3];
700}; 688};
701 689
702struct hpi_adapter_res { 690struct hpi_adapter_res {
@@ -724,18 +712,10 @@ union hpi_adapterx_res {
724 u32 adapter_mode; 712 u32 adapter_mode;
725 } mode; 713 } mode;
726 struct { 714 struct {
727 u16 sequence;
728 } program_flash;
729 struct {
730 u16 parameter1; 715 u16 parameter1;
731 u16 parameter2; 716 u16 parameter2;
732 } property_get; 717 } property_get;
733 struct { 718 struct {
734 u32 checksum;
735 u32 length;
736 u32 version;
737 } query_flash;
738 struct {
739 u32 yes; 719 u32 yes;
740 } irq_query; 720 } irq_query;
741}; 721};
@@ -1150,74 +1130,9 @@ struct hpi_res_adapter_get_info {
1150 struct hpi_adapter_res p; 1130 struct hpi_adapter_res p;
1151}; 1131};
1152 1132
1153/* padding is so these are same size as v0 hpi_message */
1154struct hpi_msg_adapter_query_flash {
1155 struct hpi_message_header h;
1156 u32 offset;
1157 u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 res */
1158 sizeof(struct hpi_message_header) - 1 * sizeof(u32)];
1159};
1160
1161/* padding is so these are same size as v0 hpi_response */
1162struct hpi_res_adapter_query_flash {
1163 struct hpi_response_header h;
1164 u32 checksum;
1165 u32 length;
1166 u32 version;
1167 u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */
1168 sizeof(struct hpi_response_header) - 3 * sizeof(u32)];
1169};
1170
1171struct hpi_msg_adapter_start_flash {
1172 struct hpi_message_header h;
1173 u32 offset;
1174 u32 length;
1175 u32 key;
1176 u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 res */
1177 sizeof(struct hpi_message_header) - 3 * sizeof(u32)];
1178};
1179
1180struct hpi_res_adapter_start_flash {
1181 struct hpi_response_header h;
1182 u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */
1183 sizeof(struct hpi_response_header)];
1184};
1185
1186struct hpi_msg_adapter_program_flash_payload {
1187 u32 checksum;
1188 u16 sequence;
1189 u16 length;
1190 u16 offset; /**< offset from start of msg to data */
1191 u16 unused;
1192 /* ensure sizeof(header + payload) == sizeof(hpi_message_V0)
1193 because old firmware expects data after message of this size */
1194 u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 message */
1195 sizeof(struct hpi_message_header) - sizeof(u32) -
1196 4 * sizeof(u16)];
1197};
1198
1199struct hpi_msg_adapter_program_flash {
1200 struct hpi_message_header h;
1201 struct hpi_msg_adapter_program_flash_payload p;
1202 u32 data[256];
1203};
1204
1205struct hpi_res_adapter_program_flash {
1206 struct hpi_response_header h;
1207 u16 sequence;
1208 u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */
1209 sizeof(struct hpi_response_header) - sizeof(u16)];
1210};
1211
1212struct hpi_msg_adapter_debug_read {
1213 struct hpi_message_header h;
1214 u32 dsp_address;
1215 u32 count_bytes;
1216};
1217
1218struct hpi_res_adapter_debug_read { 1133struct hpi_res_adapter_debug_read {
1219 struct hpi_response_header h; 1134 struct hpi_response_header h;
1220 u8 bytes[256]; 1135 u8 bytes[1024];
1221}; 1136};
1222 1137
1223struct hpi_msg_cobranet_hmi { 1138struct hpi_msg_cobranet_hmi {
@@ -1461,7 +1376,7 @@ struct hpi_control_cache_pad {
1461/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */ 1376/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1462struct hpi_fifo_buffer { 1377struct hpi_fifo_buffer {
1463 u32 size; 1378 u32 size;
1464 u32 dSP_index; 1379 u32 dsp_index;
1465 u32 host_index; 1380 u32 host_index;
1466}; 1381};
1467 1382
diff --git a/sound/pci/asihpi/hpi_version.h b/sound/pci/asihpi/hpi_version.h
new file mode 100644
index 000000000000..e9146e53bd50
--- /dev/null
+++ b/sound/pci/asihpi/hpi_version.h
@@ -0,0 +1,32 @@
1/** HPI Version Definitions
2Development releases have odd minor version.
3Production releases have even minor version.
4
5\file hpi_version.h
6*/
7
8#ifndef _HPI_VERSION_H
9#define _HPI_VERSION_H
10
11/* Use single digits for versions less that 10 to avoid octal. */
12/* *** HPI_VER is the only edit required to update version *** */
13/** HPI version */
14#define HPI_VER HPI_VERSION_CONSTRUCTOR(4, 10, 1)
15
16/** HPI version string in dotted decimal format */
17#define HPI_VER_STRING "4.10.01"
18
19/** Library version as documented in hpi-api-versions.txt */
20#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(10, 2, 0)
21
22/** Construct hpi version number from major, minor, release numbers */
23#define HPI_VERSION_CONSTRUCTOR(maj, min, r) ((maj << 16) + (min << 8) + r)
24
25/** Extract major version from hpi version number */
26#define HPI_VER_MAJOR(v) ((int)(v >> 16))
27/** Extract minor version from hpi version number */
28#define HPI_VER_MINOR(v) ((int)((v >> 8) & 0xFF))
29/** Extract release from hpi version number */
30#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
31
32#endif
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index bd47521b24ec..7ed5c26c3737 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -68,7 +68,7 @@ u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
68u16 hpi_add_adapter(struct hpi_adapter_obj *pao) 68u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
69{ 69{
70 u16 retval = 0; 70 u16 retval = 0;
71 /*HPI_ASSERT(pao->wAdapterType); */ 71 /*HPI_ASSERT(pao->type); */
72 72
73 hpios_alistlock_lock(&adapters); 73 hpios_alistlock_lock(&adapters);
74 74
@@ -77,13 +77,13 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
77 goto unlock; 77 goto unlock;
78 } 78 }
79 79
80 if (adapters.adapter[pao->index].adapter_type) { 80 if (adapters.adapter[pao->index].type) {
81 int a; 81 int a;
82 for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) { 82 for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) {
83 if (!adapters.adapter[a].adapter_type) { 83 if (!adapters.adapter[a].type) {
84 HPI_DEBUG_LOG(WARNING, 84 HPI_DEBUG_LOG(WARNING,
85 "ASI%X duplicate index %d moved to %d\n", 85 "ASI%X duplicate index %d moved to %d\n",
86 pao->adapter_type, pao->index, a); 86 pao->type, pao->index, a);
87 pao->index = a; 87 pao->index = a;
88 break; 88 break;
89 } 89 }
@@ -104,13 +104,13 @@ unlock:
104 104
105void hpi_delete_adapter(struct hpi_adapter_obj *pao) 105void hpi_delete_adapter(struct hpi_adapter_obj *pao)
106{ 106{
107 if (!pao->adapter_type) { 107 if (!pao->type) {
108 HPI_DEBUG_LOG(ERROR, "removing null adapter?\n"); 108 HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
109 return; 109 return;
110 } 110 }
111 111
112 hpios_alistlock_lock(&adapters); 112 hpios_alistlock_lock(&adapters);
113 if (adapters.adapter[pao->index].adapter_type) 113 if (adapters.adapter[pao->index].type)
114 adapters.gw_num_adapters--; 114 adapters.gw_num_adapters--;
115 memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0])); 115 memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
116 hpios_alistlock_unlock(&adapters); 116 hpios_alistlock_unlock(&adapters);
@@ -132,7 +132,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
132 } 132 }
133 133
134 pao = &adapters.adapter[adapter_index]; 134 pao = &adapters.adapter[adapter_index];
135 if (pao->adapter_type != 0) { 135 if (pao->type != 0) {
136 /* 136 /*
137 HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n", 137 HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n",
138 wAdapterIndex); 138 wAdapterIndex);
@@ -165,7 +165,7 @@ static void subsys_get_adapter(struct hpi_message *phm,
165 165
166 /* find the nCount'th nonzero adapter in array */ 166 /* find the nCount'th nonzero adapter in array */
167 for (index = 0; index < HPI_MAX_ADAPTERS; index++) { 167 for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
168 if (adapters.adapter[index].adapter_type) { 168 if (adapters.adapter[index].type) {
169 if (!count) 169 if (!count)
170 break; 170 break;
171 count--; 171 count--;
@@ -174,11 +174,11 @@ static void subsys_get_adapter(struct hpi_message *phm,
174 174
175 if (index < HPI_MAX_ADAPTERS) { 175 if (index < HPI_MAX_ADAPTERS) {
176 phr->u.s.adapter_index = adapters.adapter[index].index; 176 phr->u.s.adapter_index = adapters.adapter[index].index;
177 phr->u.s.adapter_type = adapters.adapter[index].adapter_type; 177 phr->u.s.adapter_type = adapters.adapter[index].type;
178 } else { 178 } else {
179 phr->u.s.adapter_index = 0; 179 phr->u.s.adapter_index = 0;
180 phr->u.s.adapter_type = 0; 180 phr->u.s.adapter_type = 0;
181 phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER; 181 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
182 } 182 }
183} 183}
184 184
@@ -324,6 +324,8 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
324 } 324 }
325 325
326 phr->error = 0; 326 phr->error = 0;
327 phr->specific_error = 0;
328 phr->version = 0;
327 329
328 /* set the default response size */ 330 /* set the default response size */
329 response_size = 331 response_size =
@@ -531,8 +533,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
531 found ? "Cached" : "Uncached", phm->adapter_index, 533 found ? "Cached" : "Uncached", phm->adapter_index,
532 pI->control_index, pI->control_type, phm->u.c.attribute); 534 pI->control_index, pI->control_type, phm->u.c.attribute);
533 535
534 if (found) 536 if (found) {
535 phr->size = (u16)response_size; 537 phr->size = (u16)response_size;
538 phr->type = HPI_TYPE_RESPONSE;
539 phr->object = phm->object;
540 phr->function = phm->function;
541 }
536 542
537 return found; 543 return found;
538} 544}
@@ -631,7 +637,7 @@ struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
631 if (!p_cache) 637 if (!p_cache)
632 return NULL; 638 return NULL;
633 639
634 p_cache->p_info = kzalloc(sizeof(*p_cache->p_info) * control_count, 640 p_cache->p_info = kcalloc(control_count, sizeof(*p_cache->p_info),
635 GFP_KERNEL); 641 GFP_KERNEL);
636 if (!p_cache->p_info) { 642 if (!p_cache->p_info) {
637 kfree(p_cache); 643 kfree(p_cache);
diff --git a/sound/pci/asihpi/hpicmn.h b/sound/pci/asihpi/hpicmn.h
index d53cdf6e535f..e44121283047 100644
--- a/sound/pci/asihpi/hpicmn.h
+++ b/sound/pci/asihpi/hpicmn.h
@@ -1,7 +1,7 @@
1/** 1/**
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -18,12 +18,15 @@
18 18
19*/ 19*/
20 20
21struct hpi_adapter_obj;
22
23/* a function that takes an adapter obj and returns an int */
24typedef int adapter_int_func(struct hpi_adapter_obj *pao);
25
21struct hpi_adapter_obj { 26struct hpi_adapter_obj {
22 struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */ 27 struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */
23 u16 adapter_type; /* ASI6701 etc */ 28 u16 type; /* 0x6644 == ASI6644 etc */
24 u16 index; /* */ 29 u16 index;
25 u16 open; /* =1 when adapter open */
26 u16 mixer_open;
27 30
28 struct hpios_spinlock dsp_lock; 31 struct hpios_spinlock dsp_lock;
29 32
diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c
index b52baf62791e..ac86a1f1d3bf 100644
--- a/sound/pci/asihpi/hpidebug.c
+++ b/sound/pci/asihpi/hpidebug.c
@@ -1,7 +1,7 @@
1/************************************************************************ 1/************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpidebug.h b/sound/pci/asihpi/hpidebug.h
index 940f54c3c538..2c9af2329d36 100644
--- a/sound/pci/asihpi/hpidebug.h
+++ b/sound/pci/asihpi/hpidebug.h
@@ -1,7 +1,7 @@
1/***************************************************************************** 1/*****************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index 71d32c868c92..456a758f04f6 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -25,6 +25,7 @@ hotplug firmware loader from individual dsp code files
25#define SOURCEFILE_NAME "hpidspcd.c" 25#define SOURCEFILE_NAME "hpidspcd.c"
26#include "hpidspcd.h" 26#include "hpidspcd.h"
27#include "hpidebug.h" 27#include "hpidebug.h"
28#include "hpi_version.h"
28 29
29struct dsp_code_private { 30struct dsp_code_private {
30 /** Firmware descriptor */ 31 /** Firmware descriptor */
@@ -32,9 +33,6 @@ struct dsp_code_private {
32 struct pci_dev *dev; 33 struct pci_dev *dev;
33}; 34};
34 35
35#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
36 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
37
38/*-------------------------------------------------------------------*/ 36/*-------------------------------------------------------------------*/
39short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code, 37short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
40 u32 *os_error_code) 38 u32 *os_error_code)
@@ -66,22 +64,25 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
66 if ((header.type != 0x45444F43) || /* "CODE" */ 64 if ((header.type != 0x45444F43) || /* "CODE" */
67 (header.adapter != adapter) 65 (header.adapter != adapter)
68 || (header.size != firmware->size)) { 66 || (header.size != firmware->size)) {
69 dev_printk(KERN_ERR, &dev->dev, "Invalid firmware file\n"); 67 dev_printk(KERN_ERR, &dev->dev,
68 "Invalid firmware header size %d != file %zd\n",
69 header.size, firmware->size);
70 goto error2; 70 goto error2;
71 } 71 }
72 72
73 if ((header.version / 100 & ~1) != (HPI_VER_DECIMAL / 100 & ~1)) { 73 if ((header.version >> 9) != (HPI_VER >> 9)) {
74 /* Consider even and subsequent odd minor versions to be compatible */
74 dev_printk(KERN_ERR, &dev->dev, 75 dev_printk(KERN_ERR, &dev->dev,
75 "Incompatible firmware version " 76 "Incompatible firmware version "
76 "DSP image %d != Driver %d\n", header.version, 77 "DSP image %X != Driver %X\n", header.version,
77 HPI_VER_DECIMAL); 78 HPI_VER);
78 goto error2; 79 goto error2;
79 } 80 }
80 81
81 if (header.version != HPI_VER_DECIMAL) { 82 if (header.version != HPI_VER) {
82 dev_printk(KERN_WARNING, &dev->dev, 83 dev_printk(KERN_INFO, &dev->dev,
83 "Firmware: release version mismatch DSP image %d != Driver %d\n", 84 "Firmware: release version mismatch DSP image %X != Driver %X\n",
84 header.version, HPI_VER_DECIMAL); 85 header.version, HPI_VER);
85 } 86 }
86 87
87 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); 88 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
@@ -108,11 +109,8 @@ error1:
108/*-------------------------------------------------------------------*/ 109/*-------------------------------------------------------------------*/
109void hpi_dsp_code_close(struct dsp_code *dsp_code) 110void hpi_dsp_code_close(struct dsp_code *dsp_code)
110{ 111{
111 if (dsp_code->pvt->firmware) { 112 HPI_DEBUG_LOG(DEBUG, "dsp code closed\n");
112 HPI_DEBUG_LOG(DEBUG, "dsp code closed\n"); 113 release_firmware(dsp_code->pvt->firmware);
113 release_firmware(dsp_code->pvt->firmware);
114 dsp_code->pvt->firmware = NULL;
115 }
116 kfree(dsp_code->pvt); 114 kfree(dsp_code->pvt);
117} 115}
118 116
diff --git a/sound/pci/asihpi/hpidspcd.h b/sound/pci/asihpi/hpidspcd.h
index b22881122f19..659d19ca6d42 100644
--- a/sound/pci/asihpi/hpidspcd.h
+++ b/sound/pci/asihpi/hpidspcd.h
@@ -27,10 +27,6 @@ Functions for reading DSP code to load into DSP
27 27
28#include "hpi_internal.h" 28#include "hpi_internal.h"
29 29
30/** Code header version is decimal encoded e.g. 4.06.10 is 40601 */
31#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
32HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
33
34/** Header structure for dsp firmware file 30/** Header structure for dsp firmware file
35 This structure must match that used in s2bin.c for generation of asidsp.bin 31 This structure must match that used in s2bin.c for generation of asidsp.bin
36 */ 32 */
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index ebb568d695f1..510e56cffd31 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -2826,6 +2826,16 @@ u16 hpi_volume_auto_fade(u32 h_control,
2826 duration_ms, HPI_VOLUME_AUTOFADE_LOG); 2826 duration_ms, HPI_VOLUME_AUTOFADE_LOG);
2827} 2827}
2828 2828
2829u16 hpi_volume_query_auto_fade_profile(const u32 h_volume, const u32 i,
2830 u16 *profile)
2831{
2832 u16 e;
2833 u32 u;
2834 e = hpi_control_query(h_volume, HPI_VOLUME_AUTOFADE, i, 0, &u);
2835 *profile = (u16)u;
2836 return e;
2837}
2838
2829u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB) 2839u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
2830{ 2840{
2831 struct hpi_message hm; 2841 struct hpi_message hm;
diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
index 52400a6b5f15..032d563e3708 100644
--- a/sound/pci/asihpi/hpimsginit.c
+++ b/sound/pci/asihpi/hpimsginit.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpimsginit.h b/sound/pci/asihpi/hpimsginit.h
index bfd330d78b58..5b48708c7d1e 100644
--- a/sound/pci/asihpi/hpimsginit.h
+++ b/sound/pci/asihpi/hpimsginit.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index 2e779421a618..d4790ddc225c 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -22,6 +22,7 @@ Extended Message Function With Response Caching
22*****************************************************************************/ 22*****************************************************************************/
23#define SOURCEFILE_NAME "hpimsgx.c" 23#define SOURCEFILE_NAME "hpimsgx.c"
24#include "hpi_internal.h" 24#include "hpi_internal.h"
25#include "hpi_version.h"
25#include "hpimsginit.h" 26#include "hpimsginit.h"
26#include "hpicmn.h" 27#include "hpicmn.h"
27#include "hpimsgx.h" 28#include "hpimsgx.h"
diff --git a/sound/pci/asihpi/hpimsgx.h b/sound/pci/asihpi/hpimsgx.h
index fd49e7542a88..37f3efd95a70 100644
--- a/sound/pci/asihpi/hpimsgx.h
+++ b/sound/pci/asihpi/hpimsgx.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index f6b9517b4696..609156205562 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -21,6 +21,7 @@ Common Linux HPI ioctl and module probe/remove functions
21#define SOURCEFILE_NAME "hpioctl.c" 21#define SOURCEFILE_NAME "hpioctl.c"
22 22
23#include "hpi_internal.h" 23#include "hpi_internal.h"
24#include "hpi_version.h"
24#include "hpimsginit.h" 25#include "hpimsginit.h"
25#include "hpidebug.h" 26#include "hpidebug.h"
26#include "hpimsgx.h" 27#include "hpimsgx.h"
@@ -65,9 +66,7 @@ static struct hpi_adapter adapters[HPI_MAX_ADAPTERS];
65static void hpi_send_recv_f(struct hpi_message *phm, struct hpi_response *phr, 66static void hpi_send_recv_f(struct hpi_message *phm, struct hpi_response *phr,
66 struct file *file) 67 struct file *file)
67{ 68{
68 int adapter = phm->adapter_index; 69 if ((phm->adapter_index >= HPI_MAX_ADAPTERS)
69
70 if ((adapter >= HPI_MAX_ADAPTERS || adapter < 0)
71 && (phm->object != HPI_OBJ_SUBSYSTEM)) 70 && (phm->object != HPI_OBJ_SUBSYSTEM))
72 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 71 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
73 else 72 else
@@ -178,19 +177,14 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
178 } else { 177 } else {
179 u16 __user *ptr = NULL; 178 u16 __user *ptr = NULL;
180 u32 size = 0; 179 u32 size = 0;
181 u32 adapter_present;
182 /* -1=no data 0=read from user mem, 1=write to user mem */ 180 /* -1=no data 0=read from user mem, 1=write to user mem */
183 int wrflag = -1; 181 int wrflag = -1;
184 struct hpi_adapter *pa; 182 struct hpi_adapter *pa = NULL;
185 183
186 if (hm->h.adapter_index < HPI_MAX_ADAPTERS) { 184 if (hm->h.adapter_index < ARRAY_SIZE(adapters))
187 pa = &adapters[hm->h.adapter_index]; 185 pa = &adapters[hm->h.adapter_index];
188 adapter_present = pa->type;
189 } else {
190 adapter_present = 0;
191 }
192 186
193 if (!adapter_present) { 187 if (!pa || !pa->adapter || !pa->adapter->type) {
194 hpi_init_response(&hr->r0, hm->h.object, 188 hpi_init_response(&hr->r0, hm->h.object,
195 hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER); 189 hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER);
196 190
@@ -317,6 +311,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
317 const struct pci_device_id *pci_id) 311 const struct pci_device_id *pci_id)
318{ 312{
319 int idx, nm; 313 int idx, nm;
314 int adapter_index;
320 unsigned int memlen; 315 unsigned int memlen;
321 struct hpi_message hm; 316 struct hpi_message hm;
322 struct hpi_response hr; 317 struct hpi_response hr;
@@ -345,8 +340,6 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
345 340
346 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID; 341 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
347 342
348 adapter.pci = pci_dev;
349
350 nm = HPI_MAX_ADAPTER_MEM_SPACES; 343 nm = HPI_MAX_ADAPTER_MEM_SPACES;
351 344
352 for (idx = 0; idx < nm; idx++) { 345 for (idx = 0; idx < nm; idx++) {
@@ -355,18 +348,16 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
355 348
356 if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { 349 if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) {
357 memlen = pci_resource_len(pci_dev, idx); 350 memlen = pci_resource_len(pci_dev, idx);
358 adapter.ap_remapped_mem_base[idx] = 351 pci.ap_mem_base[idx] =
359 ioremap(pci_resource_start(pci_dev, idx), 352 ioremap(pci_resource_start(pci_dev, idx),
360 memlen); 353 memlen);
361 if (!adapter.ap_remapped_mem_base[idx]) { 354 if (!pci.ap_mem_base[idx]) {
362 HPI_DEBUG_LOG(ERROR, 355 HPI_DEBUG_LOG(ERROR,
363 "ioremap failed, aborting\n"); 356 "ioremap failed, aborting\n");
364 /* unmap previously mapped pci mem space */ 357 /* unmap previously mapped pci mem space */
365 goto err; 358 goto err;
366 } 359 }
367 } 360 }
368
369 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx];
370 } 361 }
371 362
372 pci.pci_dev = pci_dev; 363 pci.pci_dev = pci_dev;
@@ -378,6 +369,9 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
378 if (hr.error) 369 if (hr.error)
379 goto err; 370 goto err;
380 371
372 adapter_index = hr.u.s.adapter_index;
373 adapter.adapter = hpi_find_adapter(adapter_index);
374
381 if (prealloc_stream_buf) { 375 if (prealloc_stream_buf) {
382 adapter.p_buffer = vmalloc(prealloc_stream_buf); 376 adapter.p_buffer = vmalloc(prealloc_stream_buf);
383 if (!adapter.p_buffer) { 377 if (!adapter.p_buffer) {
@@ -389,36 +383,32 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
389 } 383 }
390 } 384 }
391 385
392 adapter.index = hr.u.s.adapter_index;
393 adapter.type = hr.u.s.adapter_type;
394
395 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 386 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
396 HPI_ADAPTER_OPEN); 387 HPI_ADAPTER_OPEN);
397 hm.adapter_index = adapter.index; 388 hm.adapter_index = adapter.adapter->index;
398 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 389 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
399 390
400 if (hr.error) 391 if (hr.error)
401 goto err; 392 goto err;
402 393
403 adapter.snd_card_asihpi = NULL;
404 /* WARNING can't init mutex in 'adapter' 394 /* WARNING can't init mutex in 'adapter'
405 * and then copy it to adapters[] ?!?! 395 * and then copy it to adapters[] ?!?!
406 */ 396 */
407 adapters[adapter.index] = adapter; 397 adapters[adapter_index] = adapter;
408 mutex_init(&adapters[adapter.index].mutex); 398 mutex_init(&adapters[adapter_index].mutex);
409 pci_set_drvdata(pci_dev, &adapters[adapter.index]); 399 pci_set_drvdata(pci_dev, &adapters[adapter_index]);
410 400
411 dev_printk(KERN_INFO, &pci_dev->dev, 401 dev_printk(KERN_INFO, &pci_dev->dev,
412 "probe succeeded for ASI%04X HPI index %d\n", adapter.type, 402 "probe succeeded for ASI%04X HPI index %d\n",
413 adapter.index); 403 adapter.adapter->type, adapter_index);
414 404
415 return 0; 405 return 0;
416 406
417err: 407err:
418 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { 408 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
419 if (adapter.ap_remapped_mem_base[idx]) { 409 if (pci.ap_mem_base[idx]) {
420 iounmap(adapter.ap_remapped_mem_base[idx]); 410 iounmap(pci.ap_mem_base[idx]);
421 adapter.ap_remapped_mem_base[idx] = NULL; 411 pci.ap_mem_base[idx] = NULL;
422 } 412 }
423 } 413 }
424 414
@@ -437,19 +427,20 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
437 struct hpi_message hm; 427 struct hpi_message hm;
438 struct hpi_response hr; 428 struct hpi_response hr;
439 struct hpi_adapter *pa; 429 struct hpi_adapter *pa;
430 struct hpi_pci pci;
431
440 pa = pci_get_drvdata(pci_dev); 432 pa = pci_get_drvdata(pci_dev);
433 pci = pa->adapter->pci;
441 434
442 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 435 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
443 HPI_ADAPTER_DELETE); 436 HPI_ADAPTER_DELETE);
444 hm.adapter_index = pa->index; 437 hm.adapter_index = pa->adapter->index;
445 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 438 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
446 439
447 /* unmap PCI memory space, mapped during device init. */ 440 /* unmap PCI memory space, mapped during device init. */
448 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { 441 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
449 if (pa->ap_remapped_mem_base[idx]) { 442 if (pci.ap_mem_base[idx])
450 iounmap(pa->ap_remapped_mem_base[idx]); 443 iounmap(pci.ap_mem_base[idx]);
451 pa->ap_remapped_mem_base[idx] = NULL;
452 }
453 } 444 }
454 445
455 if (pa->p_buffer) 446 if (pa->p_buffer)
@@ -461,7 +452,7 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
461 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n", 452 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n",
462 pci_dev->vendor, pci_dev->device, 453 pci_dev->vendor, pci_dev->device,
463 pci_dev->subsystem_vendor, pci_dev->subsystem_device, 454 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
464 pci_dev->devfn, pa->index); 455 pci_dev->devfn, pa->adapter->index);
465 456
466 memset(pa, 0, sizeof(*pa)); 457 memset(pa, 0, sizeof(*pa));
467} 458}
diff --git a/sound/pci/asihpi/hpioctl.h b/sound/pci/asihpi/hpioctl.h
index 847f72f03fe1..2614aff672e2 100644
--- a/sound/pci/asihpi/hpioctl.h
+++ b/sound/pci/asihpi/hpioctl.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpios.c b/sound/pci/asihpi/hpios.c
index ff2a19b544fa..2d7d1c2e1d0d 100644
--- a/sound/pci/asihpi/hpios.c
+++ b/sound/pci/asihpi/hpios.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h
index 2f605e34bad0..c5cef113c209 100644
--- a/sound/pci/asihpi/hpios.h
+++ b/sound/pci/asihpi/hpios.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -149,20 +149,18 @@ static inline void cond_unlock(struct hpios_spinlock *l)
149#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) 149#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock))
150#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock)) 150#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock))
151 151
152struct snd_card;
153
154/** pci drvdata points to an instance of this struct */
152struct hpi_adapter { 155struct hpi_adapter {
156 struct hpi_adapter_obj *adapter;
157 struct snd_card *snd_card;
158
153 /* mutex prevents contention for one card 159 /* mutex prevents contention for one card
154 between multiple user programs (via ioctl) */ 160 between multiple user programs (via ioctl) */
155 struct mutex mutex; 161 struct mutex mutex;
156 u16 index;
157 u16 type;
158
159 /* ALSA card structure */
160 void *snd_card_asihpi;
161
162 char *p_buffer; 162 char *p_buffer;
163 size_t buffer_size; 163 size_t buffer_size;
164 struct pci_dev *pci;
165 void __iomem *ap_remapped_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
166}; 164};
167 165
168#endif 166#endif
diff --git a/sound/pci/asihpi/hpipcida.h b/sound/pci/asihpi/hpipcida.h
index bb30868ce1a3..db570ddf64b3 100644
--- a/sound/pci/asihpi/hpipcida.h
+++ b/sound/pci/asihpi/hpipcida.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 15e4e5ee3881..590682f115ef 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -43,7 +43,7 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
43static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 43static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
44static int ac97_clock = 48000; 44static int ac97_clock = 48000;
45static char *ac97_quirk; 45static char *ac97_quirk;
46static int spdif_aclink = 1; 46static bool spdif_aclink = 1;
47static int ac97_codec = -1; 47static int ac97_codec = -1;
48 48
49module_param(index, int, 0444); 49module_param(index, int, 0444);
@@ -60,7 +60,7 @@ module_param(spdif_aclink, bool, 0444);
60MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); 60MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
61 61
62/* just for backward compatibility */ 62/* just for backward compatibility */
63static int enable; 63static bool enable;
64module_param(enable, bool, 0444); 64module_param(enable, bool, 0444);
65 65
66 66
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 57bf8f4bc7a8..524d35f31232 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -51,7 +51,7 @@ module_param(ac97_clock, int, 0444);
51MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); 51MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
52 52
53/* just for backward compatibility */ 53/* just for backward compatibility */
54static int enable; 54static bool enable;
55module_param(enable, bool, 0444); 55module_param(enable, bool, 0444);
56 56
57 57
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index dc326be58c4b..762bb108c51c 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -26,7 +26,7 @@
26// module parameters (see "Module Parameters") 26// module parameters (see "Module Parameters")
27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
29static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 29static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
30static int pcifix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 255 }; 30static int pcifix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 255 };
31 31
32module_param_array(index, int, NULL, 0444); 32module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 489150380eac..6933a27a5d76 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -805,7 +805,7 @@ static void vortex_fifo_setadbvalid(vortex_t * vortex, int fifo, int en)
805} 805}
806 806
807static void 807static void
808vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int b, int priority, 808vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int stereo, int priority,
809 int empty, int valid, int f) 809 int empty, int valid, int f)
810{ 810{
811 int temp, lifeboat = 0; 811 int temp, lifeboat = 0;
@@ -837,7 +837,7 @@ vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int b, int priority,
837#else 837#else
838 temp = (this_4 & 0x3f) << 0xc; 838 temp = (this_4 & 0x3f) << 0xc;
839#endif 839#endif
840 temp = (temp & 0xfffffffd) | ((b & 1) << 1); 840 temp = (temp & 0xfffffffd) | ((stereo & 1) << 1);
841 temp = (temp & 0xfffffff3) | ((priority & 3) << 2); 841 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
842 temp = (temp & 0xffffffef) | ((valid & 1) << 4); 842 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
843 temp |= FIFO_U1; 843 temp |= FIFO_U1;
@@ -1148,11 +1148,11 @@ vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma,
1148 1148
1149static void 1149static void
1150vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, int dir, 1150vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, int dir,
1151 int fmt, int d, u32 offset) 1151 int fmt, int stereo, u32 offset)
1152{ 1152{
1153 stream_t *dma = &vortex->dma_adb[adbdma]; 1153 stream_t *dma = &vortex->dma_adb[adbdma];
1154 1154
1155 dma->dma_unknown = d; 1155 dma->dma_unknown = stereo;
1156 dma->dma_ctrl = 1156 dma->dma_ctrl =
1157 ((offset & OFFSET_MASK) | (dma->dma_ctrl & ~OFFSET_MASK)); 1157 ((offset & OFFSET_MASK) | (dma->dma_ctrl & ~OFFSET_MASK));
1158 /* Enable PCMOUT interrupts. */ 1158 /* Enable PCMOUT interrupts. */
@@ -1336,7 +1336,6 @@ static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma)
1336 dma->fifo_status = FIFO_PAUSE; 1336 dma->fifo_status = FIFO_PAUSE;
1337} 1337}
1338 1338
1339#if 0 // Using pause instead
1340static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma) 1339static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma)
1341{ 1340{
1342 stream_t *dma = &vortex->dma_adb[adbdma]; 1341 stream_t *dma = &vortex->dma_adb[adbdma];
@@ -1351,7 +1350,6 @@ static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma)
1351 dma->fifo_enabled = 0; 1350 dma->fifo_enabled = 0;
1352} 1351}
1353 1352
1354#endif
1355/* WTDMA */ 1353/* WTDMA */
1356 1354
1357#ifndef CHIP_AU8810 1355#ifndef CHIP_AU8810
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c
index c5f7ae46afef..0488633ea874 100644
--- a/sound/pci/au88x0/au88x0_pcm.c
+++ b/sound/pci/au88x0/au88x0_pcm.c
@@ -307,8 +307,8 @@ static int snd_vortex_pcm_prepare(struct snd_pcm_substream *substream)
307 fmt = vortex_alsafmt_aspfmt(runtime->format); 307 fmt = vortex_alsafmt_aspfmt(runtime->format);
308 spin_lock_irq(&chip->lock); 308 spin_lock_irq(&chip->lock);
309 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) { 309 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) {
310 vortex_adbdma_setmode(chip, dma, 1, dir, fmt, 0 /*? */ , 310 vortex_adbdma_setmode(chip, dma, 1, dir, fmt,
311 0); 311 runtime->channels == 1 ? 0 : 1, 0);
312 vortex_adbdma_setstartbuffer(chip, dma, 0); 312 vortex_adbdma_setstartbuffer(chip, dma, 0);
313 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_SPDIF) 313 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_SPDIF)
314 vortex_adb_setsrc(chip, dma, runtime->rate, dir); 314 vortex_adb_setsrc(chip, dma, runtime->rate, dir);
@@ -353,8 +353,7 @@ static int snd_vortex_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
353 //printk(KERN_INFO "vortex: stop %d\n", dma); 353 //printk(KERN_INFO "vortex: stop %d\n", dma);
354 stream->fifo_enabled = 0; 354 stream->fifo_enabled = 0;
355 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) 355 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT)
356 vortex_adbdma_pausefifo(chip, dma); 356 vortex_adbdma_stopfifo(chip, dma);
357 //vortex_adbdma_stopfifo(chip, dma);
358#ifndef CHIP_AU8810 357#ifndef CHIP_AU8810
359 else { 358 else {
360 printk(KERN_INFO "vortex: wt stop %d\n", dma); 359 printk(KERN_INFO "vortex: wt stop %d\n", dma);
diff --git a/sound/pci/au88x0/au88x0_xtalk.c b/sound/pci/au88x0/au88x0_xtalk.c
index b4151e208b71..b278e285fd40 100644
--- a/sound/pci/au88x0/au88x0_xtalk.c
+++ b/sound/pci/au88x0/au88x0_xtalk.c
@@ -48,43 +48,61 @@ static unsigned short const wXtalkNarrowLeftDelay = 0x7;
48static unsigned short const wXtalkNarrowRightDelay = 0x7; 48static unsigned short const wXtalkNarrowRightDelay = 0x7;
49 49
50static xtalk_gains_t const asXtalkGainsDefault = { 50static xtalk_gains_t const asXtalkGainsDefault = {
51 0x4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 51 0x4000, 0x4000, 0x4000, 0x4000, 0x4000,
52 0x4000 52 0x4000, 0x4000, 0x4000, 0x4000, 0x4000
53}; 53};
54 54
55static xtalk_gains_t const asXtalkGainsTest = { 55static xtalk_gains_t const asXtalkGainsTest = {
56 0x8000, 0x7FFF, 0, 0xFFFF, 0x0001, 0xC000, 0x4000, 0xFFFE, 0x0002, 56 0x7fff, 0x8000, 0x0000, 0x0000, 0x0001,
57 0 57 0xffff, 0x4000, 0xc000, 0x0002, 0xfffe
58}; 58};
59
59static xtalk_gains_t const asXtalkGains1Chan = { 60static xtalk_gains_t const asXtalkGains1Chan = {
60 0x7FFF, 0, 0, 0, 0x7FFF, 0, 0, 0, 0, 0 61 0x7FFF, 0, 0, 0, 0,
62 0x7FFF, 0, 0, 0, 0,
61}; 63};
62 64
63// Input gain for 4 A3D slices. One possible input pair is left zero. 65// Input gain for 4 A3D slices. One possible input pair is left zero.
64static xtalk_gains_t const asXtalkGainsAllChan = { 66static xtalk_gains_t const asXtalkGainsAllChan = {
65 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 67 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0,
66 0 68 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0
67 //0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff,0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff 69};
70
71static xtalk_gains_t const asXtalkGainsZeros = {
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
68}; 73};
69static xtalk_gains_t const asXtalkGainsZeros;
70 74
71static xtalk_dline_t const alXtalkDlineZeros; 75static xtalk_dline_t const alXtalkDlineZeros = {
76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
78};
72static xtalk_dline_t const alXtalkDlineTest = { 79static xtalk_dline_t const alXtalkDlineTest = {
73 0xFC18, 0x03E8FFFF, 0x186A0, 0x7960FFFE, 1, 0xFFFFFFFF, 80 0x0000fc18, 0xfff03e8, 0x000186a0, 0xfffe7960, 1, 0xffffffff, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
82 0, 0, 0, 0, 0, 0, 0, 0
83};
84
85static xtalk_instate_t const asXtalkInStateZeros = {
75 0, 0, 0, 0 86 0, 0, 0, 0
76}; 87};
77 88
78static xtalk_instate_t const asXtalkInStateZeros; 89static xtalk_instate_t const asXtalkInStateTest = {
79static xtalk_instate_t const asXtalkInStateTest = 90 0x0080, 0xff80, 0x0001, 0xffff
80 { 0xFF80, 0x0080, 0xFFFF, 0x0001 }; 91};
81static xtalk_state_t const asXtalkOutStateZeros; 92
93static xtalk_state_t const asXtalkOutStateZeros = {
94 {0, 0, 0, 0},
95 {0, 0, 0, 0},
96 {0, 0, 0, 0},
97 {0, 0, 0, 0},
98 {0, 0, 0, 0}
99};
82 100
83static short const sDiamondKLeftEq = 0x401d; 101static short const sDiamondKLeftEq = 0x401d;
84static short const sDiamondKRightEq = 0x401d; 102static short const sDiamondKRightEq = 0x401d;
85static short const sDiamondKLeftXt = 0xF90E; 103static short const sDiamondKLeftXt = 0xF90E;
86static short const sDiamondKRightXt = 0xF90E; 104static short const sDiamondKRightXt = 0xF90E;
87static short const sDiamondShiftLeftEq = 1; /* 0xF90E Is this a bug ??? */ 105static short const sDiamondShiftLeftEq = 1;
88static short const sDiamondShiftRightEq = 1; 106static short const sDiamondShiftRightEq = 1;
89static short const sDiamondShiftLeftXt = 0; 107static short const sDiamondShiftLeftXt = 0;
90static short const sDiamondShiftRightXt = 0; 108static short const sDiamondShiftRightXt = 0;
@@ -94,29 +112,29 @@ static unsigned short const wDiamondRightDelay = 0xb;
94static xtalk_coefs_t const asXtalkWideCoefsLeftEq = { 112static xtalk_coefs_t const asXtalkWideCoefsLeftEq = {
95 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0}, 113 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
96 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0}, 114 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
97 {0x340B, 0xf504, 0x6CE8, 0x0D23, 0x00E4}, 115 {0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
98 {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA}, 116 {0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
99 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0} 117 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
100}; 118};
101static xtalk_coefs_t const asXtalkWideCoefsRightEq = { 119static xtalk_coefs_t const asXtalkWideCoefsRightEq = {
102 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0}, 120 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
103 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0}, 121 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
104 {0x340B, 0xF504, 0x6CE8, 0x0D23, 0x00E4}, 122 {0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
105 {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA}, 123 {0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
106 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0} 124 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
107}; 125};
108static xtalk_coefs_t const asXtalkWideCoefsLeftXt = { 126static xtalk_coefs_t const asXtalkWideCoefsLeftXt = {
109 {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047}, 127 {0x55c6, 0xc97b, 0x005b, 0x0047, 0},
110 {0x6000, 0x206A, 0xC6CA, 0x40FF, 0}, 128 {0x6a60, 0xca20, 0xffc6, 0x0040, 0},
111 {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001}, 129 {0x6411, 0xd711, 0xfca1, 0x0190, 0},
112 {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0}, 130 {0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
113 {0, 0, 0, 0, 0} 131 {0, 0, 0, 0, 0}
114}; 132};
115static xtalk_coefs_t const asXtalkWideCoefsRightXt = { 133static xtalk_coefs_t const asXtalkWideCoefsRightXt = {
116 {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047}, 134 {0x55c6, 0xc97b, 0x005b, 0x0047, 0},
117 {0x6000, 0x206A, 0xC6CA, 0x40FF, 0}, 135 {0x6a60, 0xca20, 0xffc6, 0x0040, 0},
118 {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001}, 136 {0x6411, 0xd711, 0xfca1, 0x0190, 0},
119 {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0}, 137 {0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
120 {0, 0, 0, 0, 0} 138 {0, 0, 0, 0, 0}
121}; 139};
122static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = { 140static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = {
@@ -151,7 +169,14 @@ static xtalk_coefs_t const asXtalkNarrowCoefsRightXt = {
151 {0, 0, 0, 0, 0} 169 {0, 0, 0, 0, 0}
152}; 170};
153 171
154static xtalk_coefs_t const asXtalkCoefsZeros; 172static xtalk_coefs_t const asXtalkCoefsZeros = {
173 {0, 0, 0, 0, 0},
174 {0, 0, 0, 0, 0},
175 {0, 0, 0, 0, 0},
176 {0, 0, 0, 0, 0},
177 {0, 0, 0, 0, 0}
178};
179
155static xtalk_coefs_t const asXtalkCoefsPipe = { 180static xtalk_coefs_t const asXtalkCoefsPipe = {
156 {0, 0, 0x0FA0, 0, 0}, 181 {0, 0, 0x0FA0, 0, 0},
157 {0, 0, 0x0FA0, 0, 0}, 182 {0, 0, 0x0FA0, 0, 0},
@@ -186,7 +211,7 @@ static xtalk_coefs_t const asXtalkCoefsDenTest = {
186static xtalk_state_t const asXtalkOutStateTest = { 211static xtalk_state_t const asXtalkOutStateTest = {
187 {0x7FFF, 0x0004, 0xFFFC, 0}, 212 {0x7FFF, 0x0004, 0xFFFC, 0},
188 {0xFE00, 0x0008, 0xFFF8, 0x4000}, 213 {0xFE00, 0x0008, 0xFFF8, 0x4000},
189 {0x200, 0x0010, 0xFFF0, 0xC000}, 214 {0x0200, 0x0010, 0xFFF0, 0xC000},
190 {0x8000, 0x0020, 0xFFE0, 0}, 215 {0x8000, 0x0020, 0xFFE0, 0},
191 {0, 0, 0, 0} 216 {0, 0, 0, 0}
192}; 217};
@@ -306,10 +331,10 @@ vortex_XtalkHw_SetLeftEQStates(vortex_t * vortex,
306 hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]); 331 hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]);
307 hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]); 332 hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]);
308 } 333 }
309 hwwrite(vortex->mmio, 0x244F8 + i * 0x24, arg_0[0]); 334 hwwrite(vortex->mmio, 0x244F8, arg_0[0]);
310 hwwrite(vortex->mmio, 0x244FC + i * 0x24, arg_0[1]); 335 hwwrite(vortex->mmio, 0x244FC, arg_0[1]);
311 hwwrite(vortex->mmio, 0x24500 + i * 0x24, arg_0[2]); 336 hwwrite(vortex->mmio, 0x24500, arg_0[2]);
312 hwwrite(vortex->mmio, 0x24504 + i * 0x24, arg_0[3]); 337 hwwrite(vortex->mmio, 0x24504, arg_0[3]);
313} 338}
314 339
315static void 340static void
@@ -325,10 +350,10 @@ vortex_XtalkHw_SetRightEQStates(vortex_t * vortex,
325 hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]); 350 hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]);
326 hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]); 351 hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]);
327 } 352 }
328 hwwrite(vortex->mmio, 0x24508 + i * 0x24, arg_0[0]); 353 hwwrite(vortex->mmio, 0x24508, arg_0[0]);
329 hwwrite(vortex->mmio, 0x2450C + i * 0x24, arg_0[1]); 354 hwwrite(vortex->mmio, 0x2450C, arg_0[1]);
330 hwwrite(vortex->mmio, 0x24510 + i * 0x24, arg_0[2]); 355 hwwrite(vortex->mmio, 0x24510, arg_0[2]);
331 hwwrite(vortex->mmio, 0x24514 + i * 0x24, arg_0[3]); 356 hwwrite(vortex->mmio, 0x24514, arg_0[3]);
332} 357}
333 358
334static void 359static void
@@ -344,10 +369,10 @@ vortex_XtalkHw_SetLeftXTStates(vortex_t * vortex,
344 hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]); 369 hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]);
345 hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]); 370 hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]);
346 } 371 }
347 hwwrite(vortex->mmio, 0x24518 + i * 0x24, arg_0[0]); 372 hwwrite(vortex->mmio, 0x24518, arg_0[0]);
348 hwwrite(vortex->mmio, 0x2451C + i * 0x24, arg_0[1]); 373 hwwrite(vortex->mmio, 0x2451C, arg_0[1]);
349 hwwrite(vortex->mmio, 0x24520 + i * 0x24, arg_0[2]); 374 hwwrite(vortex->mmio, 0x24520, arg_0[2]);
350 hwwrite(vortex->mmio, 0x24524 + i * 0x24, arg_0[3]); 375 hwwrite(vortex->mmio, 0x24524, arg_0[3]);
351} 376}
352 377
353static void 378static void
@@ -363,10 +388,10 @@ vortex_XtalkHw_SetRightXTStates(vortex_t * vortex,
363 hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]); 388 hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]);
364 hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]); 389 hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]);
365 } 390 }
366 hwwrite(vortex->mmio, 0x24528 + i * 0x24, arg_0[0]); 391 hwwrite(vortex->mmio, 0x24528, arg_0[0]);
367 hwwrite(vortex->mmio, 0x2452C + i * 0x24, arg_0[1]); 392 hwwrite(vortex->mmio, 0x2452C, arg_0[1]);
368 hwwrite(vortex->mmio, 0x24530 + i * 0x24, arg_0[2]); 393 hwwrite(vortex->mmio, 0x24530, arg_0[2]);
369 hwwrite(vortex->mmio, 0x24534 + i * 0x24, arg_0[3]); 394 hwwrite(vortex->mmio, 0x24534, arg_0[3]);
370} 395}
371 396
372#if 0 397#if 0
@@ -450,10 +475,10 @@ vortex_XtalkHw_GetLeftEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
450 coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24); 475 coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24);
451 coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24); 476 coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24);
452 } 477 }
453 arg_0[0] = hwread(vortex->mmio, 0x244F8 + i * 0x24); 478 arg_0[0] = hwread(vortex->mmio, 0x244F8);
454 arg_0[1] = hwread(vortex->mmio, 0x244FC + i * 0x24); 479 arg_0[1] = hwread(vortex->mmio, 0x244FC);
455 arg_0[2] = hwread(vortex->mmio, 0x24500 + i * 0x24); 480 arg_0[2] = hwread(vortex->mmio, 0x24500);
456 arg_0[3] = hwread(vortex->mmio, 0x24504 + i * 0x24); 481 arg_0[3] = hwread(vortex->mmio, 0x24504);
457} 482}
458 483
459static void 484static void
@@ -468,10 +493,10 @@ vortex_XtalkHw_GetRightEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
468 coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24); 493 coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24);
469 coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24); 494 coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24);
470 } 495 }
471 arg_0[0] = hwread(vortex->mmio, 0x24508 + i * 0x24); 496 arg_0[0] = hwread(vortex->mmio, 0x24508);
472 arg_0[1] = hwread(vortex->mmio, 0x2450C + i * 0x24); 497 arg_0[1] = hwread(vortex->mmio, 0x2450C);
473 arg_0[2] = hwread(vortex->mmio, 0x24510 + i * 0x24); 498 arg_0[2] = hwread(vortex->mmio, 0x24510);
474 arg_0[3] = hwread(vortex->mmio, 0x24514 + i * 0x24); 499 arg_0[3] = hwread(vortex->mmio, 0x24514);
475} 500}
476 501
477static void 502static void
@@ -486,10 +511,10 @@ vortex_XtalkHw_GetLeftXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
486 coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24); 511 coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24);
487 coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24); 512 coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24);
488 } 513 }
489 arg_0[0] = hwread(vortex->mmio, 0x24518 + i * 0x24); 514 arg_0[0] = hwread(vortex->mmio, 0x24518);
490 arg_0[1] = hwread(vortex->mmio, 0x2451C + i * 0x24); 515 arg_0[1] = hwread(vortex->mmio, 0x2451C);
491 arg_0[2] = hwread(vortex->mmio, 0x24520 + i * 0x24); 516 arg_0[2] = hwread(vortex->mmio, 0x24520);
492 arg_0[3] = hwread(vortex->mmio, 0x24524 + i * 0x24); 517 arg_0[3] = hwread(vortex->mmio, 0x24524);
493} 518}
494 519
495static void 520static void
@@ -504,10 +529,10 @@ vortex_XtalkHw_GetRightXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
504 coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24); 529 coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24);
505 coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24); 530 coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24);
506 } 531 }
507 arg_0[0] = hwread(vortex->mmio, 0x24528 + i * 0x24); 532 arg_0[0] = hwread(vortex->mmio, 0x24528);
508 arg_0[1] = hwread(vortex->mmio, 0x2452C + i * 0x24); 533 arg_0[1] = hwread(vortex->mmio, 0x2452C);
509 arg_0[2] = hwread(vortex->mmio, 0x24530 + i * 0x24); 534 arg_0[2] = hwread(vortex->mmio, 0x24530);
510 arg_0[3] = hwread(vortex->mmio, 0x24534 + i * 0x24); 535 arg_0[3] = hwread(vortex->mmio, 0x24534);
511} 536}
512 537
513#endif 538#endif
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index 7a581151db0d..1c5231931462 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -153,7 +153,7 @@ static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
153 ********************************/ 153 ********************************/
154static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 154static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
155static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 155static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
156static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 156static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
157 157
158module_param_array(index, int, NULL, 0444); 158module_param_array(index, int, NULL, 0444);
159MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard."); 159MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard.");
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index bc1e6830b50d..95ffa6a9db6e 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -301,7 +301,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
301module_param_array(id, charp, NULL, 0444); 301module_param_array(id, charp, NULL, 0444);
302MODULE_PARM_DESC(id, "ID string for AZF3328 soundcard."); 302MODULE_PARM_DESC(id, "ID string for AZF3328 soundcard.");
303 303
304static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 304static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
305module_param_array(enable, bool, NULL, 0444); 305module_param_array(enable, bool, NULL, 0444);
306MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard."); 306MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard.");
307 307
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index c1c2d0c1c7f0..62d6163fc9d9 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -42,9 +42,9 @@ MODULE_SUPPORTED_DEVICE("{{Brooktree,Bt878},"
42 42
43static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */ 43static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
45static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 45static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
46static int digital_rate[SNDRV_CARDS]; /* digital input rate */ 46static int digital_rate[SNDRV_CARDS]; /* digital input rate */
47static int load_all; /* allow to load the non-whitelisted cards */ 47static bool load_all; /* allow to load the non-whitelisted cards */
48 48
49module_param_array(index, int, NULL, 0444); 49module_param_array(index, int, NULL, 0444);
50MODULE_PARM_DESC(index, "Index value for Bt87x soundcard"); 50MODULE_PARM_DESC(index, "Index value for Bt87x soundcard");
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index fe99fdeaf15f..08d6ebfe5a61 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -156,7 +156,7 @@ MODULE_SUPPORTED_DEVICE("{{Creative,SB CA0106 chip}}");
156// module parameters (see "Module Parameters") 156// module parameters (see "Module Parameters")
157static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 157static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
158static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 158static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
159static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 159static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
160static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */ 160static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */
161 161
162module_param_array(index, int, NULL, 0444); 162module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 954c9934748a..19b06269adc2 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -54,10 +54,10 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8738},"
54 54
55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
57static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 57static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
58static long mpu_port[SNDRV_CARDS]; 58static long mpu_port[SNDRV_CARDS];
59static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; 59static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
60static int soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; 60static bool soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
61#ifdef SUPPORT_JOYSTICK 61#ifdef SUPPORT_JOYSTICK
62static int joystick_port[SNDRV_CARDS]; 62static int joystick_port[SNDRV_CARDS];
63#endif 63#endif
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index a6c6c5c53af9..a9f368f60df6 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -44,8 +44,8 @@ MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,CS4281}}");
44 44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 47static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
48static int dual_codec[SNDRV_CARDS]; /* dual codec */ 48static bool dual_codec[SNDRV_CARDS]; /* dual codec */
49 49
50module_param_array(index, int, NULL, 0444); 50module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for CS4281 soundcard."); 51MODULE_PARM_DESC(index, "Index value for CS4281 soundcard.");
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index a4ecb40f8507..819d79d0586d 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -46,10 +46,10 @@ MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,Sound Fusion (CS4280)},"
46 46
47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
49static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 49static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
50static int external_amp[SNDRV_CARDS]; 50static bool external_amp[SNDRV_CARDS];
51static int thinkpad[SNDRV_CARDS]; 51static bool thinkpad[SNDRV_CARDS];
52static int mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 52static bool mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
53 53
54module_param_array(index, int, NULL, 0444); 54module_param_array(index, int, NULL, 0444);
55MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard."); 55MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard.");
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
index 958f4949e973..c47cabff2bfa 100644
--- a/sound/pci/cs5530.c
+++ b/sound/pci/cs5530.c
@@ -50,7 +50,14 @@ MODULE_LICENSE("GPL");
50 50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 53static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
54
55module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for CS5530 Audio driver.");
57module_param_array(id, charp, NULL, 0444);
58MODULE_PARM_DESC(id, "ID string for CS5530 Audio driver.");
59module_param_array(enable, bool, NULL, 0444);
60MODULE_PARM_DESC(enable, "Enable CS5530 Audio driver.");
54 61
55struct snd_cs5530 { 62struct snd_cs5530 {
56 struct snd_card *card; 63 struct snd_card *card;
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index b8959d2c804b..a2fb2173e980 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -57,7 +57,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
57 57
58static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 58static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
59static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 59static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
60static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 60static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
61 61
62module_param_array(index, int, NULL, 0444); 62module_param_array(index, int, NULL, 0444);
63MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME); 63MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME);
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c
index e083122ca55a..dbf94b189e75 100644
--- a/sound/pci/cs5535audio/cs5535audio_pcm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pcm.c
@@ -148,7 +148,7 @@ static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au,
148 struct cs5535audio_dma_desc *desc = 148 struct cs5535audio_dma_desc *desc =
149 &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i]; 149 &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i];
150 desc->addr = cpu_to_le32(addr); 150 desc->addr = cpu_to_le32(addr);
151 desc->size = cpu_to_le32(period_bytes); 151 desc->size = cpu_to_le16(period_bytes);
152 desc->ctlreserved = cpu_to_le16(PRD_EOP); 152 desc->ctlreserved = cpu_to_le16(PRD_EOP);
153 desc_addr += sizeof(struct cs5535audio_dma_desc); 153 desc_addr += sizeof(struct cs5535audio_dma_desc);
154 addr += period_bytes; 154 addr += period_bytes;
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index e134b3a5780d..6e77e86307c2 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -437,7 +437,7 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc)
437 437
438 /* Allocate mem for master src resource */ 438 /* Allocate mem for master src resource */
439 if (MEMRD == desc->mode) 439 if (MEMRD == desc->mode)
440 src = kzalloc(sizeof(*src)*desc->multi, GFP_KERNEL); 440 src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
441 else 441 else
442 src = kzalloc(sizeof(*src), GFP_KERNEL); 442 src = kzalloc(sizeof(*src), GFP_KERNEL);
443 443
diff --git a/sound/pci/ctxfi/cttimer.c b/sound/pci/ctxfi/cttimer.c
index 93b0aedc36d4..03fb909085af 100644
--- a/sound/pci/ctxfi/cttimer.c
+++ b/sound/pci/ctxfi/cttimer.c
@@ -15,8 +15,8 @@
15#include "cthardware.h" 15#include "cthardware.h"
16#include "cttimer.h" 16#include "cttimer.h"
17 17
18static int use_system_timer; 18static bool use_system_timer;
19MODULE_PARM_DESC(use_system_timer, "Foce to use system-timer"); 19MODULE_PARM_DESC(use_system_timer, "Force to use system-timer");
20module_param(use_system_timer, bool, S_IRUGO); 20module_param(use_system_timer, bool, S_IRUGO);
21 21
22struct ct_timer_ops { 22struct ct_timer_ops {
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c
index 33931ef5e129..15d95d2bacee 100644
--- a/sound/pci/ctxfi/xfi.c
+++ b/sound/pci/ctxfi/xfi.c
@@ -32,7 +32,7 @@ module_param(multiple, uint, S_IRUGO);
32 32
33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
35static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
36static unsigned int subsystem[SNDRV_CARDS]; 36static unsigned int subsystem[SNDRV_CARDS];
37 37
38module_param_array(index, int, NULL, 0444); 38module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 9fd694c61866..595c11f904bb 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -26,7 +26,7 @@ MODULE_DEVICE_TABLE(pci, snd_echo_ids);
26 26
27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
29static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 29static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
30 30
31module_param_array(index, int, NULL, 0444); 31module_param_array(index, int, NULL, 0444);
32MODULE_PARM_DESC(index, "Index value for " ECHOCARD_NAME " soundcard."); 32MODULE_PARM_DESC(index, "Index value for " ECHOCARD_NAME " soundcard.");
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index eaa198e122c0..790c65d980c8 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -44,13 +44,13 @@ MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
44 44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 47static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
48static int extin[SNDRV_CARDS]; 48static int extin[SNDRV_CARDS];
49static int extout[SNDRV_CARDS]; 49static int extout[SNDRV_CARDS];
50static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4}; 50static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
51static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64}; 51static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
52static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128}; 52static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
53static int enable_ir[SNDRV_CARDS]; 53static bool enable_ir[SNDRV_CARDS];
54static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */ 54static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */
55static uint delay_pcm_irq[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 55static uint delay_pcm_irq[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
56 56
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 6a3e5677f591..754924081d0a 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1480,6 +1480,18 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1480 .spdif_bug = 1, 1480 .spdif_bug = 1,
1481 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1481 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1482 .ac97_chip = 1} , 1482 .ac97_chip = 1} ,
1483 /* 0x20051102 also has SB0350 written on it, treated as Audigy 2 ZS by
1484 Creative's Windows driver */
1485 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20051102,
1486 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350a]",
1487 .id = "Audigy2",
1488 .emu10k2_chip = 1,
1489 .ca0102_chip = 1,
1490 .ca0151_chip = 1,
1491 .spk71 = 1,
1492 .spdif_bug = 1,
1493 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1494 .ac97_chip = 1} ,
1483 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1495 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1484 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]", 1496 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]",
1485 .id = "Audigy2", 1497 .id = "Audigy2",
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 2228be9f30e6..47a651cb6e84 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -50,7 +50,7 @@ MODULE_SUPPORTED_DEVICE("{{Dell Creative Labs,SB Live!}");
50// module parameters (see "Module Parameters") 50// module parameters (see "Module Parameters")
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 53static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
54 54
55module_param_array(index, int, NULL, 0444); 55module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for the EMU10K1X soundcard."); 56MODULE_PARM_DESC(index, "Index value for the EMU10K1X soundcard.");
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index d085ad03efe8..47a245e84190 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -83,12 +83,12 @@ MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI ES1371/73},"
83 83
84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
85static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 85static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
86static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 86static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
87#ifdef SUPPORT_JOYSTICK 87#ifdef SUPPORT_JOYSTICK
88#ifdef CHIP1371 88#ifdef CHIP1371
89static int joystick_port[SNDRV_CARDS]; 89static int joystick_port[SNDRV_CARDS];
90#else 90#else
91static int joystick[SNDRV_CARDS]; 91static bool joystick[SNDRV_CARDS];
92#endif 92#endif
93#endif 93#endif
94#ifdef CHIP1371 94#ifdef CHIP1371
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 04cc21f5d014..53eb76b41108 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -79,7 +79,7 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1938},"
79 79
80static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 80static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
81static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 81static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
82static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 82static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
83 83
84module_param_array(index, int, NULL, 0444); 84module_param_array(index, int, NULL, 0444);
85MODULE_PARM_DESC(index, "Index value for ESS Solo-1 soundcard."); 85MODULE_PARM_DESC(index, "Index value for ESS Solo-1 soundcard.");
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 297a151bdba9..cb557c603a80 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -132,7 +132,7 @@ MODULE_SUPPORTED_DEVICE("{{ESS,Maestro 2e},"
132 132
133static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */ 133static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */
134static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 134static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
135static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 135static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
136static int total_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1024 }; 136static int total_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1024 };
137static int pcm_substreams_p[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4 }; 137static int pcm_substreams_p[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4 };
138static int pcm_substreams_c[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1 }; 138static int pcm_substreams_c[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1 };
@@ -140,7 +140,7 @@ static int clock[SNDRV_CARDS];
140static int use_pm[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 140static int use_pm[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
141static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 141static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
142#ifdef SUPPORT_JOYSTICK 142#ifdef SUPPORT_JOYSTICK
143static int joystick[SNDRV_CARDS]; 143static bool joystick[SNDRV_CARDS];
144#endif 144#endif
145 145
146module_param_array(index, int, NULL, 0444); 146module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index ec05ef5a5abf..9597ef1eccca 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -48,7 +48,7 @@ MODULE_SUPPORTED_DEVICE("{{ForteMedia,FM801},"
48 48
49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
51static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 51static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
52/* 52/*
53 * Enable TEA575x tuner 53 * Enable TEA575x tuner
54 * 1 = MediaForte 256-PCS 54 * 1 = MediaForte 256-PCS
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e44b107fdc75..4562e9de6a1a 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4046,9 +4046,9 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
4046 4046
4047 /* Search for codec ID */ 4047 /* Search for codec ID */
4048 for (q = tbl; q->subvendor; q++) { 4048 for (q = tbl; q->subvendor; q++) {
4049 unsigned long vendorid = (q->subdevice) | (q->subvendor << 16); 4049 unsigned int mask = 0xffff0000 | q->subdevice_mask;
4050 4050 unsigned int id = (q->subdevice | (q->subvendor << 16)) & mask;
4051 if (vendorid == codec->subsystem_id) 4051 if ((codec->subsystem_id & mask) == id)
4052 break; 4052 break;
4053 } 4053 }
4054 4054
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index 7ae7578bdcc0..c1da422e085a 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -347,18 +347,28 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
347 347
348 for (i = 0; i < size; i++) { 348 for (i = 0; i < size; i++) {
349 unsigned int val = hdmi_get_eld_data(codec, nid, i); 349 unsigned int val = hdmi_get_eld_data(codec, nid, i);
350 /*
351 * Graphics driver might be writing to ELD buffer right now.
352 * Just abort. The caller will repoll after a while.
353 */
350 if (!(val & AC_ELDD_ELD_VALID)) { 354 if (!(val & AC_ELDD_ELD_VALID)) {
351 if (!i) {
352 snd_printd(KERN_INFO
353 "HDMI: invalid ELD data\n");
354 ret = -EINVAL;
355 goto error;
356 }
357 snd_printd(KERN_INFO 355 snd_printd(KERN_INFO
358 "HDMI: invalid ELD data byte %d\n", i); 356 "HDMI: invalid ELD data byte %d\n", i);
359 val = 0; 357 ret = -EINVAL;
360 } else 358 goto error;
361 val &= AC_ELDD_ELD_DATA; 359 }
360 val &= AC_ELDD_ELD_DATA;
361 /*
362 * The first byte cannot be zero. This can happen on some DVI
363 * connections. Some Intel chips may also need some 250ms delay
364 * to return non-zero ELD data, even when the graphics driver
365 * correctly writes ELD content before setting ELD_valid bit.
366 */
367 if (!val && !i) {
368 snd_printdd(KERN_INFO "HDMI: 0 ELD data\n");
369 ret = -EINVAL;
370 goto error;
371 }
362 buf[i] = val; 372 buf[i] = val;
363 } 373 }
364 374
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 096507d2ca9a..06fe2c546ee4 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -58,13 +58,13 @@
58 58
59static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 59static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
60static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 60static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
61static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 61static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
62static char *model[SNDRV_CARDS]; 62static char *model[SNDRV_CARDS];
63static int position_fix[SNDRV_CARDS]; 63static int position_fix[SNDRV_CARDS];
64static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; 64static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
65static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; 65static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
66static int probe_only[SNDRV_CARDS]; 66static int probe_only[SNDRV_CARDS];
67static int single_cmd; 67static bool single_cmd;
68static int enable_msi = -1; 68static int enable_msi = -1;
69#ifdef CONFIG_SND_HDA_PATCH_LOADER 69#ifdef CONFIG_SND_HDA_PATCH_LOADER
70static char *patch[SNDRV_CARDS]; 70static char *patch[SNDRV_CARDS];
@@ -116,12 +116,12 @@ MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
116 * this may give more power-saving, but will take longer time to 116 * this may give more power-saving, but will take longer time to
117 * wake up. 117 * wake up.
118 */ 118 */
119static int power_save_controller = 1; 119static bool power_save_controller = 1;
120module_param(power_save_controller, bool, 0644); 120module_param(power_save_controller, bool, 0644);
121MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); 121MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
122#endif 122#endif
123 123
124static int align_buffer_size = 1; 124static bool align_buffer_size = 1;
125module_param(align_buffer_size, bool, 0644); 125module_param(align_buffer_size, bool, 0644);
126MODULE_PARM_DESC(align_buffer_size, 126MODULE_PARM_DESC(align_buffer_size,
127 "Force buffer and period sizes to be multiple of 128 bytes."); 127 "Force buffer and period sizes to be multiple of 128 bytes.");
@@ -2508,7 +2508,6 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2508 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), 2508 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB),
2509 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), 2509 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB),
2510 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), 2510 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB),
2511 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB),
2512 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB), 2511 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB),
2513 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB), 2512 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
2514 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), 2513 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB),
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 2fbab8e29576..70a7abda7e22 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -58,6 +58,8 @@ struct cs_spec {
58 unsigned int gpio_mask; 58 unsigned int gpio_mask;
59 unsigned int gpio_dir; 59 unsigned int gpio_dir;
60 unsigned int gpio_data; 60 unsigned int gpio_data;
61 unsigned int gpio_eapd_hp; /* EAPD GPIO bit for headphones */
62 unsigned int gpio_eapd_speaker; /* EAPD GPIO bit for speakers */
61 63
62 struct hda_pcm pcm_rec[2]; /* PCM information */ 64 struct hda_pcm pcm_rec[2]; /* PCM information */
63 65
@@ -76,6 +78,7 @@ enum {
76 CS420X_MBP53, 78 CS420X_MBP53,
77 CS420X_MBP55, 79 CS420X_MBP55,
78 CS420X_IMAC27, 80 CS420X_IMAC27,
81 CS420X_APPLE,
79 CS420X_AUTO, 82 CS420X_AUTO,
80 CS420X_MODELS 83 CS420X_MODELS
81}; 84};
@@ -928,10 +931,9 @@ static void cs_automute(struct hda_codec *codec)
928 spdif_present ? 0 : PIN_OUT); 931 spdif_present ? 0 : PIN_OUT);
929 } 932 }
930 } 933 }
931 if (spec->board_config == CS420X_MBP53 || 934 if (spec->gpio_eapd_hp) {
932 spec->board_config == CS420X_MBP55 || 935 unsigned int gpio = hp_present ?
933 spec->board_config == CS420X_IMAC27) { 936 spec->gpio_eapd_hp : spec->gpio_eapd_speaker;
934 unsigned int gpio = hp_present ? 0x02 : 0x08;
935 snd_hda_codec_write(codec, 0x01, 0, 937 snd_hda_codec_write(codec, 0x01, 0,
936 AC_VERB_SET_GPIO_DATA, gpio); 938 AC_VERB_SET_GPIO_DATA, gpio);
937 } 939 }
@@ -1276,6 +1278,7 @@ static const char * const cs420x_models[CS420X_MODELS] = {
1276 [CS420X_MBP53] = "mbp53", 1278 [CS420X_MBP53] = "mbp53",
1277 [CS420X_MBP55] = "mbp55", 1279 [CS420X_MBP55] = "mbp55",
1278 [CS420X_IMAC27] = "imac27", 1280 [CS420X_IMAC27] = "imac27",
1281 [CS420X_APPLE] = "apple",
1279 [CS420X_AUTO] = "auto", 1282 [CS420X_AUTO] = "auto",
1280}; 1283};
1281 1284
@@ -1285,7 +1288,13 @@ static const struct snd_pci_quirk cs420x_cfg_tbl[] = {
1285 SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), 1288 SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55),
1286 SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), 1289 SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55),
1287 SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), 1290 SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55),
1288 SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), 1291 /* this conflicts with too many other models */
1292 /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
1293 {} /* terminator */
1294};
1295
1296static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = {
1297 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
1289 {} /* terminator */ 1298 {} /* terminator */
1290}; 1299};
1291 1300
@@ -1367,6 +1376,10 @@ static int patch_cs420x(struct hda_codec *codec)
1367 spec->board_config = 1376 spec->board_config =
1368 snd_hda_check_board_config(codec, CS420X_MODELS, 1377 snd_hda_check_board_config(codec, CS420X_MODELS,
1369 cs420x_models, cs420x_cfg_tbl); 1378 cs420x_models, cs420x_cfg_tbl);
1379 if (spec->board_config < 0)
1380 spec->board_config =
1381 snd_hda_check_board_codec_sid_config(codec,
1382 CS420X_MODELS, NULL, cs420x_codec_cfg_tbl);
1370 if (spec->board_config >= 0) 1383 if (spec->board_config >= 0)
1371 fix_pincfg(codec, spec->board_config, cs_pincfgs); 1384 fix_pincfg(codec, spec->board_config, cs_pincfgs);
1372 1385
@@ -1374,10 +1387,11 @@ static int patch_cs420x(struct hda_codec *codec)
1374 case CS420X_IMAC27: 1387 case CS420X_IMAC27:
1375 case CS420X_MBP53: 1388 case CS420X_MBP53:
1376 case CS420X_MBP55: 1389 case CS420X_MBP55:
1377 /* GPIO1 = headphones */ 1390 case CS420X_APPLE:
1378 /* GPIO3 = speakers */ 1391 spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */
1379 spec->gpio_mask = 0x0a; 1392 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
1380 spec->gpio_dir = 0x0a; 1393 spec->gpio_mask = spec->gpio_dir =
1394 spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
1381 break; 1395 break;
1382 } 1396 }
1383 1397
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 9850c5b481ea..c505fd5d338c 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -69,6 +69,7 @@ struct hdmi_spec_per_pin {
69 struct hda_codec *codec; 69 struct hda_codec *codec;
70 struct hdmi_eld sink_eld; 70 struct hdmi_eld sink_eld;
71 struct delayed_work work; 71 struct delayed_work work;
72 int repoll_count;
72}; 73};
73 74
74struct hdmi_spec { 75struct hdmi_spec {
@@ -748,7 +749,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx,
748 * Unsolicited events 749 * Unsolicited events
749 */ 750 */
750 751
751static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, bool retry); 752static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
752 753
753static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 754static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
754{ 755{
@@ -766,7 +767,7 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
766 if (pin_idx < 0) 767 if (pin_idx < 0)
767 return; 768 return;
768 769
769 hdmi_present_sense(&spec->pins[pin_idx], true); 770 hdmi_present_sense(&spec->pins[pin_idx], 1);
770} 771}
771 772
772static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) 773static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -960,7 +961,7 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
960 return 0; 961 return 0;
961} 962}
962 963
963static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, bool retry) 964static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
964{ 965{
965 struct hda_codec *codec = per_pin->codec; 966 struct hda_codec *codec = per_pin->codec;
966 struct hdmi_eld *eld = &per_pin->sink_eld; 967 struct hdmi_eld *eld = &per_pin->sink_eld;
@@ -989,7 +990,7 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, bool retry)
989 if (eld_valid) { 990 if (eld_valid) {
990 if (!snd_hdmi_get_eld(eld, codec, pin_nid)) 991 if (!snd_hdmi_get_eld(eld, codec, pin_nid))
991 snd_hdmi_show_eld(eld); 992 snd_hdmi_show_eld(eld);
992 else if (retry) { 993 else if (repoll) {
993 queue_delayed_work(codec->bus->workq, 994 queue_delayed_work(codec->bus->workq,
994 &per_pin->work, 995 &per_pin->work,
995 msecs_to_jiffies(300)); 996 msecs_to_jiffies(300));
@@ -1004,7 +1005,10 @@ static void hdmi_repoll_eld(struct work_struct *work)
1004 struct hdmi_spec_per_pin *per_pin = 1005 struct hdmi_spec_per_pin *per_pin =
1005 container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work); 1006 container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
1006 1007
1007 hdmi_present_sense(per_pin, false); 1008 if (per_pin->repoll_count++ > 6)
1009 per_pin->repoll_count = 0;
1010
1011 hdmi_present_sense(per_pin, per_pin->repoll_count);
1008} 1012}
1009 1013
1010static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) 1014static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
@@ -1235,7 +1239,7 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
1235 if (err < 0) 1239 if (err < 0)
1236 return err; 1240 return err;
1237 1241
1238 hdmi_present_sense(per_pin, false); 1242 hdmi_present_sense(per_pin, 0);
1239 return 0; 1243 return 0;
1240} 1244}
1241 1245
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 336d14eb72af..cbde019d3d52 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -277,6 +277,12 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
277 return false; 277 return false;
278} 278}
279 279
280static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
281{
282 return spec->capsrc_nids ?
283 spec->capsrc_nids[idx] : spec->adc_nids[idx];
284}
285
280/* select the given imux item; either unmute exclusively or select the route */ 286/* select the given imux item; either unmute exclusively or select the route */
281static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, 287static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
282 unsigned int idx, bool force) 288 unsigned int idx, bool force)
@@ -303,8 +309,7 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
303 adc_idx = spec->dyn_adc_idx[idx]; 309 adc_idx = spec->dyn_adc_idx[idx];
304 } 310 }
305 311
306 nid = spec->capsrc_nids ? 312 nid = get_capsrc(spec, adc_idx);
307 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
308 313
309 /* no selection? */ 314 /* no selection? */
310 num_conns = snd_hda_get_conn_list(codec, nid, NULL); 315 num_conns = snd_hda_get_conn_list(codec, nid, NULL);
@@ -1054,8 +1059,19 @@ static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
1054 spec->imux_pins[2] = spec->dock_mic_pin; 1059 spec->imux_pins[2] = spec->dock_mic_pin;
1055 for (i = 0; i < 3; i++) { 1060 for (i = 0; i < 3; i++) {
1056 strcpy(imux->items[i].label, texts[i]); 1061 strcpy(imux->items[i].label, texts[i]);
1057 if (spec->imux_pins[i]) 1062 if (spec->imux_pins[i]) {
1063 hda_nid_t pin = spec->imux_pins[i];
1064 int c;
1065 for (c = 0; c < spec->num_adc_nids; c++) {
1066 hda_nid_t cap = get_capsrc(spec, c);
1067 int idx = get_connection_index(codec, cap, pin);
1068 if (idx >= 0) {
1069 imux->items[i].index = idx;
1070 break;
1071 }
1072 }
1058 imux->num_items = i + 1; 1073 imux->num_items = i + 1;
1074 }
1059 } 1075 }
1060 spec->num_mux_defs = 1; 1076 spec->num_mux_defs = 1;
1061 spec->input_mux = imux; 1077 spec->input_mux = imux;
@@ -1957,10 +1973,8 @@ static int alc_build_controls(struct hda_codec *codec)
1957 if (!kctl) 1973 if (!kctl)
1958 kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 1974 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
1959 for (i = 0; kctl && i < kctl->count; i++) { 1975 for (i = 0; kctl && i < kctl->count; i++) {
1960 const hda_nid_t *nids = spec->capsrc_nids; 1976 err = snd_hda_add_nid(codec, kctl, i,
1961 if (!nids) 1977 get_capsrc(spec, i));
1962 nids = spec->adc_nids;
1963 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
1964 if (err < 0) 1978 if (err < 0)
1965 return err; 1979 return err;
1966 } 1980 }
@@ -2747,8 +2761,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
2747 } 2761 }
2748 2762
2749 for (c = 0; c < num_adcs; c++) { 2763 for (c = 0; c < num_adcs; c++) {
2750 hda_nid_t cap = spec->capsrc_nids ? 2764 hda_nid_t cap = get_capsrc(spec, c);
2751 spec->capsrc_nids[c] : spec->adc_nids[c];
2752 idx = get_connection_index(codec, cap, pin); 2765 idx = get_connection_index(codec, cap, pin);
2753 if (idx >= 0) { 2766 if (idx >= 0) {
2754 spec->imux_pins[imux->num_items] = pin; 2767 spec->imux_pins[imux->num_items] = pin;
@@ -3694,8 +3707,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
3694 if (!pin) 3707 if (!pin)
3695 return 0; 3708 return 0;
3696 for (i = 0; i < spec->num_adc_nids; i++) { 3709 for (i = 0; i < spec->num_adc_nids; i++) {
3697 hda_nid_t cap = spec->capsrc_nids ? 3710 hda_nid_t cap = get_capsrc(spec, i);
3698 spec->capsrc_nids[i] : spec->adc_nids[i];
3699 int idx; 3711 int idx;
3700 3712
3701 idx = get_connection_index(codec, cap, pin); 3713 idx = get_connection_index(codec, cap, pin);
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 470f6f286e81..d8d2f9dccd9b 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1641,6 +1641,8 @@ static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1641 "Alienware M17x", STAC_ALIENWARE_M17X), 1641 "Alienware M17x", STAC_ALIENWARE_M17X),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a, 1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1643 "Alienware M17x", STAC_ALIENWARE_M17X), 1643 "Alienware M17x", STAC_ALIENWARE_M17X),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1645 "Alienware M17x", STAC_ALIENWARE_M17X),
1644 {} /* terminator */ 1646 {} /* terminator */
1645}; 1647};
1646 1648
@@ -4439,7 +4441,9 @@ static int stac92xx_init(struct hda_codec *codec)
4439 int pinctl, def_conf; 4441 int pinctl, def_conf;
4440 4442
4441 /* power on when no jack detection is available */ 4443 /* power on when no jack detection is available */
4442 if (!spec->hp_detect) { 4444 /* or when the VREF is used for controlling LED */
4445 if (!spec->hp_detect ||
4446 (spec->gpio_led > 8 && spec->gpio_led == nid)) {
4443 stac_toggle_power_map(codec, nid, 1); 4447 stac_toggle_power_map(codec, nid, 1);
4444 continue; 4448 continue;
4445 } 4449 }
@@ -5053,20 +5057,6 @@ static int stac92xx_pre_resume(struct hda_codec *codec)
5053 return 0; 5057 return 0;
5054} 5058}
5055 5059
5056static int stac92xx_post_suspend(struct hda_codec *codec)
5057{
5058 struct sigmatel_spec *spec = codec->spec;
5059 if (spec->gpio_led > 8) {
5060 /* with vref-out pin used for mute led control
5061 * codec AFG is prevented from D3 state, but on
5062 * system suspend it can (and should) be used
5063 */
5064 snd_hda_codec_read(codec, codec->afg, 0,
5065 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5066 }
5067 return 0;
5068}
5069
5070static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg, 5060static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5071 unsigned int power_state) 5061 unsigned int power_state)
5072{ 5062{
@@ -5666,8 +5656,6 @@ again:
5666 } else { 5656 } else {
5667 codec->patch_ops.set_power_state = 5657 codec->patch_ops.set_power_state =
5668 stac92xx_set_power_state; 5658 stac92xx_set_power_state;
5669 codec->patch_ops.post_suspend =
5670 stac92xx_post_suspend;
5671 } 5659 }
5672 codec->patch_ops.pre_resume = stac92xx_pre_resume; 5660 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5673 codec->patch_ops.check_power_status = 5661 codec->patch_ops.check_power_status =
@@ -5981,8 +5969,6 @@ again:
5981 } else { 5969 } else {
5982 codec->patch_ops.set_power_state = 5970 codec->patch_ops.set_power_state =
5983 stac92xx_set_power_state; 5971 stac92xx_set_power_state;
5984 codec->patch_ops.post_suspend =
5985 stac92xx_post_suspend;
5986 } 5972 }
5987 codec->patch_ops.pre_resume = stac92xx_pre_resume; 5973 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5988 codec->patch_ops.check_power_status = 5974 codec->patch_ops.check_power_status =
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 431c0d417eeb..b5137629f8e9 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -208,6 +208,7 @@ struct via_spec {
208 /* work to check hp jack state */ 208 /* work to check hp jack state */
209 struct hda_codec *codec; 209 struct hda_codec *codec;
210 struct delayed_work vt1708_hp_work; 210 struct delayed_work vt1708_hp_work;
211 int hp_work_active;
211 int vt1708_jack_detect; 212 int vt1708_jack_detect;
212 int vt1708_hp_present; 213 int vt1708_hp_present;
213 214
@@ -305,27 +306,35 @@ enum {
305static void analog_low_current_mode(struct hda_codec *codec); 306static void analog_low_current_mode(struct hda_codec *codec);
306static bool is_aa_path_mute(struct hda_codec *codec); 307static bool is_aa_path_mute(struct hda_codec *codec);
307 308
308static void vt1708_start_hp_work(struct via_spec *spec) 309#define hp_detect_with_aa(codec) \
310 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
311 !is_aa_path_mute(codec))
312
313static void vt1708_stop_hp_work(struct via_spec *spec)
309{ 314{
310 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) 315 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0)
311 return; 316 return;
312 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 317 if (spec->hp_work_active) {
313 !spec->vt1708_jack_detect); 318 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 1);
314 if (!delayed_work_pending(&spec->vt1708_hp_work)) 319 cancel_delayed_work_sync(&spec->vt1708_hp_work);
315 schedule_delayed_work(&spec->vt1708_hp_work, 320 spec->hp_work_active = 0;
316 msecs_to_jiffies(100)); 321 }
317} 322}
318 323
319static void vt1708_stop_hp_work(struct via_spec *spec) 324static void vt1708_update_hp_work(struct via_spec *spec)
320{ 325{
321 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) 326 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0)
322 return; 327 return;
323 if (snd_hda_get_bool_hint(spec->codec, "analog_loopback_hp_detect") == 1 328 if (spec->vt1708_jack_detect &&
324 && !is_aa_path_mute(spec->codec)) 329 (spec->active_streams || hp_detect_with_aa(spec->codec))) {
325 return; 330 if (!spec->hp_work_active) {
326 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 331 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 0);
327 !spec->vt1708_jack_detect); 332 schedule_delayed_work(&spec->vt1708_hp_work,
328 cancel_delayed_work_sync(&spec->vt1708_hp_work); 333 msecs_to_jiffies(100));
334 spec->hp_work_active = 1;
335 }
336 } else if (!hp_detect_with_aa(spec->codec))
337 vt1708_stop_hp_work(spec);
329} 338}
330 339
331static void set_widgets_power_state(struct hda_codec *codec) 340static void set_widgets_power_state(struct hda_codec *codec)
@@ -343,12 +352,7 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol,
343 352
344 set_widgets_power_state(codec); 353 set_widgets_power_state(codec);
345 analog_low_current_mode(snd_kcontrol_chip(kcontrol)); 354 analog_low_current_mode(snd_kcontrol_chip(kcontrol));
346 if (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1) { 355 vt1708_update_hp_work(codec->spec);
347 if (is_aa_path_mute(codec))
348 vt1708_start_hp_work(codec->spec);
349 else
350 vt1708_stop_hp_work(codec->spec);
351 }
352 return change; 356 return change;
353} 357}
354 358
@@ -1154,7 +1158,7 @@ static int via_playback_multi_pcm_prepare(struct hda_pcm_stream *hinfo,
1154 spec->cur_dac_stream_tag = stream_tag; 1158 spec->cur_dac_stream_tag = stream_tag;
1155 spec->cur_dac_format = format; 1159 spec->cur_dac_format = format;
1156 mutex_unlock(&spec->config_mutex); 1160 mutex_unlock(&spec->config_mutex);
1157 vt1708_start_hp_work(spec); 1161 vt1708_update_hp_work(spec);
1158 return 0; 1162 return 0;
1159} 1163}
1160 1164
@@ -1174,7 +1178,7 @@ static int via_playback_hp_pcm_prepare(struct hda_pcm_stream *hinfo,
1174 spec->cur_hp_stream_tag = stream_tag; 1178 spec->cur_hp_stream_tag = stream_tag;
1175 spec->cur_hp_format = format; 1179 spec->cur_hp_format = format;
1176 mutex_unlock(&spec->config_mutex); 1180 mutex_unlock(&spec->config_mutex);
1177 vt1708_start_hp_work(spec); 1181 vt1708_update_hp_work(spec);
1178 return 0; 1182 return 0;
1179} 1183}
1180 1184
@@ -1188,7 +1192,7 @@ static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream *hinfo,
1188 snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 1192 snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1189 spec->active_streams &= ~STREAM_MULTI_OUT; 1193 spec->active_streams &= ~STREAM_MULTI_OUT;
1190 mutex_unlock(&spec->config_mutex); 1194 mutex_unlock(&spec->config_mutex);
1191 vt1708_stop_hp_work(spec); 1195 vt1708_update_hp_work(spec);
1192 return 0; 1196 return 0;
1193} 1197}
1194 1198
@@ -1203,7 +1207,7 @@ static int via_playback_hp_pcm_cleanup(struct hda_pcm_stream *hinfo,
1203 snd_hda_codec_setup_stream(codec, spec->hp_dac_nid, 0, 0, 0); 1207 snd_hda_codec_setup_stream(codec, spec->hp_dac_nid, 0, 0, 0);
1204 spec->active_streams &= ~STREAM_INDEP_HP; 1208 spec->active_streams &= ~STREAM_INDEP_HP;
1205 mutex_unlock(&spec->config_mutex); 1209 mutex_unlock(&spec->config_mutex);
1206 vt1708_stop_hp_work(spec); 1210 vt1708_update_hp_work(spec);
1207 return 0; 1211 return 0;
1208} 1212}
1209 1213
@@ -1645,7 +1649,8 @@ static void via_hp_automute(struct hda_codec *codec)
1645 int nums; 1649 int nums;
1646 struct via_spec *spec = codec->spec; 1650 struct via_spec *spec = codec->spec;
1647 1651
1648 if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0]) 1652 if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0] &&
1653 (spec->codec_type != VT1708 || spec->vt1708_jack_detect))
1649 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); 1654 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
1650 1655
1651 if (spec->smart51_enabled) 1656 if (spec->smart51_enabled)
@@ -2612,8 +2617,6 @@ static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
2612 2617
2613 if (spec->codec_type != VT1708) 2618 if (spec->codec_type != VT1708)
2614 return 0; 2619 return 0;
2615 spec->vt1708_jack_detect =
2616 !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1);
2617 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; 2620 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
2618 return 0; 2621 return 0;
2619} 2622}
@@ -2623,18 +2626,22 @@ static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
2623{ 2626{
2624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2625 struct via_spec *spec = codec->spec; 2628 struct via_spec *spec = codec->spec;
2626 int change; 2629 int val;
2627 2630
2628 if (spec->codec_type != VT1708) 2631 if (spec->codec_type != VT1708)
2629 return 0; 2632 return 0;
2630 spec->vt1708_jack_detect = ucontrol->value.integer.value[0]; 2633 val = !!ucontrol->value.integer.value[0];
2631 change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) 2634 if (spec->vt1708_jack_detect == val)
2632 == !spec->vt1708_jack_detect; 2635 return 0;
2633 if (spec->vt1708_jack_detect) { 2636 spec->vt1708_jack_detect = val;
2637 if (spec->vt1708_jack_detect &&
2638 snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") != 1) {
2634 mute_aa_path(codec, 1); 2639 mute_aa_path(codec, 1);
2635 notify_aa_path_ctls(codec); 2640 notify_aa_path_ctls(codec);
2636 } 2641 }
2637 return change; 2642 via_hp_automute(codec);
2643 vt1708_update_hp_work(spec);
2644 return 1;
2638} 2645}
2639 2646
2640static const struct snd_kcontrol_new vt1708_jack_detect_ctl = { 2647static const struct snd_kcontrol_new vt1708_jack_detect_ctl = {
@@ -2771,6 +2778,7 @@ static int via_init(struct hda_codec *codec)
2771 via_auto_init_unsol_event(codec); 2778 via_auto_init_unsol_event(codec);
2772 2779
2773 via_hp_automute(codec); 2780 via_hp_automute(codec);
2781 vt1708_update_hp_work(spec);
2774 2782
2775 return 0; 2783 return 0;
2776} 2784}
@@ -2787,7 +2795,9 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
2787 spec->vt1708_hp_present ^= 1; 2795 spec->vt1708_hp_present ^= 1;
2788 via_hp_automute(spec->codec); 2796 via_hp_automute(spec->codec);
2789 } 2797 }
2790 vt1708_start_hp_work(spec); 2798 if (spec->vt1708_jack_detect)
2799 schedule_delayed_work(&spec->vt1708_hp_work,
2800 msecs_to_jiffies(100));
2791} 2801}
2792 2802
2793static int get_mux_nids(struct hda_codec *codec) 2803static int get_mux_nids(struct hda_codec *codec)
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index e328cfb7620c..e525da2673be 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -68,8 +68,11 @@ static int __devinit snd_vt1724_amp_init(struct snd_ice1712 *ice)
68 68
69static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice) 69static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
70{ 70{
71 /* we use pins 39 and 41 of the VT1616 for left and right read outputs */ 71 if (ice->ac97)
72 snd_ac97_write_cache(ice->ac97, 0x5a, snd_ac97_read(ice->ac97, 0x5a) & ~0x8000); 72 /* we use pins 39 and 41 of the VT1616 for left and right
73 read outputs */
74 snd_ac97_write_cache(ice->ac97, 0x5a,
75 snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
73 return 0; 76 return 0;
74} 77}
75 78
diff --git a/sound/pci/ice1712/envy24ht.h b/sound/pci/ice1712/envy24ht.h
index a0c5e009bb4a..4ca33a800bc8 100644
--- a/sound/pci/ice1712/envy24ht.h
+++ b/sound/pci/ice1712/envy24ht.h
@@ -66,6 +66,7 @@ enum {
66#define VT1724_CFG_CLOCK384 0x40 /* 16.9344Mhz, 44.1kHz*384 */ 66#define VT1724_CFG_CLOCK384 0x40 /* 16.9344Mhz, 44.1kHz*384 */
67#define VT1724_CFG_MPU401 0x20 /* MPU401 UARTs */ 67#define VT1724_CFG_MPU401 0x20 /* MPU401 UARTs */
68#define VT1724_CFG_ADC_MASK 0x0c /* one, two or one and S/PDIF, stereo ADCs */ 68#define VT1724_CFG_ADC_MASK 0x0c /* one, two or one and S/PDIF, stereo ADCs */
69#define VT1724_CFG_ADC_NONE 0x0c /* no ADCs */
69#define VT1724_CFG_DAC_MASK 0x03 /* one, two, three, four stereo DACs */ 70#define VT1724_CFG_DAC_MASK 0x03 /* one, two, three, four stereo DACs */
70 71
71#define VT1724_REG_AC97_CFG 0x05 /* byte */ 72#define VT1724_REG_AC97_CFG 0x05 /* byte */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 44446f2222d9..132a86e09d07 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -84,9 +84,9 @@ MODULE_SUPPORTED_DEVICE("{"
84 84
85static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 85static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
86static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 86static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
87static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 87static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
88static char *model[SNDRV_CARDS]; 88static char *model[SNDRV_CARDS];
89static int omni[SNDRV_CARDS]; /* Delta44 & 66 Omni I/O support */ 89static bool omni[SNDRV_CARDS]; /* Delta44 & 66 Omni I/O support */
90static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transceiver reset timeout value in msec */ 90static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transceiver reset timeout value in msec */
91static int dxr_enable[SNDRV_CARDS]; /* DXR enable for DMX6FIRE */ 91static int dxr_enable[SNDRV_CARDS]; /* DXR enable for DMX6FIRE */
92 92
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 4353e76bf0a6..92362973764d 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -80,7 +80,7 @@ MODULE_SUPPORTED_DEVICE("{"
80 80
81static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 81static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
82static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 82static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
83static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 83static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
84static char *model[SNDRV_CARDS]; 84static char *model[SNDRV_CARDS];
85 85
86module_param_array(index, int, NULL, 0444); 86module_param_array(index, int, NULL, 0444);
@@ -1117,14 +1117,21 @@ static struct snd_pcm_ops snd_vt1724_capture_pro_ops = {
1117static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device) 1117static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device)
1118{ 1118{
1119 struct snd_pcm *pcm; 1119 struct snd_pcm *pcm;
1120 int err; 1120 int capt, err;
1121 1121
1122 err = snd_pcm_new(ice->card, "ICE1724", device, 1, 1, &pcm); 1122 if ((ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_ADC_MASK) ==
1123 VT1724_CFG_ADC_NONE)
1124 capt = 0;
1125 else
1126 capt = 1;
1127 err = snd_pcm_new(ice->card, "ICE1724", device, 1, capt, &pcm);
1123 if (err < 0) 1128 if (err < 0)
1124 return err; 1129 return err;
1125 1130
1126 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_vt1724_playback_pro_ops); 1131 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_vt1724_playback_pro_ops);
1127 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_vt1724_capture_pro_ops); 1132 if (capt)
1133 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1134 &snd_vt1724_capture_pro_ops);
1128 1135
1129 pcm->private_data = ice; 1136 pcm->private_data = ice;
1130 pcm->info_flags = 0; 1137 pcm->info_flags = 0;
@@ -1825,7 +1832,12 @@ static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
1825 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1832 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1826 uinfo->count = 1; 1833 uinfo->count = 1;
1827 1834
1828 uinfo->value.enumerated.items = hw_rates_count + ice->ext_clock_count; 1835 /* internal clocks */
1836 uinfo->value.enumerated.items = hw_rates_count;
1837 /* external clocks */
1838 if (ice->force_rdma1 ||
1839 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_IN))
1840 uinfo->value.enumerated.items += ice->ext_clock_count;
1829 /* upper limit - keep at top */ 1841 /* upper limit - keep at top */
1830 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1842 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1831 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1843 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
@@ -2173,6 +2185,40 @@ static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
2173 2185
2174static struct snd_ice1712_card_info no_matched __devinitdata; 2186static struct snd_ice1712_card_info no_matched __devinitdata;
2175 2187
2188
2189/*
2190 ooAoo cards with no controls
2191*/
2192static unsigned char ooaoo_sq210_eeprom[] __devinitdata = {
2193 [ICE_EEP2_SYSCONF] = 0x4c, /* 49MHz crystal, no mpu401, no ADC,
2194 1xDACs */
2195 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2196 [ICE_EEP2_I2S] = 0x78, /* no volume, 96k, 24bit, 192k */
2197 [ICE_EEP2_SPDIF] = 0xc1, /* out-en, out-int, out-ext */
2198 [ICE_EEP2_GPIO_DIR] = 0x00, /* no GPIOs are used */
2199 [ICE_EEP2_GPIO_DIR1] = 0x00,
2200 [ICE_EEP2_GPIO_DIR2] = 0x00,
2201 [ICE_EEP2_GPIO_MASK] = 0xff,
2202 [ICE_EEP2_GPIO_MASK1] = 0xff,
2203 [ICE_EEP2_GPIO_MASK2] = 0xff,
2204
2205 [ICE_EEP2_GPIO_STATE] = 0x00, /* inputs */
2206 [ICE_EEP2_GPIO_STATE1] = 0x00, /* all 1, but GPIO_CPLD_RW
2207 and GPIO15 always zero */
2208 [ICE_EEP2_GPIO_STATE2] = 0x00, /* inputs */
2209};
2210
2211
2212struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] __devinitdata = {
2213 {
2214 .name = "ooAoo SQ210a",
2215 .model = "sq210a",
2216 .eeprom_size = sizeof(ooaoo_sq210_eeprom),
2217 .eeprom_data = ooaoo_sq210_eeprom,
2218 },
2219 { } /* terminator */
2220};
2221
2176static struct snd_ice1712_card_info *card_tables[] __devinitdata = { 2222static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2177 snd_vt1724_revo_cards, 2223 snd_vt1724_revo_cards,
2178 snd_vt1724_amp_cards, 2224 snd_vt1724_amp_cards,
@@ -2187,6 +2233,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2187 snd_vt1724_wtm_cards, 2233 snd_vt1724_wtm_cards,
2188 snd_vt1724_se_cards, 2234 snd_vt1724_se_cards,
2189 snd_vt1724_qtet_cards, 2235 snd_vt1724_qtet_cards,
2236 snd_vt1724_ooaoo_cards,
2190 NULL, 2237 NULL,
2191}; 2238};
2192 2239
@@ -2270,7 +2317,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2270 } 2317 }
2271 } 2318 }
2272 for (tbl = card_tables; *tbl; tbl++) { 2319 for (tbl = card_tables; *tbl; tbl++) {
2273 for (c = *tbl; c->subvendor; c++) { 2320 for (c = *tbl; c->name; c++) {
2274 if (modelname && c->model && 2321 if (modelname && c->model &&
2275 !strcmp(modelname, c->model)) { 2322 !strcmp(modelname, c->model)) {
2276 printk(KERN_INFO "ice1724: Using board model %s\n", 2323 printk(KERN_INFO "ice1724: Using board model %s\n",
@@ -2579,8 +2626,10 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2579 ice->ext_clock_count = 0; 2626 ice->ext_clock_count = 0;
2580 2627
2581 for (tbl = card_tables; *tbl; tbl++) { 2628 for (tbl = card_tables; *tbl; tbl++) {
2582 for (c = *tbl; c->subvendor; c++) { 2629 for (c = *tbl; c->name; c++) {
2583 if (c->subvendor == ice->eeprom.subvendor) { 2630 if ((model[dev] && c->model &&
2631 !strcmp(model[dev], c->model)) ||
2632 (c->subvendor == ice->eeprom.subvendor)) {
2584 strcpy(card->shortname, c->name); 2633 strcpy(card->shortname, c->name);
2585 if (c->driver) /* specific driver? */ 2634 if (c->driver) /* specific driver? */
2586 strcpy(card->driver, c->driver); 2635 strcpy(card->driver, c->driver);
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 11718b49b2e2..40b181bab930 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -79,9 +79,9 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
79static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 79static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
80static int ac97_clock; 80static int ac97_clock;
81static char *ac97_quirk; 81static char *ac97_quirk;
82static int buggy_semaphore; 82static bool buggy_semaphore;
83static int buggy_irq = -1; /* auto-check */ 83static int buggy_irq = -1; /* auto-check */
84static int xbox; 84static bool xbox;
85static int spdif_aclink = -1; 85static int spdif_aclink = -1;
86static int inside_vm = -1; 86static int inside_vm = -1;
87 87
@@ -105,7 +105,7 @@ module_param(inside_vm, bool, 0444);
105MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization."); 105MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
106 106
107/* just for backward compatibility */ 107/* just for backward compatibility */
108static int enable; 108static bool enable;
109module_param(enable, bool, 0444); 109module_param(enable, bool, 0444);
110static int joystick; 110static int joystick;
111module_param(joystick, int, 0444); 111module_param(joystick, int, 0444);
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 0f7041ec7ddc..d689913a61be 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -68,7 +68,7 @@ module_param(ac97_clock, int, 0444);
68MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); 68MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
69 69
70/* just for backward compatibility */ 70/* just for backward compatibility */
71static int enable; 71static bool enable;
72module_param(enable, bool, 0444); 72module_param(enable, bool, 0444);
73 73
74/* 74/*
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 841864b6b371..8fea45ab5882 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -408,7 +408,7 @@ MODULE_FIRMWARE("korg/k1212.dsp");
408 408
409static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 409static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
410static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 410static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
411static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 411static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
412 412
413module_param_array(index, int, NULL, 0444); 413module_param_array(index, int, NULL, 0444);
414MODULE_PARM_DESC(index, "Index value for Korg 1212 soundcard."); 414MODULE_PARM_DESC(index, "Index value for Korg 1212 soundcard.");
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 924168ef1ed6..375982736858 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -35,7 +35,7 @@
35/* Standard options */ 35/* Standard options */
36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
38static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 38static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
39 39
40module_param_array(index, int, NULL, 0444); 40module_param_array(index, int, NULL, 0444);
41MODULE_PARM_DESC(index, "Index value for Digigram Lola driver."); 41MODULE_PARM_DESC(index, "Index value for Digigram Lola driver.");
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 04ae84b2a107..d94c0c292bd0 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -42,7 +42,7 @@ MODULE_SUPPORTED_DEVICE("{digigram lx6464es{}}");
42 42
43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
45static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 45static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
46 46
47module_param_array(index, int, NULL, 0444); 47module_param_array(index, int, NULL, 0444);
48MODULE_PARM_DESC(index, "Index value for Digigram LX6464ES interface."); 48MODULE_PARM_DESC(index, "Index value for Digigram LX6464ES interface.");
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
index 5c8717e29eeb..8c3e7fcefd99 100644
--- a/sound/pci/lx6464es/lx_core.c
+++ b/sound/pci/lx6464es/lx_core.c
@@ -78,10 +78,15 @@ unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port)
78 return ioread32(address); 78 return ioread32(address);
79} 79}
80 80
81void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data, u32 len) 81static void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data,
82 u32 len)
82{ 83{
83 void __iomem *address = lx_dsp_register(chip, port); 84 u32 __iomem *address = lx_dsp_register(chip, port);
84 memcpy_fromio(data, address, len*sizeof(u32)); 85 int i;
86
87 /* we cannot use memcpy_fromio */
88 for (i = 0; i != len; ++i)
89 data[i] = ioread32(address + i);
85} 90}
86 91
87 92
@@ -91,11 +96,15 @@ void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data)
91 iowrite32(data, address); 96 iowrite32(data, address);
92} 97}
93 98
94void lx_dsp_reg_writebuf(struct lx6464es *chip, int port, const u32 *data, 99static void lx_dsp_reg_writebuf(struct lx6464es *chip, int port,
95 u32 len) 100 const u32 *data, u32 len)
96{ 101{
97 void __iomem *address = lx_dsp_register(chip, port); 102 u32 __iomem *address = lx_dsp_register(chip, port);
98 memcpy_toio(address, data, len*sizeof(u32)); 103 int i;
104
105 /* we cannot use memcpy_to */
106 for (i = 0; i != len; ++i)
107 iowrite32(data[i], address + i);
99} 108}
100 109
101 110
diff --git a/sound/pci/lx6464es/lx_core.h b/sound/pci/lx6464es/lx_core.h
index 1dd562980b6c..4d7ff797a646 100644
--- a/sound/pci/lx6464es/lx_core.h
+++ b/sound/pci/lx6464es/lx_core.h
@@ -72,10 +72,7 @@ enum {
72}; 72};
73 73
74unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port); 74unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port);
75void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data, u32 len);
76void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data); 75void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data);
77void lx_dsp_reg_writebuf(struct lx6464es *chip, int port, const u32 *data,
78 u32 len);
79 76
80/* plx register access */ 77/* plx register access */
81enum { 78enum {
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 863c8bdaecd6..78229b0dad2b 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -64,8 +64,8 @@ MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
64 64
65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
67static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */ 67static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */
68static int external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 68static bool external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
69static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; 69static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
70 70
71module_param_array(index, int, NULL, 0444); 71module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index a0bd1d99793f..487837c01c9f 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -49,7 +49,7 @@ MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
49 49
50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
51static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 51static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
52static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 52static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
53 53
54module_param_array(index, int, NULL, 0444); 54module_param_array(index, int, NULL, 0444);
55MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard."); 55MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index c6c45d979f7a..ade2c64bd606 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -57,12 +57,12 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index */
57static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 57static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
58static int playback_bufsize = 16; 58static int playback_bufsize = 16;
59static int capture_bufsize = 16; 59static int capture_bufsize = 16;
60static int force_ac97; /* disabled as default */ 60static bool force_ac97; /* disabled as default */
61static int buffer_top; /* not specified */ 61static int buffer_top; /* not specified */
62static int use_cache; /* disabled */ 62static bool use_cache; /* disabled */
63static int vaio_hack; /* disabled */ 63static bool vaio_hack; /* disabled */
64static int reset_workaround; 64static bool reset_workaround;
65static int reset_workaround_2; 65static bool reset_workaround_2;
66 66
67module_param(index, int, 0444); 67module_param(index, int, 0444);
68MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 68MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
@@ -86,7 +86,7 @@ module_param(reset_workaround_2, bool, 0444);
86MODULE_PARM_DESC(reset_workaround_2, "Enable extended AC97 RESET workaround for some other laptops."); 86MODULE_PARM_DESC(reset_workaround_2, "Enable extended AC97 RESET workaround for some other laptops.");
87 87
88/* just for backward compatibility */ 88/* just for backward compatibility */
89static int enable; 89static bool enable;
90module_param(enable, bool, 0444); 90module_param(enable, bool, 0444);
91 91
92 92
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 5f3a13d4369d..eab663eef117 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -74,7 +74,7 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8786}"
74 74
75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
77static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 77static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
78 78
79module_param_array(index, int, NULL, 0444); 79module_param_array(index, int, NULL, 0444);
80MODULE_PARM_DESC(index, "card index"); 80MODULE_PARM_DESC(index, "card index");
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 4149a0cb8b73..3fdee4950174 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -32,7 +32,7 @@ MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
32 32
33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
35static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
36 36
37module_param_array(index, int, NULL, 0444); 37module_param_array(index, int, NULL, 0444);
38MODULE_PARM_DESC(index, "card index"); 38MODULE_PARM_DESC(index, "card index");
diff --git a/sound/pci/oxygen/xonar_cs43xx.c b/sound/pci/oxygen/xonar_cs43xx.c
index 252719101c42..c8febf4b9bd6 100644
--- a/sound/pci/oxygen/xonar_cs43xx.c
+++ b/sound/pci/oxygen/xonar_cs43xx.c
@@ -418,6 +418,7 @@ static const struct oxygen_model model_xonar_d1 = {
418 .device_config = PLAYBACK_0_TO_I2S | 418 .device_config = PLAYBACK_0_TO_I2S |
419 PLAYBACK_1_TO_SPDIF | 419 PLAYBACK_1_TO_SPDIF |
420 CAPTURE_0_FROM_I2S_2 | 420 CAPTURE_0_FROM_I2S_2 |
421 CAPTURE_1_FROM_SPDIF |
421 AC97_FMIC_SWITCH, 422 AC97_FMIC_SWITCH,
422 .dac_channels_pcm = 8, 423 .dac_channels_pcm = 8,
423 .dac_channels_mixer = 8, 424 .dac_channels_mixer = 8,
diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
index bc6eb58be380..793bdf03d7e0 100644
--- a/sound/pci/oxygen/xonar_dg.c
+++ b/sound/pci/oxygen/xonar_dg.c
@@ -597,7 +597,8 @@ struct oxygen_model model_xonar_dg = {
597 .model_data_size = sizeof(struct dg), 597 .model_data_size = sizeof(struct dg),
598 .device_config = PLAYBACK_0_TO_I2S | 598 .device_config = PLAYBACK_0_TO_I2S |
599 PLAYBACK_1_TO_SPDIF | 599 PLAYBACK_1_TO_SPDIF |
600 CAPTURE_0_FROM_I2S_2, 600 CAPTURE_0_FROM_I2S_2 |
601 CAPTURE_1_FROM_SPDIF,
601 .dac_channels_pcm = 6, 602 .dac_channels_pcm = 6,
602 .dac_channels_mixer = 0, 603 .dac_channels_mixer = 0,
603 .function_flags = OXYGEN_FUNCTION_SPI, 604 .function_flags = OXYGEN_FUNCTION_SPI,
diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c
index 42d1ab136217..478303e6c2b0 100644
--- a/sound/pci/oxygen/xonar_wm87x6.c
+++ b/sound/pci/oxygen/xonar_wm87x6.c
@@ -1274,7 +1274,8 @@ static const struct oxygen_model model_xonar_ds = {
1274 .model_data_size = sizeof(struct xonar_wm87x6), 1274 .model_data_size = sizeof(struct xonar_wm87x6),
1275 .device_config = PLAYBACK_0_TO_I2S | 1275 .device_config = PLAYBACK_0_TO_I2S |
1276 PLAYBACK_1_TO_SPDIF | 1276 PLAYBACK_1_TO_SPDIF |
1277 CAPTURE_0_FROM_I2S_1, 1277 CAPTURE_0_FROM_I2S_1 |
1278 CAPTURE_1_FROM_SPDIF,
1278 .dac_channels_pcm = 8, 1279 .dac_channels_pcm = 8,
1279 .dac_channels_mixer = 8, 1280 .dac_channels_mixer = 8,
1280 .dac_volume_min = 255 - 2*60, 1281 .dac_volume_min = 255 - 2*60,
@@ -1306,7 +1307,8 @@ static const struct oxygen_model model_xonar_hdav_slim = {
1306 .model_data_size = sizeof(struct xonar_wm87x6), 1307 .model_data_size = sizeof(struct xonar_wm87x6),
1307 .device_config = PLAYBACK_0_TO_I2S | 1308 .device_config = PLAYBACK_0_TO_I2S |
1308 PLAYBACK_1_TO_SPDIF | 1309 PLAYBACK_1_TO_SPDIF |
1309 CAPTURE_0_FROM_I2S_1, 1310 CAPTURE_0_FROM_I2S_1 |
1311 CAPTURE_1_FROM_SPDIF,
1310 .dac_channels_pcm = 8, 1312 .dac_channels_pcm = 8,
1311 .dac_channels_mixer = 2, 1313 .dac_channels_mixer = 2,
1312 .dac_volume_min = 255 - 2*60, 1314 .dac_volume_min = 255 - 2*60,
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 56a52659742d..fd1809ab73b4 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -52,8 +52,8 @@ MODULE_SUPPORTED_DEVICE("{{Digigram," DRIVER_NAME "}}");
52 52
53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
55static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 55static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
56static int mono[SNDRV_CARDS]; /* capture mono only */ 56static bool mono[SNDRV_CARDS]; /* capture mono only */
57 57
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard"); 59MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard");
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index dcbedd33a629..0481d94aac9b 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -122,7 +122,7 @@ MODULE_FIRMWARE("riptide.hex");
122 122
123static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 123static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
124static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 124static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
125static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; 125static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
126 126
127#ifdef SUPPORT_JOYSTICK 127#ifdef SUPPORT_JOYSTICK
128static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 }; 128static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 };
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 21bcb47fab50..b4819d5e41db 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -89,8 +89,8 @@
89 89
90static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 90static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
91static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 91static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
92static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 92static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
93static int fullduplex[SNDRV_CARDS]; // = {[0 ... (SNDRV_CARDS - 1)] = 1}; 93static bool fullduplex[SNDRV_CARDS]; // = {[0 ... (SNDRV_CARDS - 1)] = 1};
94 94
95module_param_array(index, int, NULL, 0444); 95module_param_array(index, int, NULL, 0444);
96MODULE_PARM_DESC(index, "Index value for RME Digi32 soundcard."); 96MODULE_PARM_DESC(index, "Index value for RME Digi32 soundcard.");
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 4585c9729fea..ba894158e76c 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -53,7 +53,7 @@ MODULE_SUPPORTED_DEVICE("{{RME,Digi96},"
53 53
54static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 54static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
55static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 55static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
56static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 56static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
57 57
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for RME Digi96 soundcard."); 59MODULE_PARM_DESC(index, "Index value for RME Digi96 soundcard.");
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index f2a3758dac52..b68cdec03b9e 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -45,7 +45,7 @@
45 45
46static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 46static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
47static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 47static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
48static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 48static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
49 49
50module_param_array(index, int, NULL, 0444); 50module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface."); 51MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface.");
@@ -2640,8 +2640,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2640 uinfo->value.enumerated.items = 3; 2640 uinfo->value.enumerated.items = 3;
2641 break; 2641 break;
2642 default: 2642 default:
2643 uinfo->value.enumerated.items = 0; 2643 return -EINVAL;
2644 break;
2645 } 2644 }
2646 2645
2647 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2646 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index e760adad9523..cc9f6c83d661 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -61,7 +61,7 @@
61 61
62static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 62static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
63static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 63static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
64static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 64static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
65 65
66module_param_array(index, int, NULL, 0444); 66module_param_array(index, int, NULL, 0444);
67MODULE_PARM_DESC(index, "Index value for RME HDSPM interface."); 67MODULE_PARM_DESC(index, "Index value for RME HDSPM interface.");
@@ -941,6 +941,8 @@ struct hdspm {
941 941
942 cycles_t last_interrupt; 942 cycles_t last_interrupt;
943 943
944 unsigned int serial;
945
944 struct hdspm_peak_rms peak_rms; 946 struct hdspm_peak_rms peak_rms;
945}; 947};
946 948
@@ -4694,7 +4696,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry,
4694 4696
4695 snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n", 4697 snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n",
4696 (hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF, 4698 (hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF,
4697 (hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF); 4699 hdspm->serial);
4698 4700
4699 snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", 4701 snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
4700 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); 4702 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase);
@@ -6266,8 +6268,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6266 hdspm_version.card_type = hdspm->io_type; 6268 hdspm_version.card_type = hdspm->io_type;
6267 strncpy(hdspm_version.cardname, hdspm->card_name, 6269 strncpy(hdspm_version.cardname, hdspm->card_name,
6268 sizeof(hdspm_version.cardname)); 6270 sizeof(hdspm_version.cardname));
6269 hdspm_version.serial = (hdspm_read(hdspm, 6271 hdspm_version.serial = hdspm->serial;
6270 HDSPM_midiStatusIn0)>>8) & 0xFFFFFF;
6271 hdspm_version.firmware_rev = hdspm->firmware_rev; 6272 hdspm_version.firmware_rev = hdspm->firmware_rev;
6272 hdspm_version.addons = 0; 6273 hdspm_version.addons = 0;
6273 if (hdspm->tco) 6274 if (hdspm->tco)
@@ -6518,7 +6519,7 @@ static int __devinit snd_hdspm_create(struct snd_card *card,
6518 hdspm->io_type = AES32; 6519 hdspm->io_type = AES32;
6519 hdspm->card_name = "RME AES32"; 6520 hdspm->card_name = "RME AES32";
6520 hdspm->midiPorts = 2; 6521 hdspm->midiPorts = 2;
6521 } else if ((hdspm->firmware_rev == 0xd5) || 6522 } else if ((hdspm->firmware_rev == 0xd2) ||
6522 ((hdspm->firmware_rev >= 0xc8) && 6523 ((hdspm->firmware_rev >= 0xc8) &&
6523 (hdspm->firmware_rev <= 0xcf))) { 6524 (hdspm->firmware_rev <= 0xcf))) {
6524 hdspm->io_type = MADI; 6525 hdspm->io_type = MADI;
@@ -6782,6 +6783,25 @@ static int __devinit snd_hdspm_create(struct snd_card *card,
6782 tasklet_init(&hdspm->midi_tasklet, 6783 tasklet_init(&hdspm->midi_tasklet,
6783 hdspm_midi_tasklet, (unsigned long) hdspm); 6784 hdspm_midi_tasklet, (unsigned long) hdspm);
6784 6785
6786
6787 if (hdspm->io_type != MADIface) {
6788 hdspm->serial = (hdspm_read(hdspm,
6789 HDSPM_midiStatusIn0)>>8) & 0xFFFFFF;
6790 /* id contains either a user-provided value or the default
6791 * NULL. If it's the default, we're safe to
6792 * fill card->id with the serial number.
6793 *
6794 * If the serial number is 0xFFFFFF, then we're dealing with
6795 * an old PCI revision that comes without a sane number. In
6796 * this case, we don't set card->id to avoid collisions
6797 * when running with multiple cards.
6798 */
6799 if (NULL == id[hdspm->dev] && hdspm->serial != 0xFFFFFF) {
6800 sprintf(card->id, "HDSPMx%06x", hdspm->serial);
6801 snd_card_set_id(card, card->id);
6802 }
6803 }
6804
6785 snd_printdd("create alsa devices.\n"); 6805 snd_printdd("create alsa devices.\n");
6786 err = snd_hdspm_create_alsa_devices(card, hdspm); 6806 err = snd_hdspm_create_alsa_devices(card, hdspm);
6787 if (err < 0) 6807 if (err < 0)
@@ -6868,10 +6888,10 @@ static int __devinit snd_hdspm_probe(struct pci_dev *pci,
6868 if (hdspm->io_type != MADIface) { 6888 if (hdspm->io_type != MADIface) {
6869 sprintf(card->shortname, "%s_%x", 6889 sprintf(card->shortname, "%s_%x",
6870 hdspm->card_name, 6890 hdspm->card_name,
6871 (hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF); 6891 hdspm->serial);
6872 sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d", 6892 sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d",
6873 hdspm->card_name, 6893 hdspm->card_name,
6874 (hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF, 6894 hdspm->serial,
6875 hdspm->port, hdspm->irq); 6895 hdspm->port, hdspm->irq);
6876 } else { 6896 } else {
6877 sprintf(card->shortname, "%s", hdspm->card_name); 6897 sprintf(card->shortname, "%s", hdspm->card_name);
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 732c5e837437..b737d1619cc7 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -38,8 +38,8 @@
38 38
39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
41static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 41static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
42static int precise_ptr[SNDRV_CARDS]; /* Enable precise pointer */ 42static bool precise_ptr[SNDRV_CARDS]; /* Enable precise pointer */
43 43
44module_param_array(index, int, NULL, 0444); 44module_param_array(index, int, NULL, 0444);
45MODULE_PARM_DESC(index, "Index value for RME Digi9652 (Hammerfall) soundcard."); 45MODULE_PARM_DESC(index, "Index value for RME Digi9652 (Hammerfall) soundcard.");
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index a391e622a192..ff500a87f769 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -40,7 +40,8 @@ MODULE_SUPPORTED_DEVICE("{{SiS,SiS7019 Audio Accelerator}}");
40 40
41static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 41static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
42static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 42static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
43static int enable = 1; 43static bool enable = 1;
44static int codecs = 1;
44 45
45module_param(index, int, 0444); 46module_param(index, int, 0444);
46MODULE_PARM_DESC(index, "Index value for SiS7019 Audio Accelerator."); 47MODULE_PARM_DESC(index, "Index value for SiS7019 Audio Accelerator.");
@@ -48,6 +49,8 @@ module_param(id, charp, 0444);
48MODULE_PARM_DESC(id, "ID string for SiS7019 Audio Accelerator."); 49MODULE_PARM_DESC(id, "ID string for SiS7019 Audio Accelerator.");
49module_param(enable, bool, 0444); 50module_param(enable, bool, 0444);
50MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator."); 51MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator.");
52module_param(codecs, int, 0444);
53MODULE_PARM_DESC(codecs, "Set bit to indicate that codec number is expected to be present (default 1)");
51 54
52static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = { 55static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = {
53 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) }, 56 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) },
@@ -140,6 +143,9 @@ struct sis7019 {
140 dma_addr_t silence_dma_addr; 143 dma_addr_t silence_dma_addr;
141}; 144};
142 145
146/* These values are also used by the module param 'codecs' to indicate
147 * which codecs should be present.
148 */
143#define SIS_PRIMARY_CODEC_PRESENT 0x0001 149#define SIS_PRIMARY_CODEC_PRESENT 0x0001
144#define SIS_SECONDARY_CODEC_PRESENT 0x0002 150#define SIS_SECONDARY_CODEC_PRESENT 0x0002
145#define SIS_TERTIARY_CODEC_PRESENT 0x0004 151#define SIS_TERTIARY_CODEC_PRESENT 0x0004
@@ -977,7 +983,7 @@ timeout:
977 mutex_unlock(&sis->ac97_mutex); 983 mutex_unlock(&sis->ac97_mutex);
978 984
979 if (!count) { 985 if (!count) {
980 printk(KERN_ERR "sis7019: ac97 codec %d timeout cmd 0x%08x\n", 986 dev_err(&sis->pci->dev, "ac97 codec %d timeout cmd 0x%08x\n",
981 codec, cmd); 987 codec, cmd);
982 } 988 }
983 989
@@ -1078,6 +1084,7 @@ static int sis_chip_init(struct sis7019 *sis)
1078{ 1084{
1079 unsigned long io = sis->ioport; 1085 unsigned long io = sis->ioport;
1080 void __iomem *ioaddr = sis->ioaddr; 1086 void __iomem *ioaddr = sis->ioaddr;
1087 unsigned long timeout;
1081 u16 status; 1088 u16 status;
1082 int count; 1089 int count;
1083 int i; 1090 int i;
@@ -1104,21 +1111,45 @@ static int sis_chip_init(struct sis7019 *sis)
1104 while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count) 1111 while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count)
1105 udelay(1); 1112 udelay(1);
1106 1113
1114 /* Command complete, we can let go of the semaphore now.
1115 */
1116 outl(SIS_AC97_SEMA_RELEASE, io + SIS_AC97_SEMA);
1117 if (!count)
1118 return -EIO;
1119
1107 /* Now that we've finished the reset, find out what's attached. 1120 /* Now that we've finished the reset, find out what's attached.
1121 * There are some codec/board combinations that take an extremely
1122 * long time to come up. 350+ ms has been observed in the field,
1123 * so we'll give them up to 500ms.
1108 */ 1124 */
1109 status = inl(io + SIS_AC97_STATUS); 1125 sis->codecs_present = 0;
1110 if (status & SIS_AC97_STATUS_CODEC_READY) 1126 timeout = msecs_to_jiffies(500) + jiffies;
1111 sis->codecs_present |= SIS_PRIMARY_CODEC_PRESENT; 1127 while (time_before_eq(jiffies, timeout)) {
1112 if (status & SIS_AC97_STATUS_CODEC2_READY) 1128 status = inl(io + SIS_AC97_STATUS);
1113 sis->codecs_present |= SIS_SECONDARY_CODEC_PRESENT; 1129 if (status & SIS_AC97_STATUS_CODEC_READY)
1114 if (status & SIS_AC97_STATUS_CODEC3_READY) 1130 sis->codecs_present |= SIS_PRIMARY_CODEC_PRESENT;
1115 sis->codecs_present |= SIS_TERTIARY_CODEC_PRESENT; 1131 if (status & SIS_AC97_STATUS_CODEC2_READY)
1116 1132 sis->codecs_present |= SIS_SECONDARY_CODEC_PRESENT;
1117 /* All done, let go of the semaphore, and check for errors 1133 if (status & SIS_AC97_STATUS_CODEC3_READY)
1134 sis->codecs_present |= SIS_TERTIARY_CODEC_PRESENT;
1135
1136 if (sis->codecs_present == codecs)
1137 break;
1138
1139 msleep(1);
1140 }
1141
1142 /* All done, check for errors.
1118 */ 1143 */
1119 outl(SIS_AC97_SEMA_RELEASE, io + SIS_AC97_SEMA); 1144 if (!sis->codecs_present) {
1120 if (!sis->codecs_present || !count) 1145 dev_err(&sis->pci->dev, "could not find any codecs\n");
1121 return -EIO; 1146 return -EIO;
1147 }
1148
1149 if (sis->codecs_present != codecs) {
1150 dev_warn(&sis->pci->dev, "missing codecs, found %0x, expected %0x\n",
1151 sis->codecs_present, codecs);
1152 }
1122 1153
1123 /* Let the hardware know that the audio driver is alive, 1154 /* Let the hardware know that the audio driver is alive,
1124 * and enable PCM slots on the AC-link for L/R playback (3 & 4) and 1155 * and enable PCM slots on the AC-link for L/R playback (3 & 4) and
@@ -1225,18 +1256,18 @@ static int sis_resume(struct pci_dev *pci)
1225 pci_restore_state(pci); 1256 pci_restore_state(pci);
1226 1257
1227 if (pci_enable_device(pci) < 0) { 1258 if (pci_enable_device(pci) < 0) {
1228 printk(KERN_ERR "sis7019: unable to re-enable device\n"); 1259 dev_err(&pci->dev, "unable to re-enable device\n");
1229 goto error; 1260 goto error;
1230 } 1261 }
1231 1262
1232 if (sis_chip_init(sis)) { 1263 if (sis_chip_init(sis)) {
1233 printk(KERN_ERR "sis7019: unable to re-init controller\n"); 1264 dev_err(&pci->dev, "unable to re-init controller\n");
1234 goto error; 1265 goto error;
1235 } 1266 }
1236 1267
1237 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED, 1268 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED,
1238 KBUILD_MODNAME, sis)) { 1269 KBUILD_MODNAME, sis)) {
1239 printk(KERN_ERR "sis7019: unable to regain IRQ %d\n", pci->irq); 1270 dev_err(&pci->dev, "unable to regain IRQ %d\n", pci->irq);
1240 goto error; 1271 goto error;
1241 } 1272 }
1242 1273
@@ -1304,8 +1335,7 @@ static int __devinit sis_chip_create(struct snd_card *card,
1304 goto error_out; 1335 goto error_out;
1305 1336
1306 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0) { 1337 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
1307 printk(KERN_ERR "sis7019: architecture does not support " 1338 dev_err(&pci->dev, "architecture does not support 30-bit PCI busmaster DMA");
1308 "30-bit PCI busmaster DMA");
1309 goto error_out_enabled; 1339 goto error_out_enabled;
1310 } 1340 }
1311 1341
@@ -1319,20 +1349,20 @@ static int __devinit sis_chip_create(struct snd_card *card,
1319 1349
1320 rc = pci_request_regions(pci, "SiS7019"); 1350 rc = pci_request_regions(pci, "SiS7019");
1321 if (rc) { 1351 if (rc) {
1322 printk(KERN_ERR "sis7019: unable request regions\n"); 1352 dev_err(&pci->dev, "unable request regions\n");
1323 goto error_out_enabled; 1353 goto error_out_enabled;
1324 } 1354 }
1325 1355
1326 rc = -EIO; 1356 rc = -EIO;
1327 sis->ioaddr = ioremap_nocache(pci_resource_start(pci, 1), 0x4000); 1357 sis->ioaddr = ioremap_nocache(pci_resource_start(pci, 1), 0x4000);
1328 if (!sis->ioaddr) { 1358 if (!sis->ioaddr) {
1329 printk(KERN_ERR "sis7019: unable to remap MMIO, aborting\n"); 1359 dev_err(&pci->dev, "unable to remap MMIO, aborting\n");
1330 goto error_out_cleanup; 1360 goto error_out_cleanup;
1331 } 1361 }
1332 1362
1333 rc = sis_alloc_suspend(sis); 1363 rc = sis_alloc_suspend(sis);
1334 if (rc < 0) { 1364 if (rc < 0) {
1335 printk(KERN_ERR "sis7019: unable to allocate state storage\n"); 1365 dev_err(&pci->dev, "unable to allocate state storage\n");
1336 goto error_out_cleanup; 1366 goto error_out_cleanup;
1337 } 1367 }
1338 1368
@@ -1340,9 +1370,9 @@ static int __devinit sis_chip_create(struct snd_card *card,
1340 if (rc) 1370 if (rc)
1341 goto error_out_cleanup; 1371 goto error_out_cleanup;
1342 1372
1343 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED, 1373 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED, KBUILD_MODNAME,
1344 KBUILD_MODNAME, sis)) { 1374 sis)) {
1345 printk(KERN_ERR "unable to allocate irq %d\n", sis->irq); 1375 dev_err(&pci->dev, "unable to allocate irq %d\n", sis->irq);
1346 goto error_out_cleanup; 1376 goto error_out_cleanup;
1347 } 1377 }
1348 1378
@@ -1390,6 +1420,17 @@ static int __devinit snd_sis7019_probe(struct pci_dev *pci,
1390 if (!enable) 1420 if (!enable)
1391 goto error_out; 1421 goto error_out;
1392 1422
1423 /* The user can specify which codecs should be present so that we
1424 * can wait for them to show up if they are slow to recover from
1425 * the AC97 cold reset. We default to a single codec, the primary.
1426 *
1427 * We assume that SIS_PRIMARY_*_PRESENT matches bits 0-2.
1428 */
1429 codecs &= SIS_PRIMARY_CODEC_PRESENT | SIS_SECONDARY_CODEC_PRESENT |
1430 SIS_TERTIARY_CODEC_PRESENT;
1431 if (!codecs)
1432 codecs = SIS_PRIMARY_CODEC_PRESENT;
1433
1393 rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card); 1434 rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card);
1394 if (rc < 0) 1435 if (rc < 0)
1395 goto error_out; 1436 goto error_out;
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 31b6ad3ab1dc..54cc802050f7 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -52,9 +52,9 @@ MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}");
52 52
53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
55static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 55static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
56static int reverb[SNDRV_CARDS]; 56static bool reverb[SNDRV_CARDS];
57static int mge[SNDRV_CARDS]; 57static bool mge[SNDRV_CARDS];
58static unsigned int dmaio = 0x7a00; /* DDMA i/o address */ 58static unsigned int dmaio = 0x7a00; /* DDMA i/o address */
59 59
60module_param_array(index, int, NULL, 0444); 60module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index deb04b924122..5f1def7f45e5 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -47,7 +47,7 @@ MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
47 47
48static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 48static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
50static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 50static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; 51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
52static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192}; 52static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192};
53 53
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index ae98d56d05bd..75630408c6db 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -80,7 +80,7 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
80static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 80static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
81static long mpu_port; 81static long mpu_port;
82#ifdef SUPPORT_JOYSTICK 82#ifdef SUPPORT_JOYSTICK
83static int joystick; 83static bool joystick;
84#endif 84#endif
85static int ac97_clock = 48000; 85static int ac97_clock = 48000;
86static char *ac97_quirk; 86static char *ac97_quirk;
@@ -110,7 +110,7 @@ module_param(nodelay, int, 0444);
110MODULE_PARM_DESC(nodelay, "Disable 500ms init delay"); 110MODULE_PARM_DESC(nodelay, "Disable 500ms init delay");
111 111
112/* just for backward compatibility */ 112/* just for backward compatibility */
113static int enable; 113static bool enable;
114module_param(enable, bool, 0444); 114module_param(enable, bool, 0444);
115 115
116 116
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 80a9c2bf3301..5efcbcac506a 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -66,7 +66,7 @@ module_param(ac97_clock, int, 0444);
66MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); 66MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
67 67
68/* just for backward compatibility */ 68/* just for backward compatibility */
69static int enable; 69static bool enable;
70module_param(enable, bool, 0444); 70module_param(enable, bool, 0444);
71 71
72 72
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index 6765822fb3b7..6a534bfe1274 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -37,8 +37,8 @@ MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
37 37
38static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 38static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
39static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 39static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
40static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 40static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
41static int mic[SNDRV_CARDS]; /* microphone */ 41static bool mic[SNDRV_CARDS]; /* microphone */
42static int ibl[SNDRV_CARDS]; /* microphone */ 42static int ibl[SNDRV_CARDS]; /* microphone */
43 43
44module_param_array(index, int, NULL, 0444); 44module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index e97ddcac0d37..e57b89e8aa89 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -41,13 +41,13 @@ MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724},"
41 41
42static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 42static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
43static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 43static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
44static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 44static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
45static long fm_port[SNDRV_CARDS]; 45static long fm_port[SNDRV_CARDS];
46static long mpu_port[SNDRV_CARDS]; 46static long mpu_port[SNDRV_CARDS];
47#ifdef SUPPORT_JOYSTICK 47#ifdef SUPPORT_JOYSTICK
48static long joystick_port[SNDRV_CARDS]; 48static long joystick_port[SNDRV_CARDS];
49#endif 49#endif
50static int rear_switch[SNDRV_CARDS]; 50static bool rear_switch[SNDRV_CARDS];
51 51
52module_param_array(index, int, NULL, 0444); 52module_param_array(index, int, NULL, 0444);
53MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard."); 53MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard.");
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index 6af41d2d8fc5..830839a874b6 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -39,7 +39,7 @@ MODULE_SUPPORTED_DEVICE("{{Sound Core," CARD_NAME "}}");
39 39
40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
42static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 42static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
43 43
44module_param_array(index, int, NULL, 0444); 44module_param_array(index, int, NULL, 0444);
45MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 45MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 9e361c9d5bf3..512f0b472375 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -39,7 +39,7 @@ MODULE_SUPPORTED_DEVICE("{{Digigram,VXPocket},{Digigram,VXPocket440}}");
39 39
40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
42static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 42static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
43static int ibl[SNDRV_CARDS]; 43static int ibl[SNDRV_CARDS];
44 44
45module_param_array(index, int, NULL, 0444); 45module_param_array(index, int, NULL, 0444);
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index 65645693c485..5a4e263b5b0f 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -36,7 +36,7 @@ MODULE_LICENSE("GPL");
36 36
37static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 37static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
38static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 38static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
39static int enable_beep = 1; 39static bool enable_beep = 1;
40 40
41module_param(index, int, 0444); 41module_param(index, int, 0444);
42MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip."); 42MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip.");
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 1120ca49edd0..391a38ca58bc 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -55,7 +55,7 @@ MODULE_FIRMWARE("aica_firmware.bin");
55#define CARD_NAME "AICA" 55#define CARD_NAME "AICA"
56static int index = -1; 56static int index = -1;
57static char *id; 57static char *id;
58static int enable = 1; 58static bool enable = 1;
59module_param(index, int, 0444); 59module_param(index, int, 0444);
60MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 60MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
61module_param(id, charp, 0444); 61module_param(id, charp, 0444);
diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c
index 56bcb46abf0d..b11f82b5718f 100644
--- a/sound/sh/sh_dac_audio.c
+++ b/sound/sh/sh_dac_audio.c
@@ -441,15 +441,4 @@ static struct platform_driver driver = {
441 }, 441 },
442}; 442};
443 443
444static int __init sh_dac_init(void) 444module_platform_driver(driver);
445{
446 return platform_driver_register(&driver);
447}
448
449static void __exit sh_dac_exit(void)
450{
451 platform_driver_unregister(&driver);
452}
453
454module_init(sh_dac_init);
455module_exit(sh_dac_exit);
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index f036776380b5..b63b3a86d3f4 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -50,7 +50,7 @@
50 50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 53static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
54 54
55module_param_array(index, int, NULL, 0444); 55module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for Sun AMD7930 soundcard."); 56MODULE_PARM_DESC(index, "Index value for Sun AMD7930 soundcard.");
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 0e618f82808c..f2eabd3f22fd 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -40,7 +40,7 @@
40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
42/* Enable this card */ 42/* Enable this card */
43static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 43static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
44 44
45module_param_array(index, int, NULL, 0444); 45module_param_array(index, int, NULL, 0444);
46MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard."); 46MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard.");
@@ -2118,15 +2118,4 @@ static struct platform_driver cs4231_driver = {
2118 .remove = __devexit_p(cs4231_remove), 2118 .remove = __devexit_p(cs4231_remove),
2119}; 2119};
2120 2120
2121static int __init cs4231_init(void) 2121module_platform_driver(cs4231_driver);
2122{
2123 return platform_driver_register(&cs4231_driver);
2124}
2125
2126static void __exit cs4231_exit(void)
2127{
2128 platform_driver_unregister(&cs4231_driver);
2129}
2130
2131module_init(cs4231_init);
2132module_exit(cs4231_exit);
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 4a4f1d740330..a6b0deb77746 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -80,7 +80,7 @@ MODULE_SUPPORTED_DEVICE("{{Sun,DBRI}}");
80static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 80static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
81static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 81static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
82/* Enable this card */ 82/* Enable this card */
83static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 83static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
84 84
85module_param_array(index, int, NULL, 0444); 85module_param_array(index, int, NULL, 0444);
86MODULE_PARM_DESC(index, "Index value for Sun DBRI soundcard."); 86MODULE_PARM_DESC(index, "Index value for Sun DBRI soundcard.");
@@ -2697,16 +2697,4 @@ static struct platform_driver dbri_sbus_driver = {
2697 .remove = __devexit_p(dbri_remove), 2697 .remove = __devexit_p(dbri_remove),
2698}; 2698};
2699 2699
2700/* Probe for the dbri chip and then attach the driver. */ 2700module_platform_driver(dbri_sbus_driver);
2701static int __init dbri_init(void)
2702{
2703 return platform_driver_register(&dbri_sbus_driver);
2704}
2705
2706static void __exit dbri_exit(void)
2707{
2708 platform_driver_unregister(&dbri_sbus_driver);
2709}
2710
2711module_init(dbri_init);
2712module_exit(dbri_exit);
diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c
index c7dca7b0b9fe..a43f1952169a 100644
--- a/sound/usb/6fire/chip.c
+++ b/sound/usb/6fire/chip.c
@@ -35,7 +35,7 @@ MODULE_SUPPORTED_DEVICE("{{TerraTec, DMX 6Fire USB}}");
35 35
36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for card */ 37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for card */
38static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable card */ 38static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable card */
39static struct sfire_chip *chips[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 39static struct sfire_chip *chips[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
40static struct usb_device *devices[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 40static struct usb_device *devices[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
41 41
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 3eb605bd9503..7cf67e44d85b 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -55,7 +55,7 @@ MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
55 55
56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
57static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ 57static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
58static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 58static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
59static int snd_card_used[SNDRV_CARDS]; 59static int snd_card_used[SNDRV_CARDS];
60 60
61module_param_array(index, int, NULL, 0444); 61module_param_array(index, int, NULL, 0444);
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 0f6dc0d457bf..4a7be7b98331 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -78,14 +78,14 @@ MODULE_SUPPORTED_DEVICE("{{Generic,USB Audio}}");
78 78
79static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 79static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
80static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 80static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
81static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 81static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
82/* Vendor/product IDs for this card */ 82/* Vendor/product IDs for this card */
83static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; 83static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
84static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; 84static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
85static int nrpacks = 8; /* max. number of packets per urb */ 85static int nrpacks = 8; /* max. number of packets per urb */
86static int async_unlink = 1; 86static bool async_unlink = 1;
87static int device_setup[SNDRV_CARDS]; /* device parameter for this card */ 87static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
88static int ignore_ctl_error; 88static bool ignore_ctl_error;
89 89
90module_param_array(index, int, NULL, 0444); 90module_param_array(index, int, NULL, 0444);
91MODULE_PARM_DESC(index, "Index value for the USB audio adapter."); 91MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 81c6edecd862..08dcce53720b 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/gfp.h> 18#include <linux/gfp.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/ratelimit.h>
20#include <linux/usb.h> 21#include <linux/usb.h>
21#include <linux/usb/audio.h> 22#include <linux/usb/audio.h>
22 23
@@ -458,8 +459,8 @@ static int retire_capture_urb(struct snd_usb_substream *subs,
458 459
459 for (i = 0; i < urb->number_of_packets; i++) { 460 for (i = 0; i < urb->number_of_packets; i++) {
460 cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; 461 cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
461 if (urb->iso_frame_desc[i].status) { 462 if (urb->iso_frame_desc[i].status && printk_ratelimit()) {
462 snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); 463 snd_printdd("frame %d active: %d\n", i, urb->iso_frame_desc[i].status);
463 // continue; 464 // continue;
464 } 465 }
465 bytes = urb->iso_frame_desc[i].actual_length; 466 bytes = urb->iso_frame_desc[i].actual_length;
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 89421d176570..e09aba19375c 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -209,6 +209,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
209 return 0; 209 return 0;
210} 210}
211 211
212#define MAX_UAC2_NR_RATES 1024
213
212/* 214/*
213 * Helper function to walk the array of sample rate triplets reported by 215 * Helper function to walk the array of sample rate triplets reported by
214 * the device. The problem is that we need to parse whole array first to 216 * the device. The problem is that we need to parse whole array first to
@@ -226,7 +228,7 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
226 int min = combine_quad(&data[2 + 12 * i]); 228 int min = combine_quad(&data[2 + 12 * i]);
227 int max = combine_quad(&data[6 + 12 * i]); 229 int max = combine_quad(&data[6 + 12 * i]);
228 int res = combine_quad(&data[10 + 12 * i]); 230 int res = combine_quad(&data[10 + 12 * i]);
229 int rate; 231 unsigned int rate;
230 232
231 if ((max < 0) || (min < 0) || (res < 0) || (max < min)) 233 if ((max < 0) || (min < 0) || (res < 0) || (max < min))
232 continue; 234 continue;
@@ -253,6 +255,10 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
253 fp->rates |= snd_pcm_rate_to_rate_bit(rate); 255 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
254 256
255 nr_rates++; 257 nr_rates++;
258 if (nr_rates >= MAX_UAC2_NR_RATES) {
259 snd_printk(KERN_ERR "invalid uac2 rates\n");
260 break;
261 }
256 262
257 /* avoid endless loop */ 263 /* avoid endless loop */
258 if (res == 0) 264 if (res == 0)
diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
index c0609c210303..e42805862ce5 100644
--- a/sound/usb/misc/ua101.c
+++ b/sound/usb/misc/ua101.c
@@ -52,7 +52,7 @@ MODULE_SUPPORTED_DEVICE("{{Edirol,UA-101},{Edirol,UA-1000}}");
52 52
53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
55static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 55static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
56static unsigned int queue_length = 21; 56static unsigned int queue_length = 21;
57 57
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index b61945f3af9e..8edc5035fc8f 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -269,6 +269,32 @@ YAMAHA_DEVICE(0x105a, NULL),
269YAMAHA_DEVICE(0x105b, NULL), 269YAMAHA_DEVICE(0x105b, NULL),
270YAMAHA_DEVICE(0x105c, NULL), 270YAMAHA_DEVICE(0x105c, NULL),
271YAMAHA_DEVICE(0x105d, NULL), 271YAMAHA_DEVICE(0x105d, NULL),
272{
273 USB_DEVICE(0x0499, 0x1503),
274 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
275 /* .vendor_name = "Yamaha", */
276 /* .product_name = "MOX6/MOX8", */
277 .ifnum = QUIRK_ANY_INTERFACE,
278 .type = QUIRK_COMPOSITE,
279 .data = (const struct snd_usb_audio_quirk[]) {
280 {
281 .ifnum = 1,
282 .type = QUIRK_AUDIO_STANDARD_INTERFACE
283 },
284 {
285 .ifnum = 2,
286 .type = QUIRK_AUDIO_STANDARD_INTERFACE
287 },
288 {
289 .ifnum = 3,
290 .type = QUIRK_MIDI_YAMAHA
291 },
292 {
293 .ifnum = -1
294 }
295 }
296 }
297},
272YAMAHA_DEVICE(0x2000, "DGP-7"), 298YAMAHA_DEVICE(0x2000, "DGP-7"),
273YAMAHA_DEVICE(0x2001, "DGP-5"), 299YAMAHA_DEVICE(0x2001, "DGP-5"),
274YAMAHA_DEVICE(0x2002, NULL), 300YAMAHA_DEVICE(0x2002, NULL),
@@ -1633,6 +1659,37 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1633 } 1659 }
1634}, 1660},
1635{ 1661{
1662 /* Roland GAIA SH-01 */
1663 USB_DEVICE(0x0582, 0x0111),
1664 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
1665 .vendor_name = "Roland",
1666 .product_name = "GAIA",
1667 .ifnum = QUIRK_ANY_INTERFACE,
1668 .type = QUIRK_COMPOSITE,
1669 .data = (const struct snd_usb_audio_quirk[]) {
1670 {
1671 .ifnum = 0,
1672 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1673 },
1674 {
1675 .ifnum = 1,
1676 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1677 },
1678 {
1679 .ifnum = 2,
1680 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1681 .data = &(const struct snd_usb_midi_endpoint_info) {
1682 .out_cables = 0x0003,
1683 .in_cables = 0x0003
1684 }
1685 },
1686 {
1687 .ifnum = -1
1688 }
1689 }
1690 }
1691},
1692{
1636 USB_DEVICE(0x0582, 0x0113), 1693 USB_DEVICE(0x0582, 0x0113),
1637 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1694 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1638 /* .vendor_name = "BOSS", */ 1695 /* .vendor_name = "BOSS", */
@@ -2305,6 +2362,16 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2305 } 2362 }
2306}, 2363},
2307 2364
2365{
2366 USB_DEVICE_VENDOR_SPEC(0x0944, 0x0201),
2367 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
2368 .vendor_name = "KORG, Inc.",
2369 /* .product_name = "ToneLab ST", */
2370 .ifnum = 3,
2371 .type = QUIRK_MIDI_STANDARD_INTERFACE,
2372 }
2373},
2374
2308/* AKAI devices */ 2375/* AKAI devices */
2309{ 2376{
2310 USB_DEVICE(0x09e8, 0x0062), 2377 USB_DEVICE(0x09e8, 0x0062),
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 726c1a7b89b8..86f76a9aefae 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -37,7 +37,7 @@ MODULE_LICENSE("GPL");
37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 37static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ 38static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
39 /* Enable this card */ 39 /* Enable this card */
40static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 40static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
41 41
42module_param_array(index, int, NULL, 0444); 42module_param_array(index, int, NULL, 0444);
43MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS"."); 43MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS".");
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index c400ade3ff08..1e7a47a86605 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -674,7 +674,7 @@ dotry:
674 inurb->transfer_buffer_length = 674 inurb->transfer_buffer_length =
675 inurb->number_of_packets * 675 inurb->number_of_packets *
676 inurb->iso_frame_desc[0].length; 676 inurb->iso_frame_desc[0].length;
677 preempt_disable(); 677
678 if (u == 0) { 678 if (u == 0) {
679 int now; 679 int now;
680 struct usb_device *dev = inurb->dev; 680 struct usb_device *dev = inurb->dev;
@@ -686,19 +686,17 @@ dotry:
686 } 686 }
687 err = usb_submit_urb(inurb, GFP_ATOMIC); 687 err = usb_submit_urb(inurb, GFP_ATOMIC);
688 if (err < 0) { 688 if (err < 0) {
689 preempt_enable();
690 snd_printk(KERN_ERR"usb_submit_urb(sk->inurb[%i])" 689 snd_printk(KERN_ERR"usb_submit_urb(sk->inurb[%i])"
691 " returned %i\n", u, err); 690 " returned %i\n", u, err);
692 return err; 691 return err;
693 } 692 }
694 err = usb_submit_urb(outurb, GFP_ATOMIC); 693 err = usb_submit_urb(outurb, GFP_ATOMIC);
695 if (err < 0) { 694 if (err < 0) {
696 preempt_enable();
697 snd_printk(KERN_ERR"usb_submit_urb(sk->outurb[%i])" 695 snd_printk(KERN_ERR"usb_submit_urb(sk->outurb[%i])"
698 " returned %i\n", u, err); 696 " returned %i\n", u, err);
699 return err; 697 return err;
700 } 698 }
701 preempt_enable(); 699
702 if (inurb->start_frame != outurb->start_frame) { 700 if (inurb->start_frame != outurb->start_frame) {
703 snd_printd(KERN_DEBUG 701 snd_printd(KERN_DEBUG
704 "u[%i] start_frames differ in:%u out:%u\n", 702 "u[%i] start_frames differ in:%u out:%u\n",
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index cbd37f2c76d0..1d694586d637 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -154,7 +154,7 @@ MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604), "NAME_ALLCAPS"(0x8001)(0x8005)(0x8007
154 154
155static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 155static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
156static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ 156static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
157static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 157static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
158 158
159module_param_array(index, int, NULL, 0444); 159module_param_array(index, int, NULL, 0444);
160MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS"."); 160MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS".");