aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-07-18 07:53:29 -0400
committerTakashi Iwai <tiwai@suse.de>2012-07-18 07:53:29 -0400
commitf0913cd16e8a6608cf9558ccbe8fdf4d428ca3de (patch)
treed6ea8cc44a9d55d29d38605165a09cf69ff9a536
parent61eab000f3536f080eab43fd5eed3fd817ded76e (diff)
parent59b1f084abd8690ffe68c67758ad08bbcb7d1af0 (diff)
Merge branch 'topic/misc' into for-next
Generic updates for sound 3.6
-rw-r--r--include/linux/ac97_codec.h362
-rw-r--r--include/sound/pcm.h3
-rw-r--r--include/sound/pcm_params.h2
-rw-r--r--include/sound/tlv.h29
-rw-r--r--sound/core/pcm_lib.c4
-rw-r--r--sound/core/pcm_misc.c18
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c86
-rw-r--r--sound/isa/wss/wss_lib.c5
-rw-r--r--sound/oss/swarm_cs4297a.c17
-rw-r--r--sound/pci/au88x0/au88x0_mixer.c11
-rw-r--r--sound/pci/es1938.c25
-rw-r--r--sound/pci/maestro3.c68
-rw-r--r--sound/pci/pcxhr/pcxhr.c63
-rw-r--r--sound/pci/pcxhr/pcxhr.h1
-rw-r--r--sound/pci/pcxhr/pcxhr_core.c27
-rw-r--r--sound/pci/pcxhr/pcxhr_core.h4
-rw-r--r--sound/pci/pcxhr/pcxhr_mix22.c11
-rw-r--r--sound/pci/pcxhr/pcxhr_mix22.h1
-rw-r--r--sound/usb/caiaq/device.c2
-rw-r--r--sound/usb/mixer_quirks.c159
20 files changed, 360 insertions, 538 deletions
diff --git a/include/linux/ac97_codec.h b/include/linux/ac97_codec.h
deleted file mode 100644
index 0260c3e79fdd..000000000000
--- a/include/linux/ac97_codec.h
+++ /dev/null
@@ -1,362 +0,0 @@
1#ifndef _AC97_CODEC_H_
2#define _AC97_CODEC_H_
3
4#include <linux/types.h>
5#include <linux/soundcard.h>
6
7/* AC97 1.0 */
8#define AC97_RESET 0x0000 //
9#define AC97_MASTER_VOL_STEREO 0x0002 // Line Out
10#define AC97_HEADPHONE_VOL 0x0004 //
11#define AC97_MASTER_VOL_MONO 0x0006 // TAD Output
12#define AC97_MASTER_TONE 0x0008 //
13#define AC97_PCBEEP_VOL 0x000a // none
14#define AC97_PHONE_VOL 0x000c // TAD Input (mono)
15#define AC97_MIC_VOL 0x000e // MIC Input (mono)
16#define AC97_LINEIN_VOL 0x0010 // Line Input (stereo)
17#define AC97_CD_VOL 0x0012 // CD Input (stereo)
18#define AC97_VIDEO_VOL 0x0014 // none
19#define AC97_AUX_VOL 0x0016 // Aux Input (stereo)
20#define AC97_PCMOUT_VOL 0x0018 // Wave Output (stereo)
21#define AC97_RECORD_SELECT 0x001a //
22#define AC97_RECORD_GAIN 0x001c
23#define AC97_RECORD_GAIN_MIC 0x001e
24#define AC97_GENERAL_PURPOSE 0x0020
25#define AC97_3D_CONTROL 0x0022
26#define AC97_MODEM_RATE 0x0024
27#define AC97_POWER_CONTROL 0x0026
28
29/* AC'97 2.0 */
30#define AC97_EXTENDED_ID 0x0028 /* Extended Audio ID */
31#define AC97_EXTENDED_STATUS 0x002A /* Extended Audio Status */
32#define AC97_PCM_FRONT_DAC_RATE 0x002C /* PCM Front DAC Rate */
33#define AC97_PCM_SURR_DAC_RATE 0x002E /* PCM Surround DAC Rate */
34#define AC97_PCM_LFE_DAC_RATE 0x0030 /* PCM LFE DAC Rate */
35#define AC97_PCM_LR_ADC_RATE 0x0032 /* PCM LR ADC Rate */
36#define AC97_PCM_MIC_ADC_RATE 0x0034 /* PCM MIC ADC Rate */
37#define AC97_CENTER_LFE_MASTER 0x0036 /* Center + LFE Master Volume */
38#define AC97_SURROUND_MASTER 0x0038 /* Surround (Rear) Master Volume */
39#define AC97_RESERVED_3A 0x003A /* Reserved in AC '97 < 2.2 */
40
41/* AC'97 2.2 */
42#define AC97_SPDIF_CONTROL 0x003A /* S/PDIF Control */
43
44/* range 0x3c-0x58 - MODEM */
45#define AC97_EXTENDED_MODEM_ID 0x003C
46#define AC97_EXTEND_MODEM_STAT 0x003E
47#define AC97_LINE1_RATE 0x0040
48#define AC97_LINE2_RATE 0x0042
49#define AC97_HANDSET_RATE 0x0044
50#define AC97_LINE1_LEVEL 0x0046
51#define AC97_LINE2_LEVEL 0x0048
52#define AC97_HANDSET_LEVEL 0x004A
53#define AC97_GPIO_CONFIG 0x004C
54#define AC97_GPIO_POLARITY 0x004E
55#define AC97_GPIO_STICKY 0x0050
56#define AC97_GPIO_WAKE_UP 0x0052
57#define AC97_GPIO_STATUS 0x0054
58#define AC97_MISC_MODEM_STAT 0x0056
59#define AC97_RESERVED_58 0x0058
60
61/* registers 0x005a - 0x007a are vendor reserved */
62
63#define AC97_VENDOR_ID1 0x007c
64#define AC97_VENDOR_ID2 0x007e
65
66/* volume control bit defines */
67#define AC97_MUTE 0x8000
68#define AC97_MICBOOST 0x0040
69#define AC97_LEFTVOL 0x3f00
70#define AC97_RIGHTVOL 0x003f
71
72/* record mux defines */
73#define AC97_RECMUX_MIC 0x0000
74#define AC97_RECMUX_CD 0x0101
75#define AC97_RECMUX_VIDEO 0x0202
76#define AC97_RECMUX_AUX 0x0303
77#define AC97_RECMUX_LINE 0x0404
78#define AC97_RECMUX_STEREO_MIX 0x0505
79#define AC97_RECMUX_MONO_MIX 0x0606
80#define AC97_RECMUX_PHONE 0x0707
81
82/* general purpose register bit defines */
83#define AC97_GP_LPBK 0x0080 /* Loopback mode */
84#define AC97_GP_MS 0x0100 /* Mic Select 0=Mic1, 1=Mic2 */
85#define AC97_GP_MIX 0x0200 /* Mono output select 0=Mix, 1=Mic */
86#define AC97_GP_RLBK 0x0400 /* Remote Loopback - Modem line codec */
87#define AC97_GP_LLBK 0x0800 /* Local Loopback - Modem Line codec */
88#define AC97_GP_LD 0x1000 /* Loudness 1=on */
89#define AC97_GP_3D 0x2000 /* 3D Enhancement 1=on */
90#define AC97_GP_ST 0x4000 /* Stereo Enhancement 1=on */
91#define AC97_GP_POP 0x8000 /* Pcm Out Path, 0=pre 3D, 1=post 3D */
92
93/* extended audio status and control bit defines */
94#define AC97_EA_VRA 0x0001 /* Variable bit rate enable bit */
95#define AC97_EA_DRA 0x0002 /* Double-rate audio enable bit */
96#define AC97_EA_SPDIF 0x0004 /* S/PDIF Enable bit */
97#define AC97_EA_VRM 0x0008 /* Variable bit rate for MIC enable bit */
98#define AC97_EA_CDAC 0x0040 /* PCM Center DAC is ready (Read only) */
99#define AC97_EA_SDAC 0x0040 /* PCM Surround DACs are ready (Read only) */
100#define AC97_EA_LDAC 0x0080 /* PCM LFE DAC is ready (Read only) */
101#define AC97_EA_MDAC 0x0100 /* MIC ADC is ready (Read only) */
102#define AC97_EA_SPCV 0x0400 /* S/PDIF configuration valid (Read only) */
103#define AC97_EA_PRI 0x0800 /* Turns the PCM Center DAC off */
104#define AC97_EA_PRJ 0x1000 /* Turns the PCM Surround DACs off */
105#define AC97_EA_PRK 0x2000 /* Turns the PCM LFE DAC off */
106#define AC97_EA_PRL 0x4000 /* Turns the MIC ADC off */
107#define AC97_EA_SLOT_MASK 0xffcf /* Mask for slot assignment bits */
108#define AC97_EA_SPSA_3_4 0x0000 /* Slot assigned to 3 & 4 */
109#define AC97_EA_SPSA_7_8 0x0010 /* Slot assigned to 7 & 8 */
110#define AC97_EA_SPSA_6_9 0x0020 /* Slot assigned to 6 & 9 */
111#define AC97_EA_SPSA_10_11 0x0030 /* Slot assigned to 10 & 11 */
112
113/* S/PDIF control bit defines */
114#define AC97_SC_PRO 0x0001 /* Professional status */
115#define AC97_SC_NAUDIO 0x0002 /* Non audio stream */
116#define AC97_SC_COPY 0x0004 /* Copyright status */
117#define AC97_SC_PRE 0x0008 /* Preemphasis status */
118#define AC97_SC_CC_MASK 0x07f0 /* Category Code mask */
119#define AC97_SC_L 0x0800 /* Generation Level status */
120#define AC97_SC_SPSR_MASK 0xcfff /* S/PDIF Sample Rate bits */
121#define AC97_SC_SPSR_44K 0x0000 /* Use 44.1kHz Sample rate */
122#define AC97_SC_SPSR_48K 0x2000 /* Use 48kHz Sample rate */
123#define AC97_SC_SPSR_32K 0x3000 /* Use 32kHz Sample rate */
124#define AC97_SC_DRS 0x4000 /* Double Rate S/PDIF */
125#define AC97_SC_V 0x8000 /* Validity status */
126
127/* powerdown control and status bit defines */
128
129/* status */
130#define AC97_PWR_MDM 0x0010 /* Modem section ready */
131#define AC97_PWR_REF 0x0008 /* Vref nominal */
132#define AC97_PWR_ANL 0x0004 /* Analog section ready */
133#define AC97_PWR_DAC 0x0002 /* DAC section ready */
134#define AC97_PWR_ADC 0x0001 /* ADC section ready */
135
136/* control */
137#define AC97_PWR_PR0 0x0100 /* ADC and Mux powerdown */
138#define AC97_PWR_PR1 0x0200 /* DAC powerdown */
139#define AC97_PWR_PR2 0x0400 /* Output mixer powerdown (Vref on) */
140#define AC97_PWR_PR3 0x0800 /* Output mixer powerdown (Vref off) */
141#define AC97_PWR_PR4 0x1000 /* AC-link powerdown */
142#define AC97_PWR_PR5 0x2000 /* Internal Clk disable */
143#define AC97_PWR_PR6 0x4000 /* HP amp powerdown */
144#define AC97_PWR_PR7 0x8000 /* Modem off - if supported */
145
146/* extended audio ID register bit defines */
147#define AC97_EXTID_VRA 0x0001
148#define AC97_EXTID_DRA 0x0002
149#define AC97_EXTID_SPDIF 0x0004
150#define AC97_EXTID_VRM 0x0008
151#define AC97_EXTID_DSA0 0x0010
152#define AC97_EXTID_DSA1 0x0020
153#define AC97_EXTID_CDAC 0x0040
154#define AC97_EXTID_SDAC 0x0080
155#define AC97_EXTID_LDAC 0x0100
156#define AC97_EXTID_AMAP 0x0200
157#define AC97_EXTID_REV0 0x0400
158#define AC97_EXTID_REV1 0x0800
159#define AC97_EXTID_ID0 0x4000
160#define AC97_EXTID_ID1 0x8000
161
162/* extended status register bit defines */
163#define AC97_EXTSTAT_VRA 0x0001
164#define AC97_EXTSTAT_DRA 0x0002
165#define AC97_EXTSTAT_SPDIF 0x0004
166#define AC97_EXTSTAT_VRM 0x0008
167#define AC97_EXTSTAT_SPSA0 0x0010
168#define AC97_EXTSTAT_SPSA1 0x0020
169#define AC97_EXTSTAT_CDAC 0x0040
170#define AC97_EXTSTAT_SDAC 0x0080
171#define AC97_EXTSTAT_LDAC 0x0100
172#define AC97_EXTSTAT_MADC 0x0200
173#define AC97_EXTSTAT_SPCV 0x0400
174#define AC97_EXTSTAT_PRI 0x0800
175#define AC97_EXTSTAT_PRJ 0x1000
176#define AC97_EXTSTAT_PRK 0x2000
177#define AC97_EXTSTAT_PRL 0x4000
178
179/* extended audio ID register bit defines */
180#define AC97_EXTID_VRA 0x0001
181#define AC97_EXTID_DRA 0x0002
182#define AC97_EXTID_SPDIF 0x0004
183#define AC97_EXTID_VRM 0x0008
184#define AC97_EXTID_DSA0 0x0010
185#define AC97_EXTID_DSA1 0x0020
186#define AC97_EXTID_CDAC 0x0040
187#define AC97_EXTID_SDAC 0x0080
188#define AC97_EXTID_LDAC 0x0100
189#define AC97_EXTID_AMAP 0x0200
190#define AC97_EXTID_REV0 0x0400
191#define AC97_EXTID_REV1 0x0800
192#define AC97_EXTID_ID0 0x4000
193#define AC97_EXTID_ID1 0x8000
194
195/* extended status register bit defines */
196#define AC97_EXTSTAT_VRA 0x0001
197#define AC97_EXTSTAT_DRA 0x0002
198#define AC97_EXTSTAT_SPDIF 0x0004
199#define AC97_EXTSTAT_VRM 0x0008
200#define AC97_EXTSTAT_SPSA0 0x0010
201#define AC97_EXTSTAT_SPSA1 0x0020
202#define AC97_EXTSTAT_CDAC 0x0040
203#define AC97_EXTSTAT_SDAC 0x0080
204#define AC97_EXTSTAT_LDAC 0x0100
205#define AC97_EXTSTAT_MADC 0x0200
206#define AC97_EXTSTAT_SPCV 0x0400
207#define AC97_EXTSTAT_PRI 0x0800
208#define AC97_EXTSTAT_PRJ 0x1000
209#define AC97_EXTSTAT_PRK 0x2000
210#define AC97_EXTSTAT_PRL 0x4000
211
212/* useful power states */
213#define AC97_PWR_D0 0x0000 /* everything on */
214#define AC97_PWR_D1 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR4
215#define AC97_PWR_D2 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
216#define AC97_PWR_D3 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
217#define AC97_PWR_ANLOFF AC97_PWR_PR2|AC97_PWR_PR3 /* analog section off */
218
219/* Total number of defined registers. */
220#define AC97_REG_CNT 64
221
222
223/* OSS interface to the ac97s.. */
224#define AC97_STEREO_MASK (SOUND_MASK_VOLUME|SOUND_MASK_PCM|\
225 SOUND_MASK_LINE|SOUND_MASK_CD|\
226 SOUND_MASK_ALTPCM|SOUND_MASK_IGAIN|\
227 SOUND_MASK_LINE1|SOUND_MASK_VIDEO)
228
229#define AC97_SUPPORTED_MASK (AC97_STEREO_MASK | \
230 SOUND_MASK_BASS|SOUND_MASK_TREBLE|\
231 SOUND_MASK_SPEAKER|SOUND_MASK_MIC|\
232 SOUND_MASK_PHONEIN|SOUND_MASK_PHONEOUT)
233
234#define AC97_RECORD_MASK (SOUND_MASK_MIC|\
235 SOUND_MASK_CD|SOUND_MASK_IGAIN|SOUND_MASK_VIDEO|\
236 SOUND_MASK_LINE1| SOUND_MASK_LINE|\
237 SOUND_MASK_PHONEIN)
238
239/* original check is not good enough in case FOO is greater than
240 * SOUND_MIXER_NRDEVICES because the supported_mixers has exactly
241 * SOUND_MIXER_NRDEVICES elements.
242 * before matching the given mixer against the bitmask in supported_mixers we
243 * check if mixer number exceeds maximum allowed size which is as mentioned
244 * above SOUND_MIXER_NRDEVICES */
245#define supported_mixer(CODEC,FOO) ((FOO >= 0) && \
246 (FOO < SOUND_MIXER_NRDEVICES) && \
247 (CODEC)->supported_mixers & (1<<FOO) )
248
249struct ac97_codec {
250 /* Linked list of codecs */
251 struct list_head list;
252
253 /* AC97 controller connected with */
254 void *private_data;
255
256 char *name;
257 int id;
258 int dev_mixer;
259 int type;
260 u32 model;
261
262 unsigned int modem:1;
263
264 struct ac97_ops *codec_ops;
265
266 /* controller specific lower leverl ac97 accessing routines.
267 must be re-entrant safe */
268 u16 (*codec_read) (struct ac97_codec *codec, u8 reg);
269 void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val);
270
271 /* Wait for codec-ready. Ok to sleep here. */
272 void (*codec_wait) (struct ac97_codec *codec);
273
274 /* callback used by helper drivers for interesting ac97 setups */
275 void (*codec_unregister) (struct ac97_codec *codec);
276
277 struct ac97_driver *driver;
278 void *driver_private; /* Private data for the driver */
279
280 spinlock_t lock;
281
282 /* OSS mixer masks */
283 int modcnt;
284 int supported_mixers;
285 int stereo_mixers;
286 int record_sources;
287
288 /* Property flags */
289 int flags;
290
291 int bit_resolution;
292
293 /* OSS mixer interface */
294 int (*read_mixer) (struct ac97_codec *codec, int oss_channel);
295 void (*write_mixer)(struct ac97_codec *codec, int oss_channel,
296 unsigned int left, unsigned int right);
297 int (*recmask_io) (struct ac97_codec *codec, int rw, int mask);
298 int (*mixer_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
299
300 /* saved OSS mixer states */
301 unsigned int mixer_state[SOUND_MIXER_NRDEVICES];
302
303 /* Software Modem interface */
304 int (*modem_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
305};
306
307/*
308 * Operation structures for each known AC97 chip
309 */
310
311struct ac97_ops
312{
313 /* Initialise */
314 int (*init)(struct ac97_codec *c);
315 /* Amplifier control */
316 int (*amplifier)(struct ac97_codec *codec, int on);
317 /* Digital mode control */
318 int (*digital)(struct ac97_codec *codec, int slots, int rate, int mode);
319#define AUDIO_DIGITAL 0x8000
320#define AUDIO_PRO 0x4000
321#define AUDIO_DRS 0x2000
322#define AUDIO_CCMASK 0x003F
323
324#define AC97_DELUDED_MODEM 1 /* Audio codec reports its a modem */
325#define AC97_NO_PCM_VOLUME 2 /* Volume control is missing */
326#define AC97_DEFAULT_POWER_OFF 4 /* Needs warm reset to power up */
327};
328
329extern int ac97_probe_codec(struct ac97_codec *);
330
331extern struct ac97_codec *ac97_alloc_codec(void);
332extern void ac97_release_codec(struct ac97_codec *codec);
333
334struct ac97_driver {
335 struct list_head list;
336 char *name;
337 u32 codec_id;
338 u32 codec_mask;
339 int (*probe) (struct ac97_codec *codec, struct ac97_driver *driver);
340 void (*remove) (struct ac97_codec *codec, struct ac97_driver *driver);
341};
342
343/* quirk types */
344enum {
345 AC97_TUNE_DEFAULT = -1, /* use default from quirk list (not valid in list) */
346 AC97_TUNE_NONE = 0, /* nothing extra to do */
347 AC97_TUNE_HP_ONLY, /* headphone (true line-out) control as master only */
348 AC97_TUNE_SWAP_HP, /* swap headphone and master controls */
349 AC97_TUNE_SWAP_SURROUND, /* swap master and surround controls */
350 AC97_TUNE_AD_SHARING, /* for AD1985, turn on OMS bit and use headphone */
351 AC97_TUNE_ALC_JACK, /* for Realtek, enable JACK detection */
352};
353
354struct ac97_quirk {
355 unsigned short vendor; /* PCI vendor id */
356 unsigned short device; /* PCI device id */
357 unsigned short mask; /* device id bit mask, 0 = accept all */
358 const char *name; /* name shown as info */
359 int type; /* quirk type above */
360};
361
362#endif /* _AC97_CODEC_H_ */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 0d1112815be3..e91e6047ca6f 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -810,7 +810,7 @@ int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_pa
810int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, 810int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime,
811 unsigned int cond, 811 unsigned int cond,
812 snd_pcm_hw_param_t var, 812 snd_pcm_hw_param_t var,
813 struct snd_pcm_hw_constraint_list *l); 813 const struct snd_pcm_hw_constraint_list *l);
814int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, 814int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime,
815 unsigned int cond, 815 unsigned int cond,
816 snd_pcm_hw_param_t var, 816 snd_pcm_hw_param_t var,
@@ -893,6 +893,7 @@ extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
893 893
894int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime); 894int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);
895unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate); 895unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
896unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
896 897
897static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, 898static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
898 struct snd_dma_buffer *bufp) 899 struct snd_dma_buffer *bufp)
diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h
index f494f1e3c900..37ae12e0ab06 100644
--- a/include/sound/pcm_params.h
+++ b/include/sound/pcm_params.h
@@ -22,6 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#include <sound/pcm.h>
26
25int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, 27int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm,
26 struct snd_pcm_hw_params *params, 28 struct snd_pcm_hw_params *params,
27 snd_pcm_hw_param_t var, int *dir); 29 snd_pcm_hw_param_t var, int *dir);
diff --git a/include/sound/tlv.h b/include/sound/tlv.h
index 7067e2dfb0b9..a64d8fe3f855 100644
--- a/include/sound/tlv.h
+++ b/include/sound/tlv.h
@@ -38,21 +38,31 @@
38#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */ 38#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */
39#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */ 39#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
40 40
41#define TLV_ITEM(type, ...) \
42 (type), TLV_LENGTH(__VA_ARGS__), __VA_ARGS__
43#define TLV_LENGTH(...) \
44 ((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ }))
45
46#define TLV_CONTAINER_ITEM(...) \
47 TLV_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__)
48#define DECLARE_TLV_CONTAINER(name, ...) \
49 unsigned int name[] = { TLV_CONTAINER_ITEM(__VA_ARGS__) }
50
41#define TLV_DB_SCALE_MASK 0xffff 51#define TLV_DB_SCALE_MASK 0xffff
42#define TLV_DB_SCALE_MUTE 0x10000 52#define TLV_DB_SCALE_MUTE 0x10000
43#define TLV_DB_SCALE_ITEM(min, step, mute) \ 53#define TLV_DB_SCALE_ITEM(min, step, mute) \
44 SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int), \ 54 TLV_ITEM(SNDRV_CTL_TLVT_DB_SCALE, \
45 (min), ((step) & TLV_DB_SCALE_MASK) | ((mute) ? TLV_DB_SCALE_MUTE : 0) 55 (min), \
56 ((step) & TLV_DB_SCALE_MASK) | \
57 ((mute) ? TLV_DB_SCALE_MUTE : 0))
46#define DECLARE_TLV_DB_SCALE(name, min, step, mute) \ 58#define DECLARE_TLV_DB_SCALE(name, min, step, mute) \
47 unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) } 59 unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) }
48 60
49/* dB scale specified with min/max values instead of step */ 61/* dB scale specified with min/max values instead of step */
50#define TLV_DB_MINMAX_ITEM(min_dB, max_dB) \ 62#define TLV_DB_MINMAX_ITEM(min_dB, max_dB) \
51 SNDRV_CTL_TLVT_DB_MINMAX, 2 * sizeof(unsigned int), \ 63 TLV_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB))
52 (min_dB), (max_dB)
53#define TLV_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \ 64#define TLV_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
54 SNDRV_CTL_TLVT_DB_MINMAX_MUTE, 2 * sizeof(unsigned int), \ 65 TLV_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB))
55 (min_dB), (max_dB)
56#define DECLARE_TLV_DB_MINMAX(name, min_dB, max_dB) \ 66#define DECLARE_TLV_DB_MINMAX(name, min_dB, max_dB) \
57 unsigned int name[] = { TLV_DB_MINMAX_ITEM(min_dB, max_dB) } 67 unsigned int name[] = { TLV_DB_MINMAX_ITEM(min_dB, max_dB) }
58#define DECLARE_TLV_DB_MINMAX_MUTE(name, min_dB, max_dB) \ 68#define DECLARE_TLV_DB_MINMAX_MUTE(name, min_dB, max_dB) \
@@ -60,13 +70,16 @@
60 70
61/* linear volume between min_dB and max_dB (.01dB unit) */ 71/* linear volume between min_dB and max_dB (.01dB unit) */
62#define TLV_DB_LINEAR_ITEM(min_dB, max_dB) \ 72#define TLV_DB_LINEAR_ITEM(min_dB, max_dB) \
63 SNDRV_CTL_TLVT_DB_LINEAR, 2 * sizeof(unsigned int), \ 73 TLV_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB))
64 (min_dB), (max_dB)
65#define DECLARE_TLV_DB_LINEAR(name, min_dB, max_dB) \ 74#define DECLARE_TLV_DB_LINEAR(name, min_dB, max_dB) \
66 unsigned int name[] = { TLV_DB_LINEAR_ITEM(min_dB, max_dB) } 75 unsigned int name[] = { TLV_DB_LINEAR_ITEM(min_dB, max_dB) }
67 76
68/* dB range container */ 77/* dB range container */
69/* Each item is: <min> <max> <TLV> */ 78/* Each item is: <min> <max> <TLV> */
79#define TLV_DB_RANGE_ITEM(...) \
80 TLV_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__)
81#define DECLARE_TLV_DB_RANGE(name, ...) \
82 unsigned int name[] = { TLV_DB_RANGE_ITEM(__VA_ARGS__) }
70/* The below assumes that each item TLV is 4 words like DB_SCALE or LINEAR */ 83/* The below assumes that each item TLV is 4 words like DB_SCALE or LINEAR */
71#define TLV_DB_RANGE_HEAD(num) \ 84#define TLV_DB_RANGE_HEAD(num) \
72 SNDRV_CTL_TLVT_DB_RANGE, 6 * (num) * sizeof(unsigned int) 85 SNDRV_CTL_TLVT_DB_RANGE, 6 * (num) * sizeof(unsigned int)
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 8f312fa6c282..7ae671923393 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1250,10 +1250,10 @@ static int snd_pcm_hw_rule_list(struct snd_pcm_hw_params *params,
1250int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, 1250int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime,
1251 unsigned int cond, 1251 unsigned int cond,
1252 snd_pcm_hw_param_t var, 1252 snd_pcm_hw_param_t var,
1253 struct snd_pcm_hw_constraint_list *l) 1253 const struct snd_pcm_hw_constraint_list *l)
1254{ 1254{
1255 return snd_pcm_hw_rule_add(runtime, cond, var, 1255 return snd_pcm_hw_rule_add(runtime, cond, var,
1256 snd_pcm_hw_rule_list, l, 1256 snd_pcm_hw_rule_list, (void *)l,
1257 var, -1); 1257 var, -1);
1258} 1258}
1259 1259
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index 9c9eff9afbac..d4fc1bfbe457 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -488,3 +488,21 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
488 return SNDRV_PCM_RATE_KNOT; 488 return SNDRV_PCM_RATE_KNOT;
489} 489}
490EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); 490EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit);
491
492/**
493 * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate
494 * @rate_bit: the rate bit to convert
495 *
496 * Returns the sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag
497 * or 0 for an unknown rate bit
498 */
499unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit)
500{
501 unsigned int i;
502
503 for (i = 0; i < snd_pcm_known_rates.count; i++)
504 if ((1u << i) == rate_bit)
505 return snd_pcm_known_rates.list[i];
506 return 0;
507}
508EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate);
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index d7ccf28bd66a..f8fbe22515c9 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -135,10 +135,9 @@ struct snd_opti9xx {
135 unsigned long mc_base_size; 135 unsigned long mc_base_size;
136#ifdef OPTi93X 136#ifdef OPTi93X
137 unsigned long mc_indir_index; 137 unsigned long mc_indir_index;
138 unsigned long mc_indir_size;
139 struct resource *res_mc_indir; 138 struct resource *res_mc_indir;
140 struct snd_wss *codec;
141#endif /* OPTi93X */ 139#endif /* OPTi93X */
140 struct snd_wss *codec;
142 unsigned long pwd_reg; 141 unsigned long pwd_reg;
143 142
144 spinlock_t lock; 143 spinlock_t lock;
@@ -245,10 +244,8 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
245 case OPTi9XX_HW_82C931: 244 case OPTi9XX_HW_82C931:
246 case OPTi9XX_HW_82C933: 245 case OPTi9XX_HW_82C933:
247 chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; 246 chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d;
248 if (!chip->mc_indir_index) { 247 if (!chip->mc_indir_index)
249 chip->mc_indir_index = 0xe0e; 248 chip->mc_indir_index = 0xe0e;
250 chip->mc_indir_size = 2;
251 }
252 chip->password = 0xe4; 249 chip->password = 0xe4;
253 chip->pwd_reg = 0; 250 chip->pwd_reg = 0;
254 break; 251 break;
@@ -351,7 +348,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
351 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) 348 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
352 349
353 350
354static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, 351static int snd_opti9xx_configure(struct snd_opti9xx *chip,
355 long port, 352 long port,
356 int irq, int dma1, int dma2, 353 int irq, int dma1, int dma2,
357 long mpu_port, int mpu_irq) 354 long mpu_port, int mpu_irq)
@@ -403,7 +400,9 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip,
403 400
404#else /* OPTi93X */ 401#else /* OPTi93X */
405 case OPTi9XX_HW_82C931: 402 case OPTi9XX_HW_82C931:
406 case OPTi9XX_HW_82C933: 403 /* disable 3D sound (set GPIO1 as output, low) */
404 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(20), 0x04, 0x0c);
405 case OPTi9XX_HW_82C933: /* FALL THROUGH */
407 /* 406 /*
408 * The BTC 1817DW has QS1000 wavetable which is connected 407 * The BTC 1817DW has QS1000 wavetable which is connected
409 * to the serial digital input of the OPTI931. 408 * to the serial digital input of the OPTI931.
@@ -696,8 +695,7 @@ static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip)
696 if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) 695 if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
697 return 0; 696 return 0;
698#else /* OPTi93X */ 697#else /* OPTi93X */
699 chip->res_mc_indir = request_region(chip->mc_indir_index, 698 chip->res_mc_indir = request_region(chip->mc_indir_index, 2,
700 chip->mc_indir_size,
701 "OPTi93x MC"); 699 "OPTi93x MC");
702 if (chip->res_mc_indir == NULL) 700 if (chip->res_mc_indir == NULL)
703 return -EBUSY; 701 return -EBUSY;
@@ -770,8 +768,9 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
770#ifdef OPTi93X 768#ifdef OPTi93X
771 port = pnp_port_start(pdev, 0) - 4; 769 port = pnp_port_start(pdev, 0) - 4;
772 fm_port = pnp_port_start(pdev, 1) + 8; 770 fm_port = pnp_port_start(pdev, 1) + 8;
773 chip->mc_indir_index = pnp_port_start(pdev, 3) + 2; 771 /* adjust mc_indir_index - some cards report it at 0xe?d,
774 chip->mc_indir_size = pnp_port_len(pdev, 3) - 2; 772 other at 0xe?c but it really is always at 0xe?e */
773 chip->mc_indir_index = (pnp_port_start(pdev, 3) & ~0xf) | 0xe;
775#else 774#else
776 devmc = pnp_request_card_device(card, pid->devs[2].id, NULL); 775 devmc = pnp_request_card_device(card, pid->devs[2].id, NULL);
777 if (devmc == NULL) 776 if (devmc == NULL)
@@ -871,9 +870,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
871 &codec); 870 &codec);
872 if (error < 0) 871 if (error < 0)
873 return error; 872 return error;
874#ifdef OPTi93X
875 chip->codec = codec; 873 chip->codec = codec;
876#endif
877 error = snd_wss_pcm(codec, 0, &pcm); 874 error = snd_wss_pcm(codec, 0, &pcm);
878 if (error < 0) 875 if (error < 0)
879 return error; 876 return error;
@@ -1054,11 +1051,55 @@ static int __devexit snd_opti9xx_isa_remove(struct device *devptr,
1054 return 0; 1051 return 0;
1055} 1052}
1056 1053
1054#ifdef CONFIG_PM
1055static int snd_opti9xx_suspend(struct snd_card *card)
1056{
1057 struct snd_opti9xx *chip = card->private_data;
1058
1059 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1060 chip->codec->suspend(chip->codec);
1061 return 0;
1062}
1063
1064static int snd_opti9xx_resume(struct snd_card *card)
1065{
1066 struct snd_opti9xx *chip = card->private_data;
1067 int error, xdma2;
1068#if defined(CS4231) || defined(OPTi93X)
1069 xdma2 = dma2;
1070#else
1071 xdma2 = -1;
1072#endif
1073
1074 error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2,
1075 mpu_port, mpu_irq);
1076 if (error)
1077 return error;
1078 chip->codec->resume(chip->codec);
1079 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
1080 return 0;
1081}
1082
1083static int snd_opti9xx_isa_suspend(struct device *dev, unsigned int n,
1084 pm_message_t state)
1085{
1086 return snd_opti9xx_suspend(dev_get_drvdata(dev));
1087}
1088
1089static int snd_opti9xx_isa_resume(struct device *dev, unsigned int n)
1090{
1091 return snd_opti9xx_resume(dev_get_drvdata(dev));
1092}
1093#endif
1094
1057static struct isa_driver snd_opti9xx_driver = { 1095static struct isa_driver snd_opti9xx_driver = {
1058 .match = snd_opti9xx_isa_match, 1096 .match = snd_opti9xx_isa_match,
1059 .probe = snd_opti9xx_isa_probe, 1097 .probe = snd_opti9xx_isa_probe,
1060 .remove = __devexit_p(snd_opti9xx_isa_remove), 1098 .remove = __devexit_p(snd_opti9xx_isa_remove),
1061 /* FIXME: suspend/resume */ 1099#ifdef CONFIG_PM
1100 .suspend = snd_opti9xx_isa_suspend,
1101 .resume = snd_opti9xx_isa_resume,
1102#endif
1062 .driver = { 1103 .driver = {
1063 .name = DEV_NAME 1104 .name = DEV_NAME
1064 }, 1105 },
@@ -1124,12 +1165,29 @@ static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard)
1124 snd_opti9xx_pnp_is_probed = 0; 1165 snd_opti9xx_pnp_is_probed = 0;
1125} 1166}
1126 1167
1168#ifdef CONFIG_PM
1169static int snd_opti9xx_pnp_suspend(struct pnp_card_link *pcard,
1170 pm_message_t state)
1171{
1172 return snd_opti9xx_suspend(pnp_get_card_drvdata(pcard));
1173}
1174
1175static int snd_opti9xx_pnp_resume(struct pnp_card_link *pcard)
1176{
1177 return snd_opti9xx_resume(pnp_get_card_drvdata(pcard));
1178}
1179#endif
1180
1127static struct pnp_card_driver opti9xx_pnpc_driver = { 1181static struct pnp_card_driver opti9xx_pnpc_driver = {
1128 .flags = PNP_DRIVER_RES_DISABLE, 1182 .flags = PNP_DRIVER_RES_DISABLE,
1129 .name = "opti9xx", 1183 .name = "opti9xx",
1130 .id_table = snd_opti9xx_pnpids, 1184 .id_table = snd_opti9xx_pnpids,
1131 .probe = snd_opti9xx_pnp_probe, 1185 .probe = snd_opti9xx_pnp_probe,
1132 .remove = __devexit_p(snd_opti9xx_pnp_remove), 1186 .remove = __devexit_p(snd_opti9xx_pnp_remove),
1187#ifdef CONFIG_PM
1188 .suspend = snd_opti9xx_pnp_suspend,
1189 .resume = snd_opti9xx_pnp_resume,
1190#endif
1133}; 1191};
1134#endif 1192#endif
1135 1193
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index 49c8a0c2442c..360b08b03e1d 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -1456,7 +1456,6 @@ static struct snd_pcm_hardware snd_wss_playback =
1456{ 1456{
1457 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1457 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1458 SNDRV_PCM_INFO_MMAP_VALID | 1458 SNDRV_PCM_INFO_MMAP_VALID |
1459 SNDRV_PCM_INFO_RESUME |
1460 SNDRV_PCM_INFO_SYNC_START), 1459 SNDRV_PCM_INFO_SYNC_START),
1461 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | 1460 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
1462 SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE), 1461 SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE),
@@ -1657,6 +1656,10 @@ static void snd_wss_resume(struct snd_wss *chip)
1657 break; 1656 break;
1658 } 1657 }
1659 } 1658 }
1659 /* Yamaha needs this to resume properly */
1660 if (chip->hardware == WSS_HW_OPL3SA2)
1661 snd_wss_out(chip, CS4231_PLAYBK_FORMAT,
1662 chip->image[CS4231_PLAYBK_FORMAT]);
1660 spin_unlock_irqrestore(&chip->reg_lock, flags); 1663 spin_unlock_irqrestore(&chip->reg_lock, flags);
1661#if 1 1664#if 1
1662 snd_wss_mce_down(chip); 1665 snd_wss_mce_down(chip);
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index 09d46484bc1a..7d8803a00b79 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -69,7 +69,6 @@
69#include <linux/sound.h> 69#include <linux/sound.h>
70#include <linux/slab.h> 70#include <linux/slab.h>
71#include <linux/soundcard.h> 71#include <linux/soundcard.h>
72#include <linux/ac97_codec.h>
73#include <linux/pci.h> 72#include <linux/pci.h>
74#include <linux/bitops.h> 73#include <linux/bitops.h>
75#include <linux/interrupt.h> 74#include <linux/interrupt.h>
@@ -199,6 +198,22 @@ static const char invalid_magic[] =
199 } \ 198 } \
200}) 199})
201 200
201/* AC97 registers */
202#define AC97_MASTER_VOL_STEREO 0x0002 /* Line Out */
203#define AC97_PCBEEP_VOL 0x000a /* none */
204#define AC97_PHONE_VOL 0x000c /* TAD Input (mono) */
205#define AC97_MIC_VOL 0x000e /* MIC Input (mono) */
206#define AC97_LINEIN_VOL 0x0010 /* Line Input (stereo) */
207#define AC97_CD_VOL 0x0012 /* CD Input (stereo) */
208#define AC97_AUX_VOL 0x0016 /* Aux Input (stereo) */
209#define AC97_PCMOUT_VOL 0x0018 /* Wave Output (stereo) */
210#define AC97_RECORD_SELECT 0x001a /* */
211#define AC97_RECORD_GAIN 0x001c
212#define AC97_GENERAL_PURPOSE 0x0020
213#define AC97_3D_CONTROL 0x0022
214#define AC97_POWER_CONTROL 0x0026
215#define AC97_VENDOR_ID1 0x007c
216
202struct list_head cs4297a_devs = { &cs4297a_devs, &cs4297a_devs }; 217struct list_head cs4297a_devs = { &cs4297a_devs, &cs4297a_devs };
203 218
204typedef struct serdma_descr_s { 219typedef struct serdma_descr_s {
diff --git a/sound/pci/au88x0/au88x0_mixer.c b/sound/pci/au88x0/au88x0_mixer.c
index 557c782ae4fc..fa13efbebdaf 100644
--- a/sound/pci/au88x0/au88x0_mixer.c
+++ b/sound/pci/au88x0/au88x0_mixer.c
@@ -10,6 +10,15 @@
10#include <sound/core.h> 10#include <sound/core.h>
11#include "au88x0.h" 11#include "au88x0.h"
12 12
13static int remove_ctl(struct snd_card *card, const char *name)
14{
15 struct snd_ctl_elem_id id;
16 memset(&id, 0, sizeof(id));
17 strcpy(id.name, name);
18 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
19 return snd_ctl_remove_id(card, &id);
20}
21
13static int __devinit snd_vortex_mixer(vortex_t * vortex) 22static int __devinit snd_vortex_mixer(vortex_t * vortex)
14{ 23{
15 struct snd_ac97_bus *pbus; 24 struct snd_ac97_bus *pbus;
@@ -28,5 +37,7 @@ static int __devinit snd_vortex_mixer(vortex_t * vortex)
28 ac97.scaps = AC97_SCAP_NO_SPDIF; 37 ac97.scaps = AC97_SCAP_NO_SPDIF;
29 err = snd_ac97_mixer(pbus, &ac97, &vortex->codec); 38 err = snd_ac97_mixer(pbus, &ac97, &vortex->codec);
30 vortex->isquad = ((vortex->codec == NULL) ? 0 : (vortex->codec->ext_id&0x80)); 39 vortex->isquad = ((vortex->codec == NULL) ? 0 : (vortex->codec->ext_id&0x80));
40 remove_ctl(vortex->card, "Master Mono Playback Volume");
41 remove_ctl(vortex->card, "Master Mono Playback Switch");
31 return err; 42 return err;
32} 43}
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 82c8d8c5c52a..a41106d745ca 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1321,35 +1321,30 @@ static int snd_es1938_put_double(struct snd_kcontrol *kcontrol,
1321 return change; 1321 return change;
1322} 1322}
1323 1323
1324static unsigned int db_scale_master[] = { 1324static const DECLARE_TLV_DB_RANGE(db_scale_master,
1325 TLV_DB_RANGE_HEAD(2),
1326 0, 54, TLV_DB_SCALE_ITEM(-3600, 50, 1), 1325 0, 54, TLV_DB_SCALE_ITEM(-3600, 50, 1),
1327 54, 63, TLV_DB_SCALE_ITEM(-900, 100, 0), 1326 54, 63, TLV_DB_SCALE_ITEM(-900, 100, 0),
1328}; 1327);
1329 1328
1330static unsigned int db_scale_audio1[] = { 1329static const DECLARE_TLV_DB_RANGE(db_scale_audio1,
1331 TLV_DB_RANGE_HEAD(2),
1332 0, 8, TLV_DB_SCALE_ITEM(-3300, 300, 1), 1330 0, 8, TLV_DB_SCALE_ITEM(-3300, 300, 1),
1333 8, 15, TLV_DB_SCALE_ITEM(-900, 150, 0), 1331 8, 15, TLV_DB_SCALE_ITEM(-900, 150, 0),
1334}; 1332);
1335 1333
1336static unsigned int db_scale_audio2[] = { 1334static const DECLARE_TLV_DB_RANGE(db_scale_audio2,
1337 TLV_DB_RANGE_HEAD(2),
1338 0, 8, TLV_DB_SCALE_ITEM(-3450, 300, 1), 1335 0, 8, TLV_DB_SCALE_ITEM(-3450, 300, 1),
1339 8, 15, TLV_DB_SCALE_ITEM(-1050, 150, 0), 1336 8, 15, TLV_DB_SCALE_ITEM(-1050, 150, 0),
1340}; 1337);
1341 1338
1342static unsigned int db_scale_mic[] = { 1339static const DECLARE_TLV_DB_RANGE(db_scale_mic,
1343 TLV_DB_RANGE_HEAD(2),
1344 0, 8, TLV_DB_SCALE_ITEM(-2400, 300, 1), 1340 0, 8, TLV_DB_SCALE_ITEM(-2400, 300, 1),
1345 8, 15, TLV_DB_SCALE_ITEM(0, 150, 0), 1341 8, 15, TLV_DB_SCALE_ITEM(0, 150, 0),
1346}; 1342);
1347 1343
1348static unsigned int db_scale_line[] = { 1344static const DECLARE_TLV_DB_RANGE(db_scale_line,
1349 TLV_DB_RANGE_HEAD(2),
1350 0, 8, TLV_DB_SCALE_ITEM(-3150, 300, 1), 1345 0, 8, TLV_DB_SCALE_ITEM(-3150, 300, 1),
1351 8, 15, TLV_DB_SCALE_ITEM(-750, 150, 0), 1346 8, 15, TLV_DB_SCALE_ITEM(-750, 150, 0),
1352}; 1347);
1353 1348
1354static const DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0); 1349static const DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0);
1355 1350
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index deef21399586..adb3b4c7917e 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -361,74 +361,6 @@ MODULE_PARM_DESC(amp_gpio, "GPIO pin number for external amp. (default = -1)");
361#define DSP2HOST_REQ_I2SRATE 0x02 361#define DSP2HOST_REQ_I2SRATE 0x02
362#define DSP2HOST_REQ_TIMER 0x04 362#define DSP2HOST_REQ_TIMER 0x04
363 363
364/* AC97 registers */
365/* XXX fix this crap up */
366/*#define AC97_RESET 0x00*/
367
368#define AC97_VOL_MUTE_B 0x8000
369#define AC97_VOL_M 0x1F
370#define AC97_LEFT_VOL_S 8
371
372#define AC97_MASTER_VOL 0x02
373#define AC97_LINE_LEVEL_VOL 0x04
374#define AC97_MASTER_MONO_VOL 0x06
375#define AC97_PC_BEEP_VOL 0x0A
376#define AC97_PC_BEEP_VOL_M 0x0F
377#define AC97_SROUND_MASTER_VOL 0x38
378#define AC97_PC_BEEP_VOL_S 1
379
380/*#define AC97_PHONE_VOL 0x0C
381#define AC97_MIC_VOL 0x0E*/
382#define AC97_MIC_20DB_ENABLE 0x40
383
384/*#define AC97_LINEIN_VOL 0x10
385#define AC97_CD_VOL 0x12
386#define AC97_VIDEO_VOL 0x14
387#define AC97_AUX_VOL 0x16*/
388#define AC97_PCM_OUT_VOL 0x18
389/*#define AC97_RECORD_SELECT 0x1A*/
390#define AC97_RECORD_MIC 0x00
391#define AC97_RECORD_CD 0x01
392#define AC97_RECORD_VIDEO 0x02
393#define AC97_RECORD_AUX 0x03
394#define AC97_RECORD_MONO_MUX 0x02
395#define AC97_RECORD_DIGITAL 0x03
396#define AC97_RECORD_LINE 0x04
397#define AC97_RECORD_STEREO 0x05
398#define AC97_RECORD_MONO 0x06
399#define AC97_RECORD_PHONE 0x07
400
401/*#define AC97_RECORD_GAIN 0x1C*/
402#define AC97_RECORD_VOL_M 0x0F
403
404/*#define AC97_GENERAL_PURPOSE 0x20*/
405#define AC97_POWER_DOWN_CTRL 0x26
406#define AC97_ADC_READY 0x0001
407#define AC97_DAC_READY 0x0002
408#define AC97_ANALOG_READY 0x0004
409#define AC97_VREF_ON 0x0008
410#define AC97_PR0 0x0100
411#define AC97_PR1 0x0200
412#define AC97_PR2 0x0400
413#define AC97_PR3 0x0800
414#define AC97_PR4 0x1000
415
416#define AC97_RESERVED1 0x28
417
418#define AC97_VENDOR_TEST 0x5A
419
420#define AC97_CLOCK_DELAY 0x5C
421#define AC97_LINEOUT_MUX_SEL 0x0001
422#define AC97_MONO_MUX_SEL 0x0002
423#define AC97_CLOCK_DELAY_SEL 0x1F
424#define AC97_DAC_CDS_SHIFT 6
425#define AC97_ADC_CDS_SHIFT 11
426
427#define AC97_MULTI_CHANNEL_SEL 0x74
428
429/*#define AC97_VENDOR_ID1 0x7C
430#define AC97_VENDOR_ID2 0x7E*/
431
432/* 364/*
433 * ASSP control regs 365 * ASSP control regs
434 */ 366 */
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 0435f45e9513..e3ac1f768ff6 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1368,6 +1368,67 @@ static void pcxhr_proc_gpo_write(struct snd_info_entry *entry,
1368 } 1368 }
1369} 1369}
1370 1370
1371/* Access to the results of the CMD_GET_TIME_CODE RMH */
1372#define TIME_CODE_VALID_MASK 0x00800000
1373#define TIME_CODE_NEW_MASK 0x00400000
1374#define TIME_CODE_BACK_MASK 0x00200000
1375#define TIME_CODE_WAIT_MASK 0x00100000
1376
1377/* Values for the CMD_MANAGE_SIGNAL RMH */
1378#define MANAGE_SIGNAL_TIME_CODE 0x01
1379#define MANAGE_SIGNAL_MIDI 0x02
1380
1381/* linear time code read proc*/
1382static void pcxhr_proc_ltc(struct snd_info_entry *entry,
1383 struct snd_info_buffer *buffer)
1384{
1385 struct snd_pcxhr *chip = entry->private_data;
1386 struct pcxhr_mgr *mgr = chip->mgr;
1387 struct pcxhr_rmh rmh;
1388 unsigned int ltcHrs, ltcMin, ltcSec, ltcFrm;
1389 int err;
1390 /* commands available when embedded DSP is running */
1391 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) {
1392 snd_iprintf(buffer, "no firmware loaded\n");
1393 return;
1394 }
1395 if (!mgr->capture_ltc) {
1396 pcxhr_init_rmh(&rmh, CMD_MANAGE_SIGNAL);
1397 rmh.cmd[0] |= MANAGE_SIGNAL_TIME_CODE;
1398 err = pcxhr_send_msg(mgr, &rmh);
1399 if (err) {
1400 snd_iprintf(buffer, "ltc not activated (%d)\n", err);
1401 return;
1402 }
1403 if (mgr->is_hr_stereo)
1404 hr222_manage_timecode(mgr, 1);
1405 else
1406 pcxhr_write_io_num_reg_cont(mgr, REG_CONT_VALSMPTE,
1407 REG_CONT_VALSMPTE, NULL);
1408 mgr->capture_ltc = 1;
1409 }
1410 pcxhr_init_rmh(&rmh, CMD_GET_TIME_CODE);
1411 err = pcxhr_send_msg(mgr, &rmh);
1412 if (err) {
1413 snd_iprintf(buffer, "ltc read error (err=%d)\n", err);
1414 return ;
1415 }
1416 ltcHrs = 10*((rmh.stat[0] >> 8) & 0x3) + (rmh.stat[0] & 0xf);
1417 ltcMin = 10*((rmh.stat[1] >> 16) & 0x7) + ((rmh.stat[1] >> 8) & 0xf);
1418 ltcSec = 10*(rmh.stat[1] & 0x7) + ((rmh.stat[2] >> 16) & 0xf);
1419 ltcFrm = 10*((rmh.stat[2] >> 8) & 0x3) + (rmh.stat[2] & 0xf);
1420
1421 snd_iprintf(buffer, "timecode: %02u:%02u:%02u-%02u\n",
1422 ltcHrs, ltcMin, ltcSec, ltcFrm);
1423 snd_iprintf(buffer, "raw: 0x%04x%06x%06x\n", rmh.stat[0] & 0x00ffff,
1424 rmh.stat[1] & 0xffffff, rmh.stat[2] & 0xffffff);
1425 /*snd_iprintf(buffer, "dsp ref time: 0x%06x%06x\n",
1426 rmh.stat[3] & 0xffffff, rmh.stat[4] & 0xffffff);*/
1427 if (!(rmh.stat[0] & TIME_CODE_VALID_MASK)) {
1428 snd_iprintf(buffer, "warning: linear timecode not valid\n");
1429 }
1430}
1431
1371static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip) 1432static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip)
1372{ 1433{
1373 struct snd_info_entry *entry; 1434 struct snd_info_entry *entry;
@@ -1383,6 +1444,8 @@ static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip)
1383 entry->c.text.write = pcxhr_proc_gpo_write; 1444 entry->c.text.write = pcxhr_proc_gpo_write;
1384 entry->mode |= S_IWUSR; 1445 entry->mode |= S_IWUSR;
1385 } 1446 }
1447 if (!snd_card_proc_new(chip->card, "ltc", &entry))
1448 snd_info_set_text_ops(entry, chip, pcxhr_proc_ltc);
1386} 1449}
1387/* end of proc interface */ 1450/* end of proc interface */
1388 1451
diff --git a/sound/pci/pcxhr/pcxhr.h b/sound/pci/pcxhr/pcxhr.h
index bda776c49884..a4c602c45173 100644
--- a/sound/pci/pcxhr/pcxhr.h
+++ b/sound/pci/pcxhr/pcxhr.h
@@ -103,6 +103,7 @@ struct pcxhr_mgr {
103 unsigned int board_has_mic:1; /* if 1 the board has microphone input */ 103 unsigned int board_has_mic:1; /* if 1 the board has microphone input */
104 unsigned int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */ 104 unsigned int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */
105 unsigned int mono_capture:1; /* if 1 the board does mono capture */ 105 unsigned int mono_capture:1; /* if 1 the board does mono capture */
106 unsigned int capture_ltc:1; /* if 1 the board captures LTC input */
106 107
107 struct snd_dma_buffer hostport; 108 struct snd_dma_buffer hostport;
108 109
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c
index 304411c1fe4b..b33db1e006e7 100644
--- a/sound/pci/pcxhr/pcxhr_core.c
+++ b/sound/pci/pcxhr/pcxhr_core.c
@@ -504,6 +504,8 @@ static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = {
504[CMD_FORMAT_STREAM_IN] = { 0x870000, 0, RMH_SSIZE_FIXED }, 504[CMD_FORMAT_STREAM_IN] = { 0x870000, 0, RMH_SSIZE_FIXED },
505[CMD_STREAM_SAMPLE_COUNT] = { 0x902000, 2, RMH_SSIZE_FIXED }, 505[CMD_STREAM_SAMPLE_COUNT] = { 0x902000, 2, RMH_SSIZE_FIXED },
506[CMD_AUDIO_LEVEL_ADJUST] = { 0xc22000, 0, RMH_SSIZE_FIXED }, 506[CMD_AUDIO_LEVEL_ADJUST] = { 0xc22000, 0, RMH_SSIZE_FIXED },
507[CMD_GET_TIME_CODE] = { 0x060000, 5, RMH_SSIZE_FIXED },
508[CMD_MANAGE_SIGNAL] = { 0x0f0000, 0, RMH_SSIZE_FIXED },
507}; 509};
508 510
509#ifdef CONFIG_SND_DEBUG_VERBOSE 511#ifdef CONFIG_SND_DEBUG_VERBOSE
@@ -533,6 +535,8 @@ static char* cmd_names[] = {
533[CMD_FORMAT_STREAM_IN] = "CMD_FORMAT_STREAM_IN", 535[CMD_FORMAT_STREAM_IN] = "CMD_FORMAT_STREAM_IN",
534[CMD_STREAM_SAMPLE_COUNT] = "CMD_STREAM_SAMPLE_COUNT", 536[CMD_STREAM_SAMPLE_COUNT] = "CMD_STREAM_SAMPLE_COUNT",
535[CMD_AUDIO_LEVEL_ADJUST] = "CMD_AUDIO_LEVEL_ADJUST", 537[CMD_AUDIO_LEVEL_ADJUST] = "CMD_AUDIO_LEVEL_ADJUST",
538[CMD_GET_TIME_CODE] = "CMD_GET_TIME_CODE",
539[CMD_MANAGE_SIGNAL] = "CMD_MANAGE_SIGNAL",
536}; 540};
537#endif 541#endif
538 542
@@ -1133,13 +1137,12 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr,
1133 hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24; 1137 hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24;
1134 hw_sample_count += (u_int64_t)rmh.stat[1]; 1138 hw_sample_count += (u_int64_t)rmh.stat[1];
1135 1139
1136 snd_printdd("stream %c%d : abs samples real(%ld) timer(%ld)\n", 1140 snd_printdd("stream %c%d : abs samples real(%llu) timer(%llu)\n",
1137 stream->pipe->is_capture ? 'C' : 'P', 1141 stream->pipe->is_capture ? 'C' : 'P',
1138 stream->substream->number, 1142 stream->substream->number,
1139 (long unsigned int)hw_sample_count, 1143 hw_sample_count,
1140 (long unsigned int)(stream->timer_abs_periods + 1144 stream->timer_abs_periods + stream->timer_period_frag +
1141 stream->timer_period_frag + 1145 mgr->granularity);
1142 mgr->granularity));
1143 return hw_sample_count; 1146 return hw_sample_count;
1144} 1147}
1145 1148
@@ -1243,10 +1246,18 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
1243 1246
1244 if ((dsp_time_diff < 0) && 1247 if ((dsp_time_diff < 0) &&
1245 (mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) { 1248 (mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) {
1246 snd_printdd("ERROR DSP TIME old(%d) new(%d) -> " 1249 /* handle dsp counter wraparound without resync */
1247 "resynchronize all streams\n", 1250 int tmp_diff = dsp_time_diff + PCXHR_DSP_TIME_MASK + 1;
1251 snd_printdd("WARNING DSP timestamp old(%d) new(%d)",
1248 mgr->dsp_time_last, dsp_time_new); 1252 mgr->dsp_time_last, dsp_time_new);
1249 mgr->dsp_time_err++; 1253 if (tmp_diff > 0 && tmp_diff <= (2*mgr->granularity)) {
1254 snd_printdd("-> timestamp wraparound OK: "
1255 "diff=%d\n", tmp_diff);
1256 dsp_time_diff = tmp_diff;
1257 } else {
1258 snd_printdd("-> resynchronize all streams\n");
1259 mgr->dsp_time_err++;
1260 }
1250 } 1261 }
1251#ifdef CONFIG_SND_DEBUG_VERBOSE 1262#ifdef CONFIG_SND_DEBUG_VERBOSE
1252 if (dsp_time_diff == 0) 1263 if (dsp_time_diff == 0)
diff --git a/sound/pci/pcxhr/pcxhr_core.h b/sound/pci/pcxhr/pcxhr_core.h
index be0173796cdb..a81ab6b811e7 100644
--- a/sound/pci/pcxhr/pcxhr_core.h
+++ b/sound/pci/pcxhr/pcxhr_core.h
@@ -79,6 +79,8 @@ enum {
79 CMD_FORMAT_STREAM_IN, /* cmd_len >= 4 stat_len = 0 */ 79 CMD_FORMAT_STREAM_IN, /* cmd_len >= 4 stat_len = 0 */
80 CMD_STREAM_SAMPLE_COUNT, /* cmd_len = 2 stat_len = (2 * nb_stream) */ 80 CMD_STREAM_SAMPLE_COUNT, /* cmd_len = 2 stat_len = (2 * nb_stream) */
81 CMD_AUDIO_LEVEL_ADJUST, /* cmd_len = 3 stat_len = 0 */ 81 CMD_AUDIO_LEVEL_ADJUST, /* cmd_len = 3 stat_len = 0 */
82 CMD_GET_TIME_CODE, /* cmd_len = 1 stat_len = 5 */
83 CMD_MANAGE_SIGNAL, /* cmd_len = 1 stat_len = 0 */
82 CMD_LAST_INDEX 84 CMD_LAST_INDEX
83}; 85};
84 86
@@ -116,7 +118,7 @@ int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh);
116#define IO_NUM_REG_OUT_ANA_LEVEL 20 118#define IO_NUM_REG_OUT_ANA_LEVEL 20
117#define IO_NUM_REG_IN_ANA_LEVEL 21 119#define IO_NUM_REG_IN_ANA_LEVEL 21
118 120
119 121#define REG_CONT_VALSMPTE 0x000800
120#define REG_CONT_UNMUTE_INPUTS 0x020000 122#define REG_CONT_UNMUTE_INPUTS 0x020000
121 123
122/* parameters used with register IO_NUM_REG_STATUS */ 124/* parameters used with register IO_NUM_REG_STATUS */
diff --git a/sound/pci/pcxhr/pcxhr_mix22.c b/sound/pci/pcxhr/pcxhr_mix22.c
index 1cb82c0a9cb3..84fe57626eba 100644
--- a/sound/pci/pcxhr/pcxhr_mix22.c
+++ b/sound/pci/pcxhr/pcxhr_mix22.c
@@ -53,6 +53,7 @@
53#define PCXHR_DSP_RESET_DSP 0x01 53#define PCXHR_DSP_RESET_DSP 0x01
54#define PCXHR_DSP_RESET_MUTE 0x02 54#define PCXHR_DSP_RESET_MUTE 0x02
55#define PCXHR_DSP_RESET_CODEC 0x08 55#define PCXHR_DSP_RESET_CODEC 0x08
56#define PCXHR_DSP_RESET_SMPTE 0x10
56#define PCXHR_DSP_RESET_GPO_OFFSET 5 57#define PCXHR_DSP_RESET_GPO_OFFSET 5
57#define PCXHR_DSP_RESET_GPO_MASK 0x60 58#define PCXHR_DSP_RESET_GPO_MASK 0x60
58 59
@@ -527,6 +528,16 @@ int hr222_write_gpo(struct pcxhr_mgr *mgr, int value)
527 return 0; 528 return 0;
528} 529}
529 530
531int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable)
532{
533 if (enable)
534 mgr->dsp_reset |= PCXHR_DSP_RESET_SMPTE;
535 else
536 mgr->dsp_reset &= ~PCXHR_DSP_RESET_SMPTE;
537
538 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, mgr->dsp_reset);
539 return 0;
540}
530 541
531int hr222_update_analog_audio_level(struct snd_pcxhr *chip, 542int hr222_update_analog_audio_level(struct snd_pcxhr *chip,
532 int is_capture, int channel) 543 int is_capture, int channel)
diff --git a/sound/pci/pcxhr/pcxhr_mix22.h b/sound/pci/pcxhr/pcxhr_mix22.h
index 5a37a0007e8f..5971b9933f41 100644
--- a/sound/pci/pcxhr/pcxhr_mix22.h
+++ b/sound/pci/pcxhr/pcxhr_mix22.h
@@ -34,6 +34,7 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
34 34
35int hr222_read_gpio(struct pcxhr_mgr *mgr, int is_gpi, int *value); 35int hr222_read_gpio(struct pcxhr_mgr *mgr, int is_gpi, int *value);
36int hr222_write_gpo(struct pcxhr_mgr *mgr, int value); 36int hr222_write_gpo(struct pcxhr_mgr *mgr, int value);
37int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable);
37 38
38#define HR222_LINE_PLAYBACK_LEVEL_MIN 0 /* -25.5 dB */ 39#define HR222_LINE_PLAYBACK_LEVEL_MIN 0 /* -25.5 dB */
39#define HR222_LINE_PLAYBACK_ZERO_LEVEL 51 /* 0.0 dB */ 40#define HR222_LINE_PLAYBACK_ZERO_LEVEL 51 /* 0.0 dB */
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 64aed432ae22..7da0d0aa72cb 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -485,7 +485,7 @@ static int __devinit snd_probe(struct usb_interface *intf,
485 const struct usb_device_id *id) 485 const struct usb_device_id *id)
486{ 486{
487 int ret; 487 int ret;
488 struct snd_card *card; 488 struct snd_card *card = NULL;
489 struct usb_device *device = interface_to_usbdev(intf); 489 struct usb_device *device = interface_to_usbdev(intf);
490 490
491 ret = create_card(device, intf, &card); 491 ret = create_card(device, intf, &card);
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 41f4b6911920..690000db0ec0 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -42,6 +42,13 @@
42 42
43extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl; 43extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
44 44
45struct std_mono_table {
46 unsigned int unitid, control, cmask;
47 int val_type;
48 const char *name;
49 snd_kcontrol_tlv_rw_t *tlv_callback;
50};
51
45/* private_free callback */ 52/* private_free callback */
46static void usb_mixer_elem_free(struct snd_kcontrol *kctl) 53static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
47{ 54{
@@ -114,6 +121,25 @@ static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
114} 121}
115 122
116/* 123/*
124 * Create a set of standard UAC controls from a table
125 */
126static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
127 struct std_mono_table *t)
128{
129 int err;
130
131 while (t->name != NULL) {
132 err = snd_create_std_mono_ctl(mixer, t->unitid, t->control,
133 t->cmask, t->val_type, t->name, t->tlv_callback);
134 if (err < 0)
135 return err;
136 t++;
137 }
138
139 return 0;
140}
141
142/*
117 * Sound Blaster remote control configuration 143 * Sound Blaster remote control configuration
118 * 144 *
119 * format of remote control data: 145 * format of remote control data:
@@ -916,61 +942,6 @@ static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
916 return 0; 942 return 0;
917} 943}
918 944
919
920/*
921 * Create mixer for Electrix Ebox-44
922 *
923 * The mixer units from this device are corrupt, and even where they
924 * are valid they presents mono controls as L and R channels of
925 * stereo. So we create a good mixer in code.
926 */
927
928static int snd_ebox44_create_mixer(struct usb_mixer_interface *mixer)
929{
930 int err;
931
932 err = snd_create_std_mono_ctl(mixer, 4, 1, 0x0, USB_MIXER_INV_BOOLEAN,
933 "Headphone Playback Switch", NULL);
934 if (err < 0)
935 return err;
936 err = snd_create_std_mono_ctl(mixer, 4, 2, 0x1, USB_MIXER_S16,
937 "Headphone A Mix Playback Volume", NULL);
938 if (err < 0)
939 return err;
940 err = snd_create_std_mono_ctl(mixer, 4, 2, 0x2, USB_MIXER_S16,
941 "Headphone B Mix Playback Volume", NULL);
942 if (err < 0)
943 return err;
944
945 err = snd_create_std_mono_ctl(mixer, 7, 1, 0x0, USB_MIXER_INV_BOOLEAN,
946 "Output Playback Switch", NULL);
947 if (err < 0)
948 return err;
949 err = snd_create_std_mono_ctl(mixer, 7, 2, 0x1, USB_MIXER_S16,
950 "Output A Playback Volume", NULL);
951 if (err < 0)
952 return err;
953 err = snd_create_std_mono_ctl(mixer, 7, 2, 0x2, USB_MIXER_S16,
954 "Output B Playback Volume", NULL);
955 if (err < 0)
956 return err;
957
958 err = snd_create_std_mono_ctl(mixer, 10, 1, 0x0, USB_MIXER_INV_BOOLEAN,
959 "Input Capture Switch", NULL);
960 if (err < 0)
961 return err;
962 err = snd_create_std_mono_ctl(mixer, 10, 2, 0x1, USB_MIXER_S16,
963 "Input A Capture Volume", NULL);
964 if (err < 0)
965 return err;
966 err = snd_create_std_mono_ctl(mixer, 10, 2, 0x2, USB_MIXER_S16,
967 "Input B Capture Volume", NULL);
968 if (err < 0)
969 return err;
970
971 return 0;
972}
973
974void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, 945void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
975 unsigned char samplerate_id) 946 unsigned char samplerate_id)
976{ 947{
@@ -990,6 +961,81 @@ void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
990 } 961 }
991} 962}
992 963
964/*
965 * The mixer units for Ebox-44 are corrupt, and even where they
966 * are valid they presents mono controls as L and R channels of
967 * stereo. So we provide a good mixer here.
968 */
969struct std_mono_table ebox44_table[] = {
970 {
971 .unitid = 4,
972 .control = 1,
973 .cmask = 0x0,
974 .val_type = USB_MIXER_INV_BOOLEAN,
975 .name = "Headphone Playback Switch"
976 },
977 {
978 .unitid = 4,
979 .control = 2,
980 .cmask = 0x1,
981 .val_type = USB_MIXER_S16,
982 .name = "Headphone A Mix Playback Volume"
983 },
984 {
985 .unitid = 4,
986 .control = 2,
987 .cmask = 0x2,
988 .val_type = USB_MIXER_S16,
989 .name = "Headphone B Mix Playback Volume"
990 },
991
992 {
993 .unitid = 7,
994 .control = 1,
995 .cmask = 0x0,
996 .val_type = USB_MIXER_INV_BOOLEAN,
997 .name = "Output Playback Switch"
998 },
999 {
1000 .unitid = 7,
1001 .control = 2,
1002 .cmask = 0x1,
1003 .val_type = USB_MIXER_S16,
1004 .name = "Output A Playback Volume"
1005 },
1006 {
1007 .unitid = 7,
1008 .control = 2,
1009 .cmask = 0x2,
1010 .val_type = USB_MIXER_S16,
1011 .name = "Output B Playback Volume"
1012 },
1013
1014 {
1015 .unitid = 10,
1016 .control = 1,
1017 .cmask = 0x0,
1018 .val_type = USB_MIXER_INV_BOOLEAN,
1019 .name = "Input Capture Switch"
1020 },
1021 {
1022 .unitid = 10,
1023 .control = 2,
1024 .cmask = 0x1,
1025 .val_type = USB_MIXER_S16,
1026 .name = "Input A Capture Volume"
1027 },
1028 {
1029 .unitid = 10,
1030 .control = 2,
1031 .cmask = 0x2,
1032 .val_type = USB_MIXER_S16,
1033 .name = "Input B Capture Volume"
1034 },
1035
1036 {}
1037};
1038
993int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) 1039int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
994{ 1040{
995 int err = 0; 1041 int err = 0;
@@ -1035,7 +1081,8 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
1035 break; 1081 break;
1036 1082
1037 case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */ 1083 case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
1038 err = snd_ebox44_create_mixer(mixer); 1084 /* detection is disabled in mixer_maps.c */
1085 err = snd_create_std_mono_table(mixer, ebox44_table);
1039 break; 1086 break;
1040 } 1087 }
1041 1088