aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/Kbuild10
-rw-r--r--include/sound/asequencer.h594
-rw-r--r--include/sound/asound.h935
-rw-r--r--include/sound/emu10k1.h355
-rw-r--r--include/sound/pcm.h3
-rw-r--r--include/sound/sb16_csp.h104
-rw-r--r--include/uapi/sound/Kbuild10
-rw-r--r--include/uapi/sound/asequencer.h614
-rw-r--r--include/uapi/sound/asound.h961
-rw-r--r--include/uapi/sound/asound_fm.h (renamed from include/sound/asound_fm.h)0
-rw-r--r--include/uapi/sound/compress_offload.h (renamed from include/sound/compress_offload.h)0
-rw-r--r--include/uapi/sound/compress_params.h (renamed from include/sound/compress_params.h)0
-rw-r--r--include/uapi/sound/emu10k1.h373
-rw-r--r--include/uapi/sound/hdsp.h (renamed from include/sound/hdsp.h)0
-rw-r--r--include/uapi/sound/hdspm.h (renamed from include/sound/hdspm.h)0
-rw-r--r--include/uapi/sound/sb16_csp.h122
-rw-r--r--include/uapi/sound/sfnt_info.h (renamed from include/sound/sfnt_info.h)0
-rw-r--r--sound/core/pcm_compat.c20
-rw-r--r--sound/core/pcm_lib.c57
-rw-r--r--sound/core/pcm_native.c2
-rw-r--r--sound/drivers/Kconfig1
-rw-r--r--sound/drivers/aloop.c36
-rw-r--r--sound/drivers/dummy.c73
-rw-r--r--sound/isa/Kconfig4
-rw-r--r--sound/pci/Kconfig2
-rw-r--r--sound/pci/asihpi/hpidspcd.c22
-rw-r--r--sound/pci/asihpi/hpioctl.c17
-rw-r--r--sound/pci/au88x0/au88x0_core.c7
-rw-r--r--sound/pci/hda/Kconfig5
-rw-r--r--sound/pci/hda/Makefile1
-rw-r--r--sound/pci/hda/hda_codec.c92
-rw-r--r--sound/pci/hda/hda_codec.h3
-rw-r--r--sound/pci/hda/hda_intel.c128
-rw-r--r--sound/pci/hda/hda_intel_trace.h62
-rw-r--r--sound/pci/hda/hda_jack.c24
-rw-r--r--sound/pci/hda/hda_jack.h2
-rw-r--r--sound/pci/hda/hda_local.h8
-rw-r--r--sound/pci/hda/patch_cirrus.c5
-rw-r--r--sound/pci/hda/patch_conexant.c44
-rw-r--r--sound/pci/hda/patch_hdmi.c7
-rw-r--r--sound/pci/hda/patch_realtek.c7
-rw-r--r--sound/pci/hda/patch_sigmatel.c7
-rw-r--r--sound/pci/ice1712/Makefile2
-rw-r--r--sound/pci/ice1712/amp.c1
-rw-r--r--sound/pci/ice1712/aureon.c4
-rw-r--r--sound/pci/ice1712/delta.c1
-rw-r--r--sound/pci/ice1712/ews.c5
-rw-r--r--sound/pci/ice1712/hoontech.c1
-rw-r--r--sound/pci/ice1712/ice1712.c9
-rw-r--r--sound/pci/ice1712/ice1712.h12
-rw-r--r--sound/pci/ice1712/ice1724.c19
-rw-r--r--sound/pci/ice1712/juli.c4
-rw-r--r--sound/pci/ice1712/maya44.c5
-rw-r--r--sound/pci/ice1712/phase.c3
-rw-r--r--sound/pci/ice1712/pontis.c1
-rw-r--r--sound/pci/ice1712/prodigy192.c5
-rw-r--r--sound/pci/ice1712/prodigy_hifi.c1
-rw-r--r--sound/pci/ice1712/psc724.c464
-rw-r--r--sound/pci/ice1712/psc724.h13
-rw-r--r--sound/pci/ice1712/quartet.c10
-rw-r--r--sound/pci/ice1712/revo.c1
-rw-r--r--sound/pci/ice1712/se.c11
-rw-r--r--sound/pci/ice1712/vt1720_mobo.c1
-rw-r--r--sound/pci/ice1712/wm8766.c361
-rw-r--r--sound/pci/ice1712/wm8766.h163
-rw-r--r--sound/pci/ice1712/wm8776.c633
-rw-r--r--sound/pci/ice1712/wm8776.h226
-rw-r--r--sound/pci/ice1712/wtm.c1
-rw-r--r--sound/usb/Kconfig2
-rw-r--r--sound/usb/pcm.c3
-rw-r--r--sound/usb/quirks-table.h75
71 files changed, 4609 insertions, 2145 deletions
diff --git a/include/sound/Kbuild b/include/sound/Kbuild
index 6df30ed1581c..e69de29bb2d1 100644
--- a/include/sound/Kbuild
+++ b/include/sound/Kbuild
@@ -1,10 +0,0 @@
1header-y += asequencer.h
2header-y += asound.h
3header-y += asound_fm.h
4header-y += emu10k1.h
5header-y += hdsp.h
6header-y += hdspm.h
7header-y += sb16_csp.h
8header-y += sfnt_info.h
9header-y += compress_params.h
10header-y += compress_offload.h
diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h
index 1505e6d5ef82..75935ce739c5 100644
--- a/include/sound/asequencer.h
+++ b/include/sound/asequencer.h
@@ -22,294 +22,9 @@
22#ifndef __SOUND_ASEQUENCER_H 22#ifndef __SOUND_ASEQUENCER_H
23#define __SOUND_ASEQUENCER_H 23#define __SOUND_ASEQUENCER_H
24 24
25#ifdef __KERNEL__
26#include <linux/ioctl.h> 25#include <linux/ioctl.h>
27#include <sound/asound.h> 26#include <sound/asound.h>
28#endif 27#include <uapi/sound/asequencer.h>
29
30/** version of the sequencer */
31#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 1)
32
33/**
34 * definition of sequencer event types
35 */
36
37/** system messages
38 * event data type = #snd_seq_result
39 */
40#define SNDRV_SEQ_EVENT_SYSTEM 0
41#define SNDRV_SEQ_EVENT_RESULT 1
42
43/** note messages (channel specific)
44 * event data type = #snd_seq_ev_note
45 */
46#define SNDRV_SEQ_EVENT_NOTE 5
47#define SNDRV_SEQ_EVENT_NOTEON 6
48#define SNDRV_SEQ_EVENT_NOTEOFF 7
49#define SNDRV_SEQ_EVENT_KEYPRESS 8
50
51/** control messages (channel specific)
52 * event data type = #snd_seq_ev_ctrl
53 */
54#define SNDRV_SEQ_EVENT_CONTROLLER 10
55#define SNDRV_SEQ_EVENT_PGMCHANGE 11
56#define SNDRV_SEQ_EVENT_CHANPRESS 12
57#define SNDRV_SEQ_EVENT_PITCHBEND 13 /**< from -8192 to 8191 */
58#define SNDRV_SEQ_EVENT_CONTROL14 14 /**< 14 bit controller value */
59#define SNDRV_SEQ_EVENT_NONREGPARAM 15 /**< 14 bit NRPN address + 14 bit unsigned value */
60#define SNDRV_SEQ_EVENT_REGPARAM 16 /**< 14 bit RPN address + 14 bit unsigned value */
61
62/** synchronisation messages
63 * event data type = #snd_seq_ev_ctrl
64 */
65#define SNDRV_SEQ_EVENT_SONGPOS 20 /* Song Position Pointer with LSB and MSB values */
66#define SNDRV_SEQ_EVENT_SONGSEL 21 /* Song Select with song ID number */
67#define SNDRV_SEQ_EVENT_QFRAME 22 /* midi time code quarter frame */
68#define SNDRV_SEQ_EVENT_TIMESIGN 23 /* SMF Time Signature event */
69#define SNDRV_SEQ_EVENT_KEYSIGN 24 /* SMF Key Signature event */
70
71/** timer messages
72 * event data type = snd_seq_ev_queue_control
73 */
74#define SNDRV_SEQ_EVENT_START 30 /* midi Real Time Start message */
75#define SNDRV_SEQ_EVENT_CONTINUE 31 /* midi Real Time Continue message */
76#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */
77#define SNDRV_SEQ_EVENT_SETPOS_TICK 33 /* set tick queue position */
78#define SNDRV_SEQ_EVENT_SETPOS_TIME 34 /* set realtime queue position */
79#define SNDRV_SEQ_EVENT_TEMPO 35 /* (SMF) Tempo event */
80#define SNDRV_SEQ_EVENT_CLOCK 36 /* midi Real Time Clock message */
81#define SNDRV_SEQ_EVENT_TICK 37 /* midi Real Time Tick message */
82#define SNDRV_SEQ_EVENT_QUEUE_SKEW 38 /* skew queue tempo */
83
84/** others
85 * event data type = none
86 */
87#define SNDRV_SEQ_EVENT_TUNE_REQUEST 40 /* tune request */
88#define SNDRV_SEQ_EVENT_RESET 41 /* reset to power-on state */
89#define SNDRV_SEQ_EVENT_SENSING 42 /* "active sensing" event */
90
91/** echo back, kernel private messages
92 * event data type = any type
93 */
94#define SNDRV_SEQ_EVENT_ECHO 50 /* echo event */
95#define SNDRV_SEQ_EVENT_OSS 51 /* OSS raw event */
96
97/** system status messages (broadcast for subscribers)
98 * event data type = snd_seq_addr
99 */
100#define SNDRV_SEQ_EVENT_CLIENT_START 60 /* new client has connected */
101#define SNDRV_SEQ_EVENT_CLIENT_EXIT 61 /* client has left the system */
102#define SNDRV_SEQ_EVENT_CLIENT_CHANGE 62 /* client status/info has changed */
103#define SNDRV_SEQ_EVENT_PORT_START 63 /* new port was created */
104#define SNDRV_SEQ_EVENT_PORT_EXIT 64 /* port was deleted from system */
105#define SNDRV_SEQ_EVENT_PORT_CHANGE 65 /* port status/info has changed */
106
107/** port connection changes
108 * event data type = snd_seq_connect
109 */
110#define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */
111#define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */
112
113/* 70-89: synthesizer events - obsoleted */
114
115/** user-defined events with fixed length
116 * event data type = any
117 */
118#define SNDRV_SEQ_EVENT_USR0 90
119#define SNDRV_SEQ_EVENT_USR1 91
120#define SNDRV_SEQ_EVENT_USR2 92
121#define SNDRV_SEQ_EVENT_USR3 93
122#define SNDRV_SEQ_EVENT_USR4 94
123#define SNDRV_SEQ_EVENT_USR5 95
124#define SNDRV_SEQ_EVENT_USR6 96
125#define SNDRV_SEQ_EVENT_USR7 97
126#define SNDRV_SEQ_EVENT_USR8 98
127#define SNDRV_SEQ_EVENT_USR9 99
128
129/* 100-118: instrument layer - obsoleted */
130/* 119-129: reserved */
131
132/* 130-139: variable length events
133 * event data type = snd_seq_ev_ext
134 * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set)
135 */
136#define SNDRV_SEQ_EVENT_SYSEX 130 /* system exclusive data (variable length) */
137#define SNDRV_SEQ_EVENT_BOUNCE 131 /* error event */
138/* 132-134: reserved */
139#define SNDRV_SEQ_EVENT_USR_VAR0 135
140#define SNDRV_SEQ_EVENT_USR_VAR1 136
141#define SNDRV_SEQ_EVENT_USR_VAR2 137
142#define SNDRV_SEQ_EVENT_USR_VAR3 138
143#define SNDRV_SEQ_EVENT_USR_VAR4 139
144
145/* 150-151: kernel events with quote - DO NOT use in user clients */
146#define SNDRV_SEQ_EVENT_KERNEL_ERROR 150
147#define SNDRV_SEQ_EVENT_KERNEL_QUOTE 151 /* obsolete */
148
149/* 152-191: reserved */
150
151/* 192-254: hardware specific events */
152
153/* 255: special event */
154#define SNDRV_SEQ_EVENT_NONE 255
155
156
157typedef unsigned char snd_seq_event_type_t;
158
159/** event address */
160struct snd_seq_addr {
161 unsigned char client; /**< Client number: 0..255, 255 = broadcast to all clients */
162 unsigned char port; /**< Port within client: 0..255, 255 = broadcast to all ports */
163};
164
165/** port connection */
166struct snd_seq_connect {
167 struct snd_seq_addr sender;
168 struct snd_seq_addr dest;
169};
170
171
172#define SNDRV_SEQ_ADDRESS_UNKNOWN 253 /* unknown source */
173#define SNDRV_SEQ_ADDRESS_SUBSCRIBERS 254 /* send event to all subscribed ports */
174#define SNDRV_SEQ_ADDRESS_BROADCAST 255 /* send event to all queues/clients/ports/channels */
175#define SNDRV_SEQ_QUEUE_DIRECT 253 /* direct dispatch */
176
177 /* event mode flag - NOTE: only 8 bits available! */
178#define SNDRV_SEQ_TIME_STAMP_TICK (0<<0) /* timestamp in clock ticks */
179#define SNDRV_SEQ_TIME_STAMP_REAL (1<<0) /* timestamp in real time */
180#define SNDRV_SEQ_TIME_STAMP_MASK (1<<0)
181
182#define SNDRV_SEQ_TIME_MODE_ABS (0<<1) /* absolute timestamp */
183#define SNDRV_SEQ_TIME_MODE_REL (1<<1) /* relative to current time */
184#define SNDRV_SEQ_TIME_MODE_MASK (1<<1)
185
186#define SNDRV_SEQ_EVENT_LENGTH_FIXED (0<<2) /* fixed event size */
187#define SNDRV_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /* variable event size */
188#define SNDRV_SEQ_EVENT_LENGTH_VARUSR (2<<2) /* variable event size - user memory space */
189#define SNDRV_SEQ_EVENT_LENGTH_MASK (3<<2)
190
191#define SNDRV_SEQ_PRIORITY_NORMAL (0<<4) /* normal priority */
192#define SNDRV_SEQ_PRIORITY_HIGH (1<<4) /* event should be processed before others */
193#define SNDRV_SEQ_PRIORITY_MASK (1<<4)
194
195
196 /* note event */
197struct snd_seq_ev_note {
198 unsigned char channel;
199 unsigned char note;
200 unsigned char velocity;
201 unsigned char off_velocity; /* only for SNDRV_SEQ_EVENT_NOTE */
202 unsigned int duration; /* only for SNDRV_SEQ_EVENT_NOTE */
203};
204
205 /* controller event */
206struct snd_seq_ev_ctrl {
207 unsigned char channel;
208 unsigned char unused1, unused2, unused3; /* pad */
209 unsigned int param;
210 signed int value;
211};
212
213 /* generic set of bytes (12x8 bit) */
214struct snd_seq_ev_raw8 {
215 unsigned char d[12]; /* 8 bit value */
216};
217
218 /* generic set of integers (3x32 bit) */
219struct snd_seq_ev_raw32 {
220 unsigned int d[3]; /* 32 bit value */
221};
222
223 /* external stored data */
224struct snd_seq_ev_ext {
225 unsigned int len; /* length of data */
226 void *ptr; /* pointer to data (note: maybe 64-bit) */
227} __attribute__((packed));
228
229struct snd_seq_result {
230 int event; /* processed event type */
231 int result;
232};
233
234
235struct snd_seq_real_time {
236 unsigned int tv_sec; /* seconds */
237 unsigned int tv_nsec; /* nanoseconds */
238};
239
240typedef unsigned int snd_seq_tick_time_t; /* midi ticks */
241
242union snd_seq_timestamp {
243 snd_seq_tick_time_t tick;
244 struct snd_seq_real_time time;
245};
246
247struct snd_seq_queue_skew {
248 unsigned int value;
249 unsigned int base;
250};
251
252 /* queue timer control */
253struct snd_seq_ev_queue_control {
254 unsigned char queue; /* affected queue */
255 unsigned char pad[3]; /* reserved */
256 union {
257 signed int value; /* affected value (e.g. tempo) */
258 union snd_seq_timestamp time; /* time */
259 unsigned int position; /* sync position */
260 struct snd_seq_queue_skew skew;
261 unsigned int d32[2];
262 unsigned char d8[8];
263 } param;
264};
265
266 /* quoted event - inside the kernel only */
267struct snd_seq_ev_quote {
268 struct snd_seq_addr origin; /* original sender */
269 unsigned short value; /* optional data */
270 struct snd_seq_event *event; /* quoted event */
271} __attribute__((packed));
272
273
274 /* sequencer event */
275struct snd_seq_event {
276 snd_seq_event_type_t type; /* event type */
277 unsigned char flags; /* event flags */
278 char tag;
279
280 unsigned char queue; /* schedule queue */
281 union snd_seq_timestamp time; /* schedule time */
282
283
284 struct snd_seq_addr source; /* source address */
285 struct snd_seq_addr dest; /* destination address */
286
287 union { /* event data... */
288 struct snd_seq_ev_note note;
289 struct snd_seq_ev_ctrl control;
290 struct snd_seq_ev_raw8 raw8;
291 struct snd_seq_ev_raw32 raw32;
292 struct snd_seq_ev_ext ext;
293 struct snd_seq_ev_queue_control queue;
294 union snd_seq_timestamp time;
295 struct snd_seq_addr addr;
296 struct snd_seq_connect connect;
297 struct snd_seq_result result;
298 struct snd_seq_ev_quote quote;
299 } data;
300};
301
302
303/*
304 * bounce event - stored as variable size data
305 */
306struct snd_seq_event_bounce {
307 int err;
308 struct snd_seq_event event;
309 /* external data follows here. */
310};
311
312#ifdef __KERNEL__
313 28
314/* helper macro */ 29/* helper macro */
315#define snd_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(struct snd_seq_event_bounce))) 30#define snd_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(struct snd_seq_event_bounce)))
@@ -368,311 +83,4 @@ struct snd_seq_event_bounce {
368/* queue sync port */ 83/* queue sync port */
369#define snd_seq_queue_sync_port(q) ((q) + 16) 84#define snd_seq_queue_sync_port(q) ((q) + 16)
370 85
371#endif /* __KERNEL__ */
372
373 /* system information */
374struct snd_seq_system_info {
375 int queues; /* maximum queues count */
376 int clients; /* maximum clients count */
377 int ports; /* maximum ports per client */
378 int channels; /* maximum channels per port */
379 int cur_clients; /* current clients */
380 int cur_queues; /* current queues */
381 char reserved[24];
382};
383
384
385 /* system running information */
386struct snd_seq_running_info {
387 unsigned char client; /* client id */
388 unsigned char big_endian; /* 1 = big-endian */
389 unsigned char cpu_mode; /* 4 = 32bit, 8 = 64bit */
390 unsigned char pad; /* reserved */
391 unsigned char reserved[12];
392};
393
394
395 /* known client numbers */
396#define SNDRV_SEQ_CLIENT_SYSTEM 0
397 /* internal client numbers */
398#define SNDRV_SEQ_CLIENT_DUMMY 14 /* midi through */
399#define SNDRV_SEQ_CLIENT_OSS 15 /* oss sequencer emulator */
400
401
402 /* client types */
403typedef int __bitwise snd_seq_client_type_t;
404#define NO_CLIENT ((__force snd_seq_client_type_t) 0)
405#define USER_CLIENT ((__force snd_seq_client_type_t) 1)
406#define KERNEL_CLIENT ((__force snd_seq_client_type_t) 2)
407
408 /* event filter flags */
409#define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */
410#define SNDRV_SEQ_FILTER_MULTICAST (1<<1) /* accept multicast messages */
411#define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */
412#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */
413
414struct snd_seq_client_info {
415 int client; /* client number to inquire */
416 snd_seq_client_type_t type; /* client type */
417 char name[64]; /* client name */
418 unsigned int filter; /* filter flags */
419 unsigned char multicast_filter[8]; /* multicast filter bitmap */
420 unsigned char event_filter[32]; /* event filter bitmap */
421 int num_ports; /* RO: number of ports */
422 int event_lost; /* number of lost events */
423 char reserved[64]; /* for future use */
424};
425
426
427/* client pool size */
428struct snd_seq_client_pool {
429 int client; /* client number to inquire */
430 int output_pool; /* outgoing (write) pool size */
431 int input_pool; /* incoming (read) pool size */
432 int output_room; /* minimum free pool size for select/blocking mode */
433 int output_free; /* unused size */
434 int input_free; /* unused size */
435 char reserved[64];
436};
437
438
439/* Remove events by specified criteria */
440
441#define SNDRV_SEQ_REMOVE_INPUT (1<<0) /* Flush input queues */
442#define SNDRV_SEQ_REMOVE_OUTPUT (1<<1) /* Flush output queues */
443#define SNDRV_SEQ_REMOVE_DEST (1<<2) /* Restrict by destination q:client:port */
444#define SNDRV_SEQ_REMOVE_DEST_CHANNEL (1<<3) /* Restrict by channel */
445#define SNDRV_SEQ_REMOVE_TIME_BEFORE (1<<4) /* Restrict to before time */
446#define SNDRV_SEQ_REMOVE_TIME_AFTER (1<<5) /* Restrict to time or after */
447#define SNDRV_SEQ_REMOVE_TIME_TICK (1<<6) /* Time is in ticks */
448#define SNDRV_SEQ_REMOVE_EVENT_TYPE (1<<7) /* Restrict to event type */
449#define SNDRV_SEQ_REMOVE_IGNORE_OFF (1<<8) /* Do not flush off events */
450#define SNDRV_SEQ_REMOVE_TAG_MATCH (1<<9) /* Restrict to events with given tag */
451
452struct snd_seq_remove_events {
453 unsigned int remove_mode; /* Flags that determine what gets removed */
454
455 union snd_seq_timestamp time;
456
457 unsigned char queue; /* Queue for REMOVE_DEST */
458 struct snd_seq_addr dest; /* Address for REMOVE_DEST */
459 unsigned char channel; /* Channel for REMOVE_DEST */
460
461 int type; /* For REMOVE_EVENT_TYPE */
462 char tag; /* Tag for REMOVE_TAG */
463
464 int reserved[10]; /* To allow for future binary compatibility */
465
466};
467
468
469 /* known port numbers */
470#define SNDRV_SEQ_PORT_SYSTEM_TIMER 0
471#define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE 1
472
473 /* port capabilities (32 bits) */
474#define SNDRV_SEQ_PORT_CAP_READ (1<<0) /* readable from this port */
475#define SNDRV_SEQ_PORT_CAP_WRITE (1<<1) /* writable to this port */
476
477#define SNDRV_SEQ_PORT_CAP_SYNC_READ (1<<2)
478#define SNDRV_SEQ_PORT_CAP_SYNC_WRITE (1<<3)
479
480#define SNDRV_SEQ_PORT_CAP_DUPLEX (1<<4)
481
482#define SNDRV_SEQ_PORT_CAP_SUBS_READ (1<<5) /* allow read subscription */
483#define SNDRV_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /* allow write subscription */
484#define SNDRV_SEQ_PORT_CAP_NO_EXPORT (1<<7) /* routing not allowed */
485
486 /* port type */
487#define SNDRV_SEQ_PORT_TYPE_SPECIFIC (1<<0) /* hardware specific */
488#define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /* generic MIDI device */
489#define SNDRV_SEQ_PORT_TYPE_MIDI_GM (1<<2) /* General MIDI compatible device */
490#define SNDRV_SEQ_PORT_TYPE_MIDI_GS (1<<3) /* GS compatible device */
491#define SNDRV_SEQ_PORT_TYPE_MIDI_XG (1<<4) /* XG compatible device */
492#define SNDRV_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /* MT-32 compatible device */
493#define SNDRV_SEQ_PORT_TYPE_MIDI_GM2 (1<<6) /* General MIDI 2 compatible device */
494
495/* other standards...*/
496#define SNDRV_SEQ_PORT_TYPE_SYNTH (1<<10) /* Synth device (no MIDI compatible - direct wavetable) */
497#define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /* Sampling device (support sample download) */
498#define SNDRV_SEQ_PORT_TYPE_SAMPLE (1<<12) /* Sampling device (sample can be downloaded at any time) */
499/*...*/
500#define SNDRV_SEQ_PORT_TYPE_HARDWARE (1<<16) /* driver for a hardware device */
501#define SNDRV_SEQ_PORT_TYPE_SOFTWARE (1<<17) /* implemented in software */
502#define SNDRV_SEQ_PORT_TYPE_SYNTHESIZER (1<<18) /* generates sound */
503#define SNDRV_SEQ_PORT_TYPE_PORT (1<<19) /* connects to other device(s) */
504#define SNDRV_SEQ_PORT_TYPE_APPLICATION (1<<20) /* application (sequencer/editor) */
505
506/* misc. conditioning flags */
507#define SNDRV_SEQ_PORT_FLG_GIVEN_PORT (1<<0)
508#define SNDRV_SEQ_PORT_FLG_TIMESTAMP (1<<1)
509#define SNDRV_SEQ_PORT_FLG_TIME_REAL (1<<2)
510
511struct snd_seq_port_info {
512 struct snd_seq_addr addr; /* client/port numbers */
513 char name[64]; /* port name */
514
515 unsigned int capability; /* port capability bits */
516 unsigned int type; /* port type bits */
517 int midi_channels; /* channels per MIDI port */
518 int midi_voices; /* voices per MIDI port */
519 int synth_voices; /* voices per SYNTH port */
520
521 int read_use; /* R/O: subscribers for output (from this port) */
522 int write_use; /* R/O: subscribers for input (to this port) */
523
524 void *kernel; /* reserved for kernel use (must be NULL) */
525 unsigned int flags; /* misc. conditioning */
526 unsigned char time_queue; /* queue # for timestamping */
527 char reserved[59]; /* for future use */
528};
529
530
531/* queue flags */
532#define SNDRV_SEQ_QUEUE_FLG_SYNC (1<<0) /* sync enabled */
533
534/* queue information */
535struct snd_seq_queue_info {
536 int queue; /* queue id */
537
538 /*
539 * security settings, only owner of this queue can start/stop timer
540 * etc. if the queue is locked for other clients
541 */
542 int owner; /* client id for owner of the queue */
543 unsigned locked:1; /* timing queue locked for other queues */
544 char name[64]; /* name of this queue */
545 unsigned int flags; /* flags */
546 char reserved[60]; /* for future use */
547
548};
549
550/* queue info/status */
551struct snd_seq_queue_status {
552 int queue; /* queue id */
553 int events; /* read-only - queue size */
554 snd_seq_tick_time_t tick; /* current tick */
555 struct snd_seq_real_time time; /* current time */
556 int running; /* running state of queue */
557 int flags; /* various flags */
558 char reserved[64]; /* for the future */
559};
560
561
562/* queue tempo */
563struct snd_seq_queue_tempo {
564 int queue; /* sequencer queue */
565 unsigned int tempo; /* current tempo, us/tick */
566 int ppq; /* time resolution, ticks/quarter */
567 unsigned int skew_value; /* queue skew */
568 unsigned int skew_base; /* queue skew base */
569 char reserved[24]; /* for the future */
570};
571
572
573/* sequencer timer sources */
574#define SNDRV_SEQ_TIMER_ALSA 0 /* ALSA timer */
575#define SNDRV_SEQ_TIMER_MIDI_CLOCK 1 /* Midi Clock (CLOCK event) */
576#define SNDRV_SEQ_TIMER_MIDI_TICK 2 /* Midi Timer Tick (TICK event) */
577
578/* queue timer info */
579struct snd_seq_queue_timer {
580 int queue; /* sequencer queue */
581 int type; /* source timer type */
582 union {
583 struct {
584 struct snd_timer_id id; /* ALSA's timer ID */
585 unsigned int resolution; /* resolution in Hz */
586 } alsa;
587 } u;
588 char reserved[64]; /* for the future use */
589};
590
591
592struct snd_seq_queue_client {
593 int queue; /* sequencer queue */
594 int client; /* sequencer client */
595 int used; /* queue is used with this client
596 (must be set for accepting events) */
597 /* per client watermarks */
598 char reserved[64]; /* for future use */
599};
600
601
602#define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE (1<<0) /* exclusive connection */
603#define SNDRV_SEQ_PORT_SUBS_TIMESTAMP (1<<1)
604#define SNDRV_SEQ_PORT_SUBS_TIME_REAL (1<<2)
605
606struct snd_seq_port_subscribe {
607 struct snd_seq_addr sender; /* sender address */
608 struct snd_seq_addr dest; /* destination address */
609 unsigned int voices; /* number of voices to be allocated (0 = don't care) */
610 unsigned int flags; /* modes */
611 unsigned char queue; /* input time-stamp queue (optional) */
612 unsigned char pad[3]; /* reserved */
613 char reserved[64];
614};
615
616/* type of query subscription */
617#define SNDRV_SEQ_QUERY_SUBS_READ 0
618#define SNDRV_SEQ_QUERY_SUBS_WRITE 1
619
620struct snd_seq_query_subs {
621 struct snd_seq_addr root; /* client/port id to be searched */
622 int type; /* READ or WRITE */
623 int index; /* 0..N-1 */
624 int num_subs; /* R/O: number of subscriptions on this port */
625 struct snd_seq_addr addr; /* R/O: result */
626 unsigned char queue; /* R/O: result */
627 unsigned int flags; /* R/O: result */
628 char reserved[64]; /* for future use */
629};
630
631
632/*
633 * IOCTL commands
634 */
635
636#define SNDRV_SEQ_IOCTL_PVERSION _IOR ('S', 0x00, int)
637#define SNDRV_SEQ_IOCTL_CLIENT_ID _IOR ('S', 0x01, int)
638#define SNDRV_SEQ_IOCTL_SYSTEM_INFO _IOWR('S', 0x02, struct snd_seq_system_info)
639#define SNDRV_SEQ_IOCTL_RUNNING_MODE _IOWR('S', 0x03, struct snd_seq_running_info)
640
641#define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct snd_seq_client_info)
642#define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW ('S', 0x11, struct snd_seq_client_info)
643
644#define SNDRV_SEQ_IOCTL_CREATE_PORT _IOWR('S', 0x20, struct snd_seq_port_info)
645#define SNDRV_SEQ_IOCTL_DELETE_PORT _IOW ('S', 0x21, struct snd_seq_port_info)
646#define SNDRV_SEQ_IOCTL_GET_PORT_INFO _IOWR('S', 0x22, struct snd_seq_port_info)
647#define SNDRV_SEQ_IOCTL_SET_PORT_INFO _IOW ('S', 0x23, struct snd_seq_port_info)
648
649#define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT _IOW ('S', 0x30, struct snd_seq_port_subscribe)
650#define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct snd_seq_port_subscribe)
651
652#define SNDRV_SEQ_IOCTL_CREATE_QUEUE _IOWR('S', 0x32, struct snd_seq_queue_info)
653#define SNDRV_SEQ_IOCTL_DELETE_QUEUE _IOW ('S', 0x33, struct snd_seq_queue_info)
654#define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO _IOWR('S', 0x34, struct snd_seq_queue_info)
655#define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO _IOWR('S', 0x35, struct snd_seq_queue_info)
656#define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct snd_seq_queue_info)
657#define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status)
658#define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct snd_seq_queue_tempo)
659#define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW ('S', 0x42, struct snd_seq_queue_tempo)
660#define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct snd_seq_queue_owner)
661#define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW ('S', 0x44, struct snd_seq_queue_owner)
662#define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct snd_seq_queue_timer)
663#define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW ('S', 0x46, struct snd_seq_queue_timer)
664/* XXX
665#define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC _IOWR('S', 0x53, struct snd_seq_queue_sync)
666#define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC _IOW ('S', 0x54, struct snd_seq_queue_sync)
667*/
668#define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT _IOWR('S', 0x49, struct snd_seq_queue_client)
669#define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT _IOW ('S', 0x4a, struct snd_seq_queue_client)
670#define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL _IOWR('S', 0x4b, struct snd_seq_client_pool)
671#define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL _IOW ('S', 0x4c, struct snd_seq_client_pool)
672#define SNDRV_SEQ_IOCTL_REMOVE_EVENTS _IOW ('S', 0x4e, struct snd_seq_remove_events)
673#define SNDRV_SEQ_IOCTL_QUERY_SUBS _IOWR('S', 0x4f, struct snd_seq_query_subs)
674#define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION _IOWR('S', 0x50, struct snd_seq_port_subscribe)
675#define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT _IOWR('S', 0x51, struct snd_seq_client_info)
676#define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT _IOWR('S', 0x52, struct snd_seq_port_info)
677
678#endif /* __SOUND_ASEQUENCER_H */ 86#endif /* __SOUND_ASEQUENCER_H */
diff --git a/include/sound/asound.h b/include/sound/asound.h
index dfe7d441748c..c2dff5369d33 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -19,13 +19,9 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * 20 *
21 */ 21 */
22
23#ifndef __SOUND_ASOUND_H 22#ifndef __SOUND_ASOUND_H
24#define __SOUND_ASOUND_H 23#define __SOUND_ASOUND_H
25 24
26#include <linux/types.h>
27
28#ifdef __KERNEL__
29#include <linux/ioctl.h> 25#include <linux/ioctl.h>
30#include <linux/time.h> 26#include <linux/time.h>
31#include <asm/byteorder.h> 27#include <asm/byteorder.h>
@@ -40,934 +36,5 @@
40#endif 36#endif
41#endif 37#endif
42 38
43#endif /* __KERNEL__ **/ 39#include <uapi/sound/asound.h>
44
45/*
46 * protocol version
47 */
48
49#define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor))
50#define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff)
51#define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff)
52#define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff)
53#define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) \
54 (SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || \
55 (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && \
56 SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion)))
57
58/****************************************************************************
59 * *
60 * Digital audio interface *
61 * *
62 ****************************************************************************/
63
64struct snd_aes_iec958 {
65 unsigned char status[24]; /* AES/IEC958 channel status bits */
66 unsigned char subcode[147]; /* AES/IEC958 subcode bits */
67 unsigned char pad; /* nothing */
68 unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */
69};
70
71/****************************************************************************
72 * *
73 * CEA-861 Audio InfoFrame. Used in HDMI and DisplayPort *
74 * *
75 ****************************************************************************/
76
77struct snd_cea_861_aud_if {
78 unsigned char db1_ct_cc; /* coding type and channel count */
79 unsigned char db2_sf_ss; /* sample frequency and size */
80 unsigned char db3; /* not used, all zeros */
81 unsigned char db4_ca; /* channel allocation code */
82 unsigned char db5_dminh_lsv; /* downmix inhibit & level-shit values */
83};
84
85/****************************************************************************
86 * *
87 * Section for driver hardware dependent interface - /dev/snd/hw? *
88 * *
89 ****************************************************************************/
90
91#define SNDRV_HWDEP_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1)
92
93enum {
94 SNDRV_HWDEP_IFACE_OPL2 = 0,
95 SNDRV_HWDEP_IFACE_OPL3,
96 SNDRV_HWDEP_IFACE_OPL4,
97 SNDRV_HWDEP_IFACE_SB16CSP, /* Creative Signal Processor */
98 SNDRV_HWDEP_IFACE_EMU10K1, /* FX8010 processor in EMU10K1 chip */
99 SNDRV_HWDEP_IFACE_YSS225, /* Yamaha FX processor */
100 SNDRV_HWDEP_IFACE_ICS2115, /* Wavetable synth */
101 SNDRV_HWDEP_IFACE_SSCAPE, /* Ensoniq SoundScape ISA card (MC68EC000) */
102 SNDRV_HWDEP_IFACE_VX, /* Digigram VX cards */
103 SNDRV_HWDEP_IFACE_MIXART, /* Digigram miXart cards */
104 SNDRV_HWDEP_IFACE_USX2Y, /* Tascam US122, US224 & US428 usb */
105 SNDRV_HWDEP_IFACE_EMUX_WAVETABLE, /* EmuX wavetable */
106 SNDRV_HWDEP_IFACE_BLUETOOTH, /* Bluetooth audio */
107 SNDRV_HWDEP_IFACE_USX2Y_PCM, /* Tascam US122, US224 & US428 rawusb pcm */
108 SNDRV_HWDEP_IFACE_PCXHR, /* Digigram PCXHR */
109 SNDRV_HWDEP_IFACE_SB_RC, /* SB Extigy/Audigy2NX remote control */
110 SNDRV_HWDEP_IFACE_HDA, /* HD-audio */
111 SNDRV_HWDEP_IFACE_USB_STREAM, /* direct access to usb stream */
112
113 /* Don't forget to change the following: */
114 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM
115};
116
117struct snd_hwdep_info {
118 unsigned int device; /* WR: device number */
119 int card; /* R: card number */
120 unsigned char id[64]; /* ID (user selectable) */
121 unsigned char name[80]; /* hwdep name */
122 int iface; /* hwdep interface */
123 unsigned char reserved[64]; /* reserved for future */
124};
125
126/* generic DSP loader */
127struct snd_hwdep_dsp_status {
128 unsigned int version; /* R: driver-specific version */
129 unsigned char id[32]; /* R: driver-specific ID string */
130 unsigned int num_dsps; /* R: number of DSP images to transfer */
131 unsigned int dsp_loaded; /* R: bit flags indicating the loaded DSPs */
132 unsigned int chip_ready; /* R: 1 = initialization finished */
133 unsigned char reserved[16]; /* reserved for future use */
134};
135
136struct snd_hwdep_dsp_image {
137 unsigned int index; /* W: DSP index */
138 unsigned char name[64]; /* W: ID (e.g. file name) */
139 unsigned char __user *image; /* W: binary image */
140 size_t length; /* W: size of image in bytes */
141 unsigned long driver_data; /* W: driver-specific data */
142};
143
144#define SNDRV_HWDEP_IOCTL_PVERSION _IOR ('H', 0x00, int)
145#define SNDRV_HWDEP_IOCTL_INFO _IOR ('H', 0x01, struct snd_hwdep_info)
146#define SNDRV_HWDEP_IOCTL_DSP_STATUS _IOR('H', 0x02, struct snd_hwdep_dsp_status)
147#define SNDRV_HWDEP_IOCTL_DSP_LOAD _IOW('H', 0x03, struct snd_hwdep_dsp_image)
148
149/*****************************************************************************
150 * *
151 * Digital Audio (PCM) interface - /dev/snd/pcm?? *
152 * *
153 *****************************************************************************/
154
155#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 10)
156
157typedef unsigned long snd_pcm_uframes_t;
158typedef signed long snd_pcm_sframes_t;
159
160enum {
161 SNDRV_PCM_CLASS_GENERIC = 0, /* standard mono or stereo device */
162 SNDRV_PCM_CLASS_MULTI, /* multichannel device */
163 SNDRV_PCM_CLASS_MODEM, /* software modem class */
164 SNDRV_PCM_CLASS_DIGITIZER, /* digitizer class */
165 /* Don't forget to change the following: */
166 SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER,
167};
168
169enum {
170 SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, /* mono or stereo subdevices are mixed together */
171 SNDRV_PCM_SUBCLASS_MULTI_MIX, /* multichannel subdevices are mixed together */
172 /* Don't forget to change the following: */
173 SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX,
174};
175
176enum {
177 SNDRV_PCM_STREAM_PLAYBACK = 0,
178 SNDRV_PCM_STREAM_CAPTURE,
179 SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE,
180};
181
182typedef int __bitwise snd_pcm_access_t;
183#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0) /* interleaved mmap */
184#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1) /* noninterleaved mmap */
185#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2) /* complex mmap */
186#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3) /* readi/writei */
187#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4) /* readn/writen */
188#define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_RW_NONINTERLEAVED
189
190typedef int __bitwise snd_pcm_format_t;
191#define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0)
192#define SNDRV_PCM_FORMAT_U8 ((__force snd_pcm_format_t) 1)
193#define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2)
194#define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3)
195#define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4)
196#define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5)
197#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) /* low three bytes */
198#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */
199#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */
200#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */
201#define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10)
202#define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11)
203#define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12)
204#define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13)
205#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
206#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
207#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
208#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
209#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) /* IEC-958 subframe, Little Endian */
210#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) /* IEC-958 subframe, Big Endian */
211#define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20)
212#define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21)
213#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22)
214#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23)
215#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24)
216#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31)
217#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) /* in three bytes */
218#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) /* in three bytes */
219#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34) /* in three bytes */
220#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35) /* in three bytes */
221#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36) /* in three bytes */
222#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37) /* in three bytes */
223#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38) /* in three bytes */
224#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39) /* in three bytes */
225#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40) /* in three bytes */
226#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41) /* in three bytes */
227#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42) /* in three bytes */
228#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43) /* in three bytes */
229#define SNDRV_PCM_FORMAT_G723_24 ((__force snd_pcm_format_t) 44) /* 8 samples in 3 bytes */
230#define SNDRV_PCM_FORMAT_G723_24_1B ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */
231#define SNDRV_PCM_FORMAT_G723_40 ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */
232#define SNDRV_PCM_FORMAT_G723_40_1B ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */
233#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_G723_40_1B
234
235#ifdef SNDRV_LITTLE_ENDIAN
236#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE
237#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_LE
238#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_LE
239#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_LE
240#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_LE
241#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_LE
242#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE
243#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE
244#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
245#endif
246#ifdef SNDRV_BIG_ENDIAN
247#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE
248#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_BE
249#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_BE
250#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_BE
251#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_BE
252#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_BE
253#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE
254#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE
255#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
256#endif
257
258typedef int __bitwise snd_pcm_subformat_t;
259#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0)
260#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD
261
262#define SNDRV_PCM_INFO_MMAP 0x00000001 /* hardware supports mmap */
263#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 /* period data are valid during transfer */
264#define SNDRV_PCM_INFO_DOUBLE 0x00000004 /* Double buffering needed for PCM start/stop */
265#define SNDRV_PCM_INFO_BATCH 0x00000010 /* double buffering */
266#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100 /* channels are interleaved */
267#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200 /* channels are not interleaved */
268#define SNDRV_PCM_INFO_COMPLEX 0x00000400 /* complex frame organization (mmap only) */
269#define SNDRV_PCM_INFO_BLOCK_TRANSFER 0x00010000 /* hardware transfer block of samples */
270#define SNDRV_PCM_INFO_OVERRANGE 0x00020000 /* hardware supports ADC (capture) overrange detection */
271#define SNDRV_PCM_INFO_RESUME 0x00040000 /* hardware supports stream resume after suspend */
272#define SNDRV_PCM_INFO_PAUSE 0x00080000 /* pause ioctl is supported */
273#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000 /* only half duplex */
274#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */
275#define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */
276#define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */
277#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
278
279typedef int __bitwise snd_pcm_state_t;
280#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */
281#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) /* stream has a setup */
282#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2) /* stream is ready to start */
283#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3) /* stream is running */
284#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4) /* stream reached an xrun */
285#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5) /* stream is draining */
286#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6) /* stream is paused */
287#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7) /* hardware is suspended */
288#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8) /* hardware is disconnected */
289#define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED
290
291enum {
292 SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
293 SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
294 SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
295};
296
297union snd_pcm_sync_id {
298 unsigned char id[16];
299 unsigned short id16[8];
300 unsigned int id32[4];
301};
302
303struct snd_pcm_info {
304 unsigned int device; /* RO/WR (control): device number */
305 unsigned int subdevice; /* RO/WR (control): subdevice number */
306 int stream; /* RO/WR (control): stream direction */
307 int card; /* R: card number */
308 unsigned char id[64]; /* ID (user selectable) */
309 unsigned char name[80]; /* name of this device */
310 unsigned char subname[32]; /* subdevice name */
311 int dev_class; /* SNDRV_PCM_CLASS_* */
312 int dev_subclass; /* SNDRV_PCM_SUBCLASS_* */
313 unsigned int subdevices_count;
314 unsigned int subdevices_avail;
315 union snd_pcm_sync_id sync; /* hardware synchronization ID */
316 unsigned char reserved[64]; /* reserved for future... */
317};
318
319typedef int snd_pcm_hw_param_t;
320#define SNDRV_PCM_HW_PARAM_ACCESS 0 /* Access type */
321#define SNDRV_PCM_HW_PARAM_FORMAT 1 /* Format */
322#define SNDRV_PCM_HW_PARAM_SUBFORMAT 2 /* Subformat */
323#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS
324#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT
325
326#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS 8 /* Bits per sample */
327#define SNDRV_PCM_HW_PARAM_FRAME_BITS 9 /* Bits per frame */
328#define SNDRV_PCM_HW_PARAM_CHANNELS 10 /* Channels */
329#define SNDRV_PCM_HW_PARAM_RATE 11 /* Approx rate */
330#define SNDRV_PCM_HW_PARAM_PERIOD_TIME 12 /* Approx distance between
331 * interrupts in us
332 */
333#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE 13 /* Approx frames between
334 * interrupts
335 */
336#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14 /* Approx bytes between
337 * interrupts
338 */
339#define SNDRV_PCM_HW_PARAM_PERIODS 15 /* Approx interrupts per
340 * buffer
341 */
342#define SNDRV_PCM_HW_PARAM_BUFFER_TIME 16 /* Approx duration of buffer
343 * in us
344 */
345#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE 17 /* Size of buffer in frames */
346#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18 /* Size of buffer in bytes */
347#define SNDRV_PCM_HW_PARAM_TICK_TIME 19 /* Approx tick duration in us */
348#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS
349#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME
350
351#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
352#define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER (1<<1) /* export buffer */
353#define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) /* disable period wakeups */
354
355struct snd_interval {
356 unsigned int min, max;
357 unsigned int openmin:1,
358 openmax:1,
359 integer:1,
360 empty:1;
361};
362
363#define SNDRV_MASK_MAX 256
364
365struct snd_mask {
366 __u32 bits[(SNDRV_MASK_MAX+31)/32];
367};
368
369struct snd_pcm_hw_params {
370 unsigned int flags;
371 struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
372 SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
373 struct snd_mask mres[5]; /* reserved masks */
374 struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
375 SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
376 struct snd_interval ires[9]; /* reserved intervals */
377 unsigned int rmask; /* W: requested masks */
378 unsigned int cmask; /* R: changed masks */
379 unsigned int info; /* R: Info flags for returned setup */
380 unsigned int msbits; /* R: used most significant bits */
381 unsigned int rate_num; /* R: rate numerator */
382 unsigned int rate_den; /* R: rate denominator */
383 snd_pcm_uframes_t fifo_size; /* R: chip FIFO size in frames */
384 unsigned char reserved[64]; /* reserved for future */
385};
386
387enum {
388 SNDRV_PCM_TSTAMP_NONE = 0,
389 SNDRV_PCM_TSTAMP_ENABLE,
390 SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE,
391};
392
393struct snd_pcm_sw_params {
394 int tstamp_mode; /* timestamp mode */
395 unsigned int period_step;
396 unsigned int sleep_min; /* min ticks to sleep */
397 snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */
398 snd_pcm_uframes_t xfer_align; /* obsolete: xfer size need to be a multiple */
399 snd_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */
400 snd_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */
401 snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */
402 snd_pcm_uframes_t silence_size; /* silence block size */
403 snd_pcm_uframes_t boundary; /* pointers wrap point */
404 unsigned char reserved[64]; /* reserved for future */
405};
406
407struct snd_pcm_channel_info {
408 unsigned int channel;
409 __kernel_off_t offset; /* mmap offset */
410 unsigned int first; /* offset to first sample in bits */
411 unsigned int step; /* samples distance in bits */
412};
413
414struct snd_pcm_status {
415 snd_pcm_state_t state; /* stream state */
416 struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */
417 struct timespec tstamp; /* reference timestamp */
418 snd_pcm_uframes_t appl_ptr; /* appl ptr */
419 snd_pcm_uframes_t hw_ptr; /* hw ptr */
420 snd_pcm_sframes_t delay; /* current delay in frames */
421 snd_pcm_uframes_t avail; /* number of frames available */
422 snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */
423 snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */
424 snd_pcm_state_t suspended_state; /* suspended stream state */
425 unsigned char reserved[60]; /* must be filled with zero */
426};
427
428struct snd_pcm_mmap_status {
429 snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */
430 int pad1; /* Needed for 64 bit alignment */
431 snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
432 struct timespec tstamp; /* Timestamp */
433 snd_pcm_state_t suspended_state; /* RO: suspended stream state */
434};
435
436struct snd_pcm_mmap_control {
437 snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
438 snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
439};
440
441#define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0) /* execute hwsync */
442#define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */
443#define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */
444
445struct snd_pcm_sync_ptr {
446 unsigned int flags;
447 union {
448 struct snd_pcm_mmap_status status;
449 unsigned char reserved[64];
450 } s;
451 union {
452 struct snd_pcm_mmap_control control;
453 unsigned char reserved[64];
454 } c;
455};
456
457struct snd_xferi {
458 snd_pcm_sframes_t result;
459 void __user *buf;
460 snd_pcm_uframes_t frames;
461};
462
463struct snd_xfern {
464 snd_pcm_sframes_t result;
465 void __user * __user *bufs;
466 snd_pcm_uframes_t frames;
467};
468
469enum {
470 SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /* gettimeofday equivalent */
471 SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, /* posix_clock_monotonic equivalent */
472 SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,
473};
474
475/* channel positions */
476enum {
477 SNDRV_CHMAP_UNKNOWN = 0,
478 SNDRV_CHMAP_NA, /* N/A, silent */
479 SNDRV_CHMAP_MONO, /* mono stream */
480 /* this follows the alsa-lib mixer channel value + 3 */
481 SNDRV_CHMAP_FL, /* front left */
482 SNDRV_CHMAP_FR, /* front right */
483 SNDRV_CHMAP_RL, /* rear left */
484 SNDRV_CHMAP_RR, /* rear right */
485 SNDRV_CHMAP_FC, /* front center */
486 SNDRV_CHMAP_LFE, /* LFE */
487 SNDRV_CHMAP_SL, /* side left */
488 SNDRV_CHMAP_SR, /* side right */
489 SNDRV_CHMAP_RC, /* rear center */
490 /* new definitions */
491 SNDRV_CHMAP_FLC, /* front left center */
492 SNDRV_CHMAP_FRC, /* front right center */
493 SNDRV_CHMAP_RLC, /* rear left center */
494 SNDRV_CHMAP_RRC, /* rear right center */
495 SNDRV_CHMAP_FLW, /* front left wide */
496 SNDRV_CHMAP_FRW, /* front right wide */
497 SNDRV_CHMAP_FLH, /* front left high */
498 SNDRV_CHMAP_FCH, /* front center high */
499 SNDRV_CHMAP_FRH, /* front right high */
500 SNDRV_CHMAP_TC, /* top center */
501 SNDRV_CHMAP_TFL, /* top front left */
502 SNDRV_CHMAP_TFR, /* top front right */
503 SNDRV_CHMAP_TFC, /* top front center */
504 SNDRV_CHMAP_TRL, /* top rear left */
505 SNDRV_CHMAP_TRR, /* top rear right */
506 SNDRV_CHMAP_TRC, /* top rear center */
507 SNDRV_CHMAP_LAST = SNDRV_CHMAP_TRC,
508};
509
510#define SNDRV_CHMAP_POSITION_MASK 0xffff
511#define SNDRV_CHMAP_PHASE_INVERSE (0x01 << 16)
512#define SNDRV_CHMAP_DRIVER_SPEC (0x02 << 16)
513
514#define SNDRV_PCM_IOCTL_PVERSION _IOR('A', 0x00, int)
515#define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info)
516#define SNDRV_PCM_IOCTL_TSTAMP _IOW('A', 0x02, int)
517#define SNDRV_PCM_IOCTL_TTSTAMP _IOW('A', 0x03, int)
518#define SNDRV_PCM_IOCTL_HW_REFINE _IOWR('A', 0x10, struct snd_pcm_hw_params)
519#define SNDRV_PCM_IOCTL_HW_PARAMS _IOWR('A', 0x11, struct snd_pcm_hw_params)
520#define SNDRV_PCM_IOCTL_HW_FREE _IO('A', 0x12)
521#define SNDRV_PCM_IOCTL_SW_PARAMS _IOWR('A', 0x13, struct snd_pcm_sw_params)
522#define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status)
523#define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t)
524#define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22)
525#define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr)
526#define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info)
527#define SNDRV_PCM_IOCTL_PREPARE _IO('A', 0x40)
528#define SNDRV_PCM_IOCTL_RESET _IO('A', 0x41)
529#define SNDRV_PCM_IOCTL_START _IO('A', 0x42)
530#define SNDRV_PCM_IOCTL_DROP _IO('A', 0x43)
531#define SNDRV_PCM_IOCTL_DRAIN _IO('A', 0x44)
532#define SNDRV_PCM_IOCTL_PAUSE _IOW('A', 0x45, int)
533#define SNDRV_PCM_IOCTL_REWIND _IOW('A', 0x46, snd_pcm_uframes_t)
534#define SNDRV_PCM_IOCTL_RESUME _IO('A', 0x47)
535#define SNDRV_PCM_IOCTL_XRUN _IO('A', 0x48)
536#define SNDRV_PCM_IOCTL_FORWARD _IOW('A', 0x49, snd_pcm_uframes_t)
537#define SNDRV_PCM_IOCTL_WRITEI_FRAMES _IOW('A', 0x50, struct snd_xferi)
538#define SNDRV_PCM_IOCTL_READI_FRAMES _IOR('A', 0x51, struct snd_xferi)
539#define SNDRV_PCM_IOCTL_WRITEN_FRAMES _IOW('A', 0x52, struct snd_xfern)
540#define SNDRV_PCM_IOCTL_READN_FRAMES _IOR('A', 0x53, struct snd_xfern)
541#define SNDRV_PCM_IOCTL_LINK _IOW('A', 0x60, int)
542#define SNDRV_PCM_IOCTL_UNLINK _IO('A', 0x61)
543
544/*****************************************************************************
545 * *
546 * MIDI v1.0 interface *
547 * *
548 *****************************************************************************/
549
550/*
551 * Raw MIDI section - /dev/snd/midi??
552 */
553
554#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0)
555
556enum {
557 SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
558 SNDRV_RAWMIDI_STREAM_INPUT,
559 SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT,
560};
561
562#define SNDRV_RAWMIDI_INFO_OUTPUT 0x00000001
563#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002
564#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004
565
566struct snd_rawmidi_info {
567 unsigned int device; /* RO/WR (control): device number */
568 unsigned int subdevice; /* RO/WR (control): subdevice number */
569 int stream; /* WR: stream */
570 int card; /* R: card number */
571 unsigned int flags; /* SNDRV_RAWMIDI_INFO_XXXX */
572 unsigned char id[64]; /* ID (user selectable) */
573 unsigned char name[80]; /* name of device */
574 unsigned char subname[32]; /* name of active or selected subdevice */
575 unsigned int subdevices_count;
576 unsigned int subdevices_avail;
577 unsigned char reserved[64]; /* reserved for future use */
578};
579
580struct snd_rawmidi_params {
581 int stream;
582 size_t buffer_size; /* queue size in bytes */
583 size_t avail_min; /* minimum avail bytes for wakeup */
584 unsigned int no_active_sensing: 1; /* do not send active sensing byte in close() */
585 unsigned char reserved[16]; /* reserved for future use */
586};
587
588struct snd_rawmidi_status {
589 int stream;
590 struct timespec tstamp; /* Timestamp */
591 size_t avail; /* available bytes */
592 size_t xruns; /* count of overruns since last status (in bytes) */
593 unsigned char reserved[16]; /* reserved for future use */
594};
595
596#define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
597#define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
598#define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params)
599#define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status)
600#define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)
601#define SNDRV_RAWMIDI_IOCTL_DRAIN _IOW('W', 0x31, int)
602
603/*
604 * Timer section - /dev/snd/timer
605 */
606
607#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6)
608
609enum {
610 SNDRV_TIMER_CLASS_NONE = -1,
611 SNDRV_TIMER_CLASS_SLAVE = 0,
612 SNDRV_TIMER_CLASS_GLOBAL,
613 SNDRV_TIMER_CLASS_CARD,
614 SNDRV_TIMER_CLASS_PCM,
615 SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM,
616};
617
618/* slave timer classes */
619enum {
620 SNDRV_TIMER_SCLASS_NONE = 0,
621 SNDRV_TIMER_SCLASS_APPLICATION,
622 SNDRV_TIMER_SCLASS_SEQUENCER, /* alias */
623 SNDRV_TIMER_SCLASS_OSS_SEQUENCER, /* alias */
624 SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER,
625};
626
627/* global timers (device member) */
628#define SNDRV_TIMER_GLOBAL_SYSTEM 0
629#define SNDRV_TIMER_GLOBAL_RTC 1
630#define SNDRV_TIMER_GLOBAL_HPET 2
631#define SNDRV_TIMER_GLOBAL_HRTIMER 3
632
633/* info flags */
634#define SNDRV_TIMER_FLG_SLAVE (1<<0) /* cannot be controlled */
635
636struct snd_timer_id {
637 int dev_class;
638 int dev_sclass;
639 int card;
640 int device;
641 int subdevice;
642};
643
644struct snd_timer_ginfo {
645 struct snd_timer_id tid; /* requested timer ID */
646 unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
647 int card; /* card number */
648 unsigned char id[64]; /* timer identification */
649 unsigned char name[80]; /* timer name */
650 unsigned long reserved0; /* reserved for future use */
651 unsigned long resolution; /* average period resolution in ns */
652 unsigned long resolution_min; /* minimal period resolution in ns */
653 unsigned long resolution_max; /* maximal period resolution in ns */
654 unsigned int clients; /* active timer clients */
655 unsigned char reserved[32];
656};
657
658struct snd_timer_gparams {
659 struct snd_timer_id tid; /* requested timer ID */
660 unsigned long period_num; /* requested precise period duration (in seconds) - numerator */
661 unsigned long period_den; /* requested precise period duration (in seconds) - denominator */
662 unsigned char reserved[32];
663};
664
665struct snd_timer_gstatus {
666 struct snd_timer_id tid; /* requested timer ID */
667 unsigned long resolution; /* current period resolution in ns */
668 unsigned long resolution_num; /* precise current period resolution (in seconds) - numerator */
669 unsigned long resolution_den; /* precise current period resolution (in seconds) - denominator */
670 unsigned char reserved[32];
671};
672
673struct snd_timer_select {
674 struct snd_timer_id id; /* bind to timer ID */
675 unsigned char reserved[32]; /* reserved */
676};
677
678struct snd_timer_info {
679 unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
680 int card; /* card number */
681 unsigned char id[64]; /* timer identificator */
682 unsigned char name[80]; /* timer name */
683 unsigned long reserved0; /* reserved for future use */
684 unsigned long resolution; /* average period resolution in ns */
685 unsigned char reserved[64]; /* reserved */
686};
687
688#define SNDRV_TIMER_PSFLG_AUTO (1<<0) /* auto start, otherwise one-shot */
689#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) /* exclusive use, precise start/stop/pause/continue */
690#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2) /* write early event to the poll queue */
691
692struct snd_timer_params {
693 unsigned int flags; /* flags - SNDRV_MIXER_PSFLG_* */
694 unsigned int ticks; /* requested resolution in ticks */
695 unsigned int queue_size; /* total size of queue (32-1024) */
696 unsigned int reserved0; /* reserved, was: failure locations */
697 unsigned int filter; /* event filter (bitmask of SNDRV_TIMER_EVENT_*) */
698 unsigned char reserved[60]; /* reserved */
699};
700
701struct snd_timer_status {
702 struct timespec tstamp; /* Timestamp - last update */
703 unsigned int resolution; /* current period resolution in ns */
704 unsigned int lost; /* counter of master tick lost */
705 unsigned int overrun; /* count of read queue overruns */
706 unsigned int queue; /* used queue size */
707 unsigned char reserved[64]; /* reserved */
708};
709
710#define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int)
711#define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id)
712#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int)
713#define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo)
714#define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams)
715#define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus)
716#define SNDRV_TIMER_IOCTL_SELECT _IOW('T', 0x10, struct snd_timer_select)
717#define SNDRV_TIMER_IOCTL_INFO _IOR('T', 0x11, struct snd_timer_info)
718#define SNDRV_TIMER_IOCTL_PARAMS _IOW('T', 0x12, struct snd_timer_params)
719#define SNDRV_TIMER_IOCTL_STATUS _IOR('T', 0x14, struct snd_timer_status)
720/* The following four ioctls are changed since 1.0.9 due to confliction */
721#define SNDRV_TIMER_IOCTL_START _IO('T', 0xa0)
722#define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1)
723#define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2)
724#define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3)
725
726struct snd_timer_read {
727 unsigned int resolution;
728 unsigned int ticks;
729};
730
731enum {
732 SNDRV_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */
733 SNDRV_TIMER_EVENT_TICK, /* val = ticks */
734 SNDRV_TIMER_EVENT_START, /* val = resolution in ns */
735 SNDRV_TIMER_EVENT_STOP, /* val = 0 */
736 SNDRV_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
737 SNDRV_TIMER_EVENT_PAUSE, /* val = 0 */
738 SNDRV_TIMER_EVENT_EARLY, /* val = 0, early event */
739 SNDRV_TIMER_EVENT_SUSPEND, /* val = 0 */
740 SNDRV_TIMER_EVENT_RESUME, /* val = resolution in ns */
741 /* master timer events for slave timer instances */
742 SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
743 SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10,
744 SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10,
745 SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10,
746 SNDRV_TIMER_EVENT_MSUSPEND = SNDRV_TIMER_EVENT_SUSPEND + 10,
747 SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
748};
749
750struct snd_timer_tread {
751 int event;
752 struct timespec tstamp;
753 unsigned int val;
754};
755
756/****************************************************************************
757 * *
758 * Section for driver control interface - /dev/snd/control? *
759 * *
760 ****************************************************************************/
761
762#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7)
763
764struct snd_ctl_card_info {
765 int card; /* card number */
766 int pad; /* reserved for future (was type) */
767 unsigned char id[16]; /* ID of card (user selectable) */
768 unsigned char driver[16]; /* Driver name */
769 unsigned char name[32]; /* Short name of soundcard */
770 unsigned char longname[80]; /* name + info text about soundcard */
771 unsigned char reserved_[16]; /* reserved for future (was ID of mixer) */
772 unsigned char mixername[80]; /* visual mixer identification */
773 unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */
774};
775
776typedef int __bitwise snd_ctl_elem_type_t;
777#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0) /* invalid */
778#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1) /* boolean type */
779#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2) /* integer type */
780#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3) /* enumerated type */
781#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4) /* byte array */
782#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5) /* IEC958 (S/PDIF) setup */
783#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6) /* 64-bit integer type */
784#define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64
785
786typedef int __bitwise snd_ctl_elem_iface_t;
787#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0) /* global control */
788#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1) /* hardware dependent device */
789#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2) /* virtual mixer device */
790#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3) /* PCM device */
791#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4) /* RawMidi device */
792#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5) /* timer device */
793#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6) /* sequencer client */
794#define SNDRV_CTL_ELEM_IFACE_LAST SNDRV_CTL_ELEM_IFACE_SEQUENCER
795
796#define SNDRV_CTL_ELEM_ACCESS_READ (1<<0)
797#define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1)
798#define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE)
799#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) /* control value may be changed without a notification */
800#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3) /* when was control changed */
801#define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) /* TLV read is possible */
802#define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) /* TLV write is possible */
803#define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE)
804#define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6) /* TLV command is possible */
805#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) /* control does actually nothing, but may be updated */
806#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) /* write lock */
807#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */
808#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */
809#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */
810/* bits 30 and 31 are obsoleted (for indirect access) */
811
812/* for further details see the ACPI and PCI power management specification */
813#define SNDRV_CTL_POWER_D0 0x0000 /* full On */
814#define SNDRV_CTL_POWER_D1 0x0100 /* partial On */
815#define SNDRV_CTL_POWER_D2 0x0200 /* partial On */
816#define SNDRV_CTL_POWER_D3 0x0300 /* Off */
817#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000) /* Off, with power */
818#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001) /* Off, without power */
819
820struct snd_ctl_elem_id {
821 unsigned int numid; /* numeric identifier, zero = invalid */
822 snd_ctl_elem_iface_t iface; /* interface identifier */
823 unsigned int device; /* device/client number */
824 unsigned int subdevice; /* subdevice (substream) number */
825 unsigned char name[44]; /* ASCII name of item */
826 unsigned int index; /* index of item */
827};
828
829struct snd_ctl_elem_list {
830 unsigned int offset; /* W: first element ID to get */
831 unsigned int space; /* W: count of element IDs to get */
832 unsigned int used; /* R: count of element IDs set */
833 unsigned int count; /* R: count of all elements */
834 struct snd_ctl_elem_id __user *pids; /* R: IDs */
835 unsigned char reserved[50];
836};
837
838struct snd_ctl_elem_info {
839 struct snd_ctl_elem_id id; /* W: element ID */
840 snd_ctl_elem_type_t type; /* R: value type - SNDRV_CTL_ELEM_TYPE_* */
841 unsigned int access; /* R: value access (bitmask) - SNDRV_CTL_ELEM_ACCESS_* */
842 unsigned int count; /* count of values */
843 __kernel_pid_t owner; /* owner's PID of this control */
844 union {
845 struct {
846 long min; /* R: minimum value */
847 long max; /* R: maximum value */
848 long step; /* R: step (0 variable) */
849 } integer;
850 struct {
851 long long min; /* R: minimum value */
852 long long max; /* R: maximum value */
853 long long step; /* R: step (0 variable) */
854 } integer64;
855 struct {
856 unsigned int items; /* R: number of items */
857 unsigned int item; /* W: item number */
858 char name[64]; /* R: value name */
859 __u64 names_ptr; /* W: names list (ELEM_ADD only) */
860 unsigned int names_length;
861 } enumerated;
862 unsigned char reserved[128];
863 } value;
864 union {
865 unsigned short d[4]; /* dimensions */
866 unsigned short *d_ptr; /* indirect - obsoleted */
867 } dimen;
868 unsigned char reserved[64-4*sizeof(unsigned short)];
869};
870
871struct snd_ctl_elem_value {
872 struct snd_ctl_elem_id id; /* W: element ID */
873 unsigned int indirect: 1; /* W: indirect access - obsoleted */
874 union {
875 union {
876 long value[128];
877 long *value_ptr; /* obsoleted */
878 } integer;
879 union {
880 long long value[64];
881 long long *value_ptr; /* obsoleted */
882 } integer64;
883 union {
884 unsigned int item[128];
885 unsigned int *item_ptr; /* obsoleted */
886 } enumerated;
887 union {
888 unsigned char data[512];
889 unsigned char *data_ptr; /* obsoleted */
890 } bytes;
891 struct snd_aes_iec958 iec958;
892 } value; /* RO */
893 struct timespec tstamp;
894 unsigned char reserved[128-sizeof(struct timespec)];
895};
896
897struct snd_ctl_tlv {
898 unsigned int numid; /* control element numeric identification */
899 unsigned int length; /* in bytes aligned to 4 */
900 unsigned int tlv[0]; /* first TLV */
901};
902
903#define SNDRV_CTL_IOCTL_PVERSION _IOR('U', 0x00, int)
904#define SNDRV_CTL_IOCTL_CARD_INFO _IOR('U', 0x01, struct snd_ctl_card_info)
905#define SNDRV_CTL_IOCTL_ELEM_LIST _IOWR('U', 0x10, struct snd_ctl_elem_list)
906#define SNDRV_CTL_IOCTL_ELEM_INFO _IOWR('U', 0x11, struct snd_ctl_elem_info)
907#define SNDRV_CTL_IOCTL_ELEM_READ _IOWR('U', 0x12, struct snd_ctl_elem_value)
908#define SNDRV_CTL_IOCTL_ELEM_WRITE _IOWR('U', 0x13, struct snd_ctl_elem_value)
909#define SNDRV_CTL_IOCTL_ELEM_LOCK _IOW('U', 0x14, struct snd_ctl_elem_id)
910#define SNDRV_CTL_IOCTL_ELEM_UNLOCK _IOW('U', 0x15, struct snd_ctl_elem_id)
911#define SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS _IOWR('U', 0x16, int)
912#define SNDRV_CTL_IOCTL_ELEM_ADD _IOWR('U', 0x17, struct snd_ctl_elem_info)
913#define SNDRV_CTL_IOCTL_ELEM_REPLACE _IOWR('U', 0x18, struct snd_ctl_elem_info)
914#define SNDRV_CTL_IOCTL_ELEM_REMOVE _IOWR('U', 0x19, struct snd_ctl_elem_id)
915#define SNDRV_CTL_IOCTL_TLV_READ _IOWR('U', 0x1a, struct snd_ctl_tlv)
916#define SNDRV_CTL_IOCTL_TLV_WRITE _IOWR('U', 0x1b, struct snd_ctl_tlv)
917#define SNDRV_CTL_IOCTL_TLV_COMMAND _IOWR('U', 0x1c, struct snd_ctl_tlv)
918#define SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE _IOWR('U', 0x20, int)
919#define SNDRV_CTL_IOCTL_HWDEP_INFO _IOR('U', 0x21, struct snd_hwdep_info)
920#define SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE _IOR('U', 0x30, int)
921#define SNDRV_CTL_IOCTL_PCM_INFO _IOWR('U', 0x31, struct snd_pcm_info)
922#define SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE _IOW('U', 0x32, int)
923#define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int)
924#define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info)
925#define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int)
926#define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int)
927#define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int)
928
929/*
930 * Read interface.
931 */
932
933enum sndrv_ctl_event_type {
934 SNDRV_CTL_EVENT_ELEM = 0,
935 SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM,
936};
937
938#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0) /* element value was changed */
939#define SNDRV_CTL_EVENT_MASK_INFO (1<<1) /* element info was changed */
940#define SNDRV_CTL_EVENT_MASK_ADD (1<<2) /* element was added */
941#define SNDRV_CTL_EVENT_MASK_TLV (1<<3) /* element TLV tree was changed */
942#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) /* element was removed */
943
944struct snd_ctl_event {
945 int type; /* event type - SNDRV_CTL_EVENT_* */
946 union {
947 struct {
948 unsigned int mask;
949 struct snd_ctl_elem_id id;
950 } elem;
951 unsigned char data8[60];
952 } data;
953};
954
955/*
956 * Control names
957 */
958
959#define SNDRV_CTL_NAME_NONE ""
960#define SNDRV_CTL_NAME_PLAYBACK "Playback "
961#define SNDRV_CTL_NAME_CAPTURE "Capture "
962
963#define SNDRV_CTL_NAME_IEC958_NONE ""
964#define SNDRV_CTL_NAME_IEC958_SWITCH "Switch"
965#define SNDRV_CTL_NAME_IEC958_VOLUME "Volume"
966#define SNDRV_CTL_NAME_IEC958_DEFAULT "Default"
967#define SNDRV_CTL_NAME_IEC958_MASK "Mask"
968#define SNDRV_CTL_NAME_IEC958_CON_MASK "Con Mask"
969#define SNDRV_CTL_NAME_IEC958_PRO_MASK "Pro Mask"
970#define SNDRV_CTL_NAME_IEC958_PCM_STREAM "PCM Stream"
971#define SNDRV_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what
972
973#endif /* __SOUND_ASOUND_H */ 40#endif /* __SOUND_ASOUND_H */
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 1a33f48ebe78..3707288ae9bf 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -1,8 +1,3 @@
1#ifndef __SOUND_EMU10K1_H
2#define __SOUND_EMU10K1_H
3
4#include <linux/types.h>
5
6/* 1/*
7 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>, 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
8 * Creative Labs, Inc. 3 * Creative Labs, Inc.
@@ -24,8 +19,9 @@
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * 20 *
26 */ 21 */
22#ifndef __SOUND_EMU10K1_H
23#define __SOUND_EMU10K1_H
27 24
28#ifdef __KERNEL__
29 25
30#include <sound/pcm.h> 26#include <sound/pcm.h>
31#include <sound/rawmidi.h> 27#include <sound/rawmidi.h>
@@ -38,6 +34,7 @@
38#include <linux/mutex.h> 34#include <linux/mutex.h>
39 35
40#include <asm/io.h> 36#include <asm/io.h>
37#include <uapi/sound/emu10k1.h>
41 38
42/* ------------------- DEFINES -------------------- */ 39/* ------------------- DEFINES -------------------- */
43 40
@@ -1899,350 +1896,4 @@ int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu,
1899int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu, 1896int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu,
1900 struct snd_emu10k1_fx8010_irq *irq); 1897 struct snd_emu10k1_fx8010_irq *irq);
1901 1898
1902#endif /* __KERNEL__ */
1903
1904/*
1905 * ---- FX8010 ----
1906 */
1907
1908#define EMU10K1_CARD_CREATIVE 0x00000000
1909#define EMU10K1_CARD_EMUAPS 0x00000001
1910
1911#define EMU10K1_FX8010_PCM_COUNT 8
1912
1913/* instruction set */
1914#define iMAC0 0x00 /* R = A + (X * Y >> 31) ; saturation */
1915#define iMAC1 0x01 /* R = A + (-X * Y >> 31) ; saturation */
1916#define iMAC2 0x02 /* R = A + (X * Y >> 31) ; wraparound */
1917#define iMAC3 0x03 /* R = A + (-X * Y >> 31) ; wraparound */
1918#define iMACINT0 0x04 /* R = A + X * Y ; saturation */
1919#define iMACINT1 0x05 /* R = A + X * Y ; wraparound (31-bit) */
1920#define iACC3 0x06 /* R = A + X + Y ; saturation */
1921#define iMACMV 0x07 /* R = A, acc += X * Y >> 31 */
1922#define iANDXOR 0x08 /* R = (A & X) ^ Y */
1923#define iTSTNEG 0x09 /* R = (A >= Y) ? X : ~X */
1924#define iLIMITGE 0x0a /* R = (A >= Y) ? X : Y */
1925#define iLIMITLT 0x0b /* R = (A < Y) ? X : Y */
1926#define iLOG 0x0c /* R = linear_data, A (log_data), X (max_exp), Y (format_word) */
1927#define iEXP 0x0d /* R = log_data, A (linear_data), X (max_exp), Y (format_word) */
1928#define iINTERP 0x0e /* R = A + (X * (Y - A) >> 31) ; saturation */
1929#define iSKIP 0x0f /* R = A (cc_reg), X (count), Y (cc_test) */
1930
1931/* GPRs */
1932#define FXBUS(x) (0x00 + (x)) /* x = 0x00 - 0x0f */
1933#define EXTIN(x) (0x10 + (x)) /* x = 0x00 - 0x0f */
1934#define EXTOUT(x) (0x20 + (x)) /* x = 0x00 - 0x0f physical outs -> FXWC low 16 bits */
1935#define FXBUS2(x) (0x30 + (x)) /* x = 0x00 - 0x0f copies of fx buses for capture -> FXWC high 16 bits */
1936 /* NB: 0x31 and 0x32 are shared with Center/LFE on SB live 5.1 */
1937
1938#define C_00000000 0x40
1939#define C_00000001 0x41
1940#define C_00000002 0x42
1941#define C_00000003 0x43
1942#define C_00000004 0x44
1943#define C_00000008 0x45
1944#define C_00000010 0x46
1945#define C_00000020 0x47
1946#define C_00000100 0x48
1947#define C_00010000 0x49
1948#define C_00080000 0x4a
1949#define C_10000000 0x4b
1950#define C_20000000 0x4c
1951#define C_40000000 0x4d
1952#define C_80000000 0x4e
1953#define C_7fffffff 0x4f
1954#define C_ffffffff 0x50
1955#define C_fffffffe 0x51
1956#define C_c0000000 0x52
1957#define C_4f1bbcdc 0x53
1958#define C_5a7ef9db 0x54
1959#define C_00100000 0x55 /* ?? */
1960#define GPR_ACCU 0x56 /* ACCUM, accumulator */
1961#define GPR_COND 0x57 /* CCR, condition register */
1962#define GPR_NOISE0 0x58 /* noise source */
1963#define GPR_NOISE1 0x59 /* noise source */
1964#define GPR_IRQ 0x5a /* IRQ register */
1965#define GPR_DBAC 0x5b /* TRAM Delay Base Address Counter */
1966#define GPR(x) (FXGPREGBASE + (x)) /* free GPRs: x = 0x00 - 0xff */
1967#define ITRAM_DATA(x) (TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
1968#define ETRAM_DATA(x) (TANKMEMDATAREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
1969#define ITRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
1970#define ETRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
1971
1972#define A_ITRAM_DATA(x) (TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
1973#define A_ETRAM_DATA(x) (TANKMEMDATAREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
1974#define A_ITRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
1975#define A_ETRAM_ADDR(x) (TANKMEMADDRREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
1976#define A_ITRAM_CTL(x) (A_TANKMEMCTLREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
1977#define A_ETRAM_CTL(x) (A_TANKMEMCTLREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
1978
1979#define A_FXBUS(x) (0x00 + (x)) /* x = 0x00 - 0x3f FX buses */
1980#define A_EXTIN(x) (0x40 + (x)) /* x = 0x00 - 0x0f physical ins */
1981#define A_P16VIN(x) (0x50 + (x)) /* x = 0x00 - 0x0f p16v ins (A2 only) "EMU32 inputs" */
1982#define A_EXTOUT(x) (0x60 + (x)) /* x = 0x00 - 0x1f physical outs -> A_FXWC1 0x79-7f unknown */
1983#define A_FXBUS2(x) (0x80 + (x)) /* x = 0x00 - 0x1f extra outs used for EFX capture -> A_FXWC2 */
1984#define A_EMU32OUTH(x) (0xa0 + (x)) /* x = 0x00 - 0x0f "EMU32_OUT_10 - _1F" - ??? */
1985#define A_EMU32OUTL(x) (0xb0 + (x)) /* x = 0x00 - 0x0f "EMU32_OUT_1 - _F" - ??? */
1986#define A3_EMU32IN(x) (0x160 + (x)) /* x = 0x00 - 0x3f "EMU32_IN_00 - _3F" - Only when .device = 0x0008 */
1987#define A3_EMU32OUT(x) (0x1E0 + (x)) /* x = 0x00 - 0x0f "EMU32_OUT_00 - _3F" - Only when .device = 0x0008 */
1988#define A_GPR(x) (A_FXGPREGBASE + (x))
1989
1990/* cc_reg constants */
1991#define CC_REG_NORMALIZED C_00000001
1992#define CC_REG_BORROW C_00000002
1993#define CC_REG_MINUS C_00000004
1994#define CC_REG_ZERO C_00000008
1995#define CC_REG_SATURATE C_00000010
1996#define CC_REG_NONZERO C_00000100
1997
1998/* FX buses */
1999#define FXBUS_PCM_LEFT 0x00
2000#define FXBUS_PCM_RIGHT 0x01
2001#define FXBUS_PCM_LEFT_REAR 0x02
2002#define FXBUS_PCM_RIGHT_REAR 0x03
2003#define FXBUS_MIDI_LEFT 0x04
2004#define FXBUS_MIDI_RIGHT 0x05
2005#define FXBUS_PCM_CENTER 0x06
2006#define FXBUS_PCM_LFE 0x07
2007#define FXBUS_PCM_LEFT_FRONT 0x08
2008#define FXBUS_PCM_RIGHT_FRONT 0x09
2009#define FXBUS_MIDI_REVERB 0x0c
2010#define FXBUS_MIDI_CHORUS 0x0d
2011#define FXBUS_PCM_LEFT_SIDE 0x0e
2012#define FXBUS_PCM_RIGHT_SIDE 0x0f
2013#define FXBUS_PT_LEFT 0x14
2014#define FXBUS_PT_RIGHT 0x15
2015
2016/* Inputs */
2017#define EXTIN_AC97_L 0x00 /* AC'97 capture channel - left */
2018#define EXTIN_AC97_R 0x01 /* AC'97 capture channel - right */
2019#define EXTIN_SPDIF_CD_L 0x02 /* internal S/PDIF CD - onboard - left */
2020#define EXTIN_SPDIF_CD_R 0x03 /* internal S/PDIF CD - onboard - right */
2021#define EXTIN_ZOOM_L 0x04 /* Zoom Video I2S - left */
2022#define EXTIN_ZOOM_R 0x05 /* Zoom Video I2S - right */
2023#define EXTIN_TOSLINK_L 0x06 /* LiveDrive - TOSLink Optical - left */
2024#define EXTIN_TOSLINK_R 0x07 /* LiveDrive - TOSLink Optical - right */
2025#define EXTIN_LINE1_L 0x08 /* LiveDrive - Line/Mic 1 - left */
2026#define EXTIN_LINE1_R 0x09 /* LiveDrive - Line/Mic 1 - right */
2027#define EXTIN_COAX_SPDIF_L 0x0a /* LiveDrive - Coaxial S/PDIF - left */
2028#define EXTIN_COAX_SPDIF_R 0x0b /* LiveDrive - Coaxial S/PDIF - right */
2029#define EXTIN_LINE2_L 0x0c /* LiveDrive - Line/Mic 2 - left */
2030#define EXTIN_LINE2_R 0x0d /* LiveDrive - Line/Mic 2 - right */
2031
2032/* Outputs */
2033#define EXTOUT_AC97_L 0x00 /* AC'97 playback channel - left */
2034#define EXTOUT_AC97_R 0x01 /* AC'97 playback channel - right */
2035#define EXTOUT_TOSLINK_L 0x02 /* LiveDrive - TOSLink Optical - left */
2036#define EXTOUT_TOSLINK_R 0x03 /* LiveDrive - TOSLink Optical - right */
2037#define EXTOUT_AC97_CENTER 0x04 /* SB Live 5.1 - center */
2038#define EXTOUT_AC97_LFE 0x05 /* SB Live 5.1 - LFE */
2039#define EXTOUT_HEADPHONE_L 0x06 /* LiveDrive - Headphone - left */
2040#define EXTOUT_HEADPHONE_R 0x07 /* LiveDrive - Headphone - right */
2041#define EXTOUT_REAR_L 0x08 /* Rear channel - left */
2042#define EXTOUT_REAR_R 0x09 /* Rear channel - right */
2043#define EXTOUT_ADC_CAP_L 0x0a /* ADC Capture buffer - left */
2044#define EXTOUT_ADC_CAP_R 0x0b /* ADC Capture buffer - right */
2045#define EXTOUT_MIC_CAP 0x0c /* MIC Capture buffer */
2046#define EXTOUT_AC97_REAR_L 0x0d /* SB Live 5.1 (c) 2003 - Rear Left */
2047#define EXTOUT_AC97_REAR_R 0x0e /* SB Live 5.1 (c) 2003 - Rear Right */
2048#define EXTOUT_ACENTER 0x11 /* Analog Center */
2049#define EXTOUT_ALFE 0x12 /* Analog LFE */
2050
2051/* Audigy Inputs */
2052#define A_EXTIN_AC97_L 0x00 /* AC'97 capture channel - left */
2053#define A_EXTIN_AC97_R 0x01 /* AC'97 capture channel - right */
2054#define A_EXTIN_SPDIF_CD_L 0x02 /* digital CD left */
2055#define A_EXTIN_SPDIF_CD_R 0x03 /* digital CD left */
2056#define A_EXTIN_OPT_SPDIF_L 0x04 /* audigy drive Optical SPDIF - left */
2057#define A_EXTIN_OPT_SPDIF_R 0x05 /* right */
2058#define A_EXTIN_LINE2_L 0x08 /* audigy drive line2/mic2 - left */
2059#define A_EXTIN_LINE2_R 0x09 /* right */
2060#define A_EXTIN_ADC_L 0x0a /* Philips ADC - left */
2061#define A_EXTIN_ADC_R 0x0b /* right */
2062#define A_EXTIN_AUX2_L 0x0c /* audigy drive aux2 - left */
2063#define A_EXTIN_AUX2_R 0x0d /* - right */
2064
2065/* Audigiy Outputs */
2066#define A_EXTOUT_FRONT_L 0x00 /* digital front left */
2067#define A_EXTOUT_FRONT_R 0x01 /* right */
2068#define A_EXTOUT_CENTER 0x02 /* digital front center */
2069#define A_EXTOUT_LFE 0x03 /* digital front lfe */
2070#define A_EXTOUT_HEADPHONE_L 0x04 /* headphone audigy drive left */
2071#define A_EXTOUT_HEADPHONE_R 0x05 /* right */
2072#define A_EXTOUT_REAR_L 0x06 /* digital rear left */
2073#define A_EXTOUT_REAR_R 0x07 /* right */
2074#define A_EXTOUT_AFRONT_L 0x08 /* analog front left */
2075#define A_EXTOUT_AFRONT_R 0x09 /* right */
2076#define A_EXTOUT_ACENTER 0x0a /* analog center */
2077#define A_EXTOUT_ALFE 0x0b /* analog LFE */
2078#define A_EXTOUT_ASIDE_L 0x0c /* analog side left - Audigy 2 ZS */
2079#define A_EXTOUT_ASIDE_R 0x0d /* right - Audigy 2 ZS */
2080#define A_EXTOUT_AREAR_L 0x0e /* analog rear left */
2081#define A_EXTOUT_AREAR_R 0x0f /* right */
2082#define A_EXTOUT_AC97_L 0x10 /* AC97 left (front) */
2083#define A_EXTOUT_AC97_R 0x11 /* right */
2084#define A_EXTOUT_ADC_CAP_L 0x16 /* ADC capture buffer left */
2085#define A_EXTOUT_ADC_CAP_R 0x17 /* right */
2086#define A_EXTOUT_MIC_CAP 0x18 /* Mic capture buffer */
2087
2088/* Audigy constants */
2089#define A_C_00000000 0xc0
2090#define A_C_00000001 0xc1
2091#define A_C_00000002 0xc2
2092#define A_C_00000003 0xc3
2093#define A_C_00000004 0xc4
2094#define A_C_00000008 0xc5
2095#define A_C_00000010 0xc6
2096#define A_C_00000020 0xc7
2097#define A_C_00000100 0xc8
2098#define A_C_00010000 0xc9
2099#define A_C_00000800 0xca
2100#define A_C_10000000 0xcb
2101#define A_C_20000000 0xcc
2102#define A_C_40000000 0xcd
2103#define A_C_80000000 0xce
2104#define A_C_7fffffff 0xcf
2105#define A_C_ffffffff 0xd0
2106#define A_C_fffffffe 0xd1
2107#define A_C_c0000000 0xd2
2108#define A_C_4f1bbcdc 0xd3
2109#define A_C_5a7ef9db 0xd4
2110#define A_C_00100000 0xd5
2111#define A_GPR_ACCU 0xd6 /* ACCUM, accumulator */
2112#define A_GPR_COND 0xd7 /* CCR, condition register */
2113#define A_GPR_NOISE0 0xd8 /* noise source */
2114#define A_GPR_NOISE1 0xd9 /* noise source */
2115#define A_GPR_IRQ 0xda /* IRQ register */
2116#define A_GPR_DBAC 0xdb /* TRAM Delay Base Address Counter - internal */
2117#define A_GPR_DBACE 0xde /* TRAM Delay Base Address Counter - external */
2118
2119/* definitions for debug register */
2120#define EMU10K1_DBG_ZC 0x80000000 /* zero tram counter */
2121#define EMU10K1_DBG_SATURATION_OCCURED 0x02000000 /* saturation control */
2122#define EMU10K1_DBG_SATURATION_ADDR 0x01ff0000 /* saturation address */
2123#define EMU10K1_DBG_SINGLE_STEP 0x00008000 /* single step mode */
2124#define EMU10K1_DBG_STEP 0x00004000 /* start single step */
2125#define EMU10K1_DBG_CONDITION_CODE 0x00003e00 /* condition code */
2126#define EMU10K1_DBG_SINGLE_STEP_ADDR 0x000001ff /* single step address */
2127
2128/* tank memory address line */
2129#ifndef __KERNEL__
2130#define TANKMEMADDRREG_ADDR_MASK 0x000fffff /* 20 bit tank address field */
2131#define TANKMEMADDRREG_CLEAR 0x00800000 /* Clear tank memory */
2132#define TANKMEMADDRREG_ALIGN 0x00400000 /* Align read or write relative to tank access */
2133#define TANKMEMADDRREG_WRITE 0x00200000 /* Write to tank memory */
2134#define TANKMEMADDRREG_READ 0x00100000 /* Read from tank memory */
2135#endif
2136
2137struct snd_emu10k1_fx8010_info {
2138 unsigned int internal_tram_size; /* in samples */
2139 unsigned int external_tram_size; /* in samples */
2140 char fxbus_names[16][32]; /* names of FXBUSes */
2141 char extin_names[16][32]; /* names of external inputs */
2142 char extout_names[32][32]; /* names of external outputs */
2143 unsigned int gpr_controls; /* count of GPR controls */
2144};
2145
2146#define EMU10K1_GPR_TRANSLATION_NONE 0
2147#define EMU10K1_GPR_TRANSLATION_TABLE100 1
2148#define EMU10K1_GPR_TRANSLATION_BASS 2
2149#define EMU10K1_GPR_TRANSLATION_TREBLE 3
2150#define EMU10K1_GPR_TRANSLATION_ONOFF 4
2151
2152struct snd_emu10k1_fx8010_control_gpr {
2153 struct snd_ctl_elem_id id; /* full control ID definition */
2154 unsigned int vcount; /* visible count */
2155 unsigned int count; /* count of GPR (1..16) */
2156 unsigned short gpr[32]; /* GPR number(s) */
2157 unsigned int value[32]; /* initial values */
2158 unsigned int min; /* minimum range */
2159 unsigned int max; /* maximum range */
2160 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */
2161 const unsigned int *tlv;
2162};
2163
2164/* old ABI without TLV support */
2165struct snd_emu10k1_fx8010_control_old_gpr {
2166 struct snd_ctl_elem_id id;
2167 unsigned int vcount;
2168 unsigned int count;
2169 unsigned short gpr[32];
2170 unsigned int value[32];
2171 unsigned int min;
2172 unsigned int max;
2173 unsigned int translation;
2174};
2175
2176struct snd_emu10k1_fx8010_code {
2177 char name[128];
2178
2179 DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */
2180 __u32 __user *gpr_map; /* initializers */
2181
2182 unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */
2183 struct snd_emu10k1_fx8010_control_gpr __user *gpr_add_controls; /* GPR controls to add/replace */
2184
2185 unsigned int gpr_del_control_count; /* count of GPR controls to remove */
2186 struct snd_ctl_elem_id __user *gpr_del_controls; /* IDs of GPR controls to remove */
2187
2188 unsigned int gpr_list_control_count; /* count of GPR controls to list */
2189 unsigned int gpr_list_control_total; /* total count of GPR controls */
2190 struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /* listed GPR controls */
2191
2192 DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */
2193 __u32 __user *tram_data_map; /* data initializers */
2194 __u32 __user *tram_addr_map; /* map initializers */
2195
2196 DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */
2197 __u32 __user *code; /* one instruction - 64 bits */
2198};
2199
2200struct snd_emu10k1_fx8010_tram {
2201 unsigned int address; /* 31.bit == 1 -> external TRAM */
2202 unsigned int size; /* size in samples (4 bytes) */
2203 unsigned int *samples; /* pointer to samples (20-bit) */
2204 /* NULL->clear memory */
2205};
2206
2207struct snd_emu10k1_fx8010_pcm_rec {
2208 unsigned int substream; /* substream number */
2209 unsigned int res1; /* reserved */
2210 unsigned int channels; /* 16-bit channels count, zero = remove this substream */
2211 unsigned int tram_start; /* ring buffer position in TRAM (in samples) */
2212 unsigned int buffer_size; /* count of buffered samples */
2213 unsigned short gpr_size; /* GPR containing size of ringbuffer in samples (host) */
2214 unsigned short gpr_ptr; /* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
2215 unsigned short gpr_count; /* GPR containing count of samples between two interrupts (host) */
2216 unsigned short gpr_tmpcount; /* GPR containing current count of samples to interrupt (host = set, FX8010) */
2217 unsigned short gpr_trigger; /* GPR containing trigger (activate) information (host) */
2218 unsigned short gpr_running; /* GPR containing info if PCM is running (FX8010) */
2219 unsigned char pad; /* reserved */
2220 unsigned char etram[32]; /* external TRAM address & data (one per channel) */
2221 unsigned int res2; /* reserved */
2222};
2223
2224#define SNDRV_EMU10K1_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1)
2225
2226#define SNDRV_EMU10K1_IOCTL_INFO _IOR ('H', 0x10, struct snd_emu10k1_fx8010_info)
2227#define SNDRV_EMU10K1_IOCTL_CODE_POKE _IOW ('H', 0x11, struct snd_emu10k1_fx8010_code)
2228#define SNDRV_EMU10K1_IOCTL_CODE_PEEK _IOWR('H', 0x12, struct snd_emu10k1_fx8010_code)
2229#define SNDRV_EMU10K1_IOCTL_TRAM_SETUP _IOW ('H', 0x20, int)
2230#define SNDRV_EMU10K1_IOCTL_TRAM_POKE _IOW ('H', 0x21, struct snd_emu10k1_fx8010_tram)
2231#define SNDRV_EMU10K1_IOCTL_TRAM_PEEK _IOWR('H', 0x22, struct snd_emu10k1_fx8010_tram)
2232#define SNDRV_EMU10K1_IOCTL_PCM_POKE _IOW ('H', 0x30, struct snd_emu10k1_fx8010_pcm_rec)
2233#define SNDRV_EMU10K1_IOCTL_PCM_PEEK _IOWR('H', 0x31, struct snd_emu10k1_fx8010_pcm_rec)
2234#define SNDRV_EMU10K1_IOCTL_PVERSION _IOR ('H', 0x40, int)
2235#define SNDRV_EMU10K1_IOCTL_STOP _IO ('H', 0x80)
2236#define SNDRV_EMU10K1_IOCTL_CONTINUE _IO ('H', 0x81)
2237#define SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER _IO ('H', 0x82)
2238#define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int)
2239#define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int)
2240
2241/* typedefs for compatibility to user-space */
2242typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t;
2243typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t;
2244typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t;
2245typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t;
2246typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t;
2247
2248#endif /* __SOUND_EMU10K1_H */ 1899#endif /* __SOUND_EMU10K1_H */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 6268a4192d5c..45c1981c9ca2 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -71,6 +71,8 @@ struct snd_pcm_ops {
71 int (*prepare)(struct snd_pcm_substream *substream); 71 int (*prepare)(struct snd_pcm_substream *substream);
72 int (*trigger)(struct snd_pcm_substream *substream, int cmd); 72 int (*trigger)(struct snd_pcm_substream *substream, int cmd);
73 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream); 73 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
74 int (*wall_clock)(struct snd_pcm_substream *substream,
75 struct timespec *audio_ts);
74 int (*copy)(struct snd_pcm_substream *substream, int channel, 76 int (*copy)(struct snd_pcm_substream *substream, int channel,
75 snd_pcm_uframes_t pos, 77 snd_pcm_uframes_t pos,
76 void __user *buf, snd_pcm_uframes_t count); 78 void __user *buf, snd_pcm_uframes_t count);
@@ -281,6 +283,7 @@ struct snd_pcm_runtime {
281 unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */ 283 unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */
282 unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */ 284 unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */
283 snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */ 285 snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */
286 u64 hw_ptr_wrap; /* offset for hw_ptr due to boundary wrap-around */
284 287
285 /* -- HW params -- */ 288 /* -- HW params -- */
286 snd_pcm_access_t access; /* access mode */ 289 snd_pcm_access_t access; /* access mode */
diff --git a/include/sound/sb16_csp.h b/include/sound/sb16_csp.h
index 7e950560e591..c7c7788005e4 100644
--- a/include/sound/sb16_csp.h
+++ b/include/sound/sb16_csp.h
@@ -1,6 +1,3 @@
1#ifndef __SOUND_SB16_CSP_H
2#define __SOUND_SB16_CSP_H
3
4/* 1/*
5 * Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si> 2 * Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
6 * Takashi Iwai <tiwai@suse.de> 3 * Takashi Iwai <tiwai@suse.de>
@@ -22,106 +19,13 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * 20 *
24 */ 21 */
22#ifndef __SOUND_SB16_CSP_H
23#define __SOUND_SB16_CSP_H
25 24
26/* CSP modes */
27#define SNDRV_SB_CSP_MODE_NONE 0x00
28#define SNDRV_SB_CSP_MODE_DSP_READ 0x01 /* Record from DSP */
29#define SNDRV_SB_CSP_MODE_DSP_WRITE 0x02 /* Play to DSP */
30#define SNDRV_SB_CSP_MODE_QSOUND 0x04 /* QSound */
31
32/* CSP load flags */
33#define SNDRV_SB_CSP_LOAD_FROMUSER 0x01
34#define SNDRV_SB_CSP_LOAD_INITBLOCK 0x02
35
36/* CSP sample width */
37#define SNDRV_SB_CSP_SAMPLE_8BIT 0x01
38#define SNDRV_SB_CSP_SAMPLE_16BIT 0x02
39
40/* CSP channels */
41#define SNDRV_SB_CSP_MONO 0x01
42#define SNDRV_SB_CSP_STEREO 0x02
43
44/* CSP rates */
45#define SNDRV_SB_CSP_RATE_8000 0x01
46#define SNDRV_SB_CSP_RATE_11025 0x02
47#define SNDRV_SB_CSP_RATE_22050 0x04
48#define SNDRV_SB_CSP_RATE_44100 0x08
49#define SNDRV_SB_CSP_RATE_ALL 0x0f
50
51/* CSP running state */
52#define SNDRV_SB_CSP_ST_IDLE 0x00
53#define SNDRV_SB_CSP_ST_LOADED 0x01
54#define SNDRV_SB_CSP_ST_RUNNING 0x02
55#define SNDRV_SB_CSP_ST_PAUSED 0x04
56#define SNDRV_SB_CSP_ST_AUTO 0x08
57#define SNDRV_SB_CSP_ST_QSOUND 0x10
58
59/* maximum QSound value (180 degrees right) */
60#define SNDRV_SB_CSP_QSOUND_MAX_RIGHT 0x20
61
62/* maximum microcode RIFF file size */
63#define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE 0x3000
64
65/* microcode header */
66struct snd_sb_csp_mc_header {
67 char codec_name[16]; /* id name of codec */
68 unsigned short func_req; /* requested function */
69};
70
71/* microcode to be loaded */
72struct snd_sb_csp_microcode {
73 struct snd_sb_csp_mc_header info;
74 unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
75};
76
77/* start CSP with sample_width in mono/stereo */
78struct snd_sb_csp_start {
79 int sample_width; /* sample width, look above */
80 int channels; /* channels, look above */
81};
82
83/* CSP information */
84struct snd_sb_csp_info {
85 char codec_name[16]; /* id name of codec */
86 unsigned short func_nr; /* function number */
87 unsigned int acc_format; /* accepted PCM formats */
88 unsigned short acc_channels; /* accepted channels */
89 unsigned short acc_width; /* accepted sample width */
90 unsigned short acc_rates; /* accepted sample rates */
91 unsigned short csp_mode; /* CSP mode, see above */
92 unsigned short run_channels; /* current channels */
93 unsigned short run_width; /* current sample width */
94 unsigned short version; /* version id: 0x10 - 0x1f */
95 unsigned short state; /* state bits */
96};
97
98/* HWDEP controls */
99/* get CSP information */
100#define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info)
101/* load microcode to CSP */
102/* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits)
103 * defined for some architectures like MIPS, and it leads to build errors.
104 * (x86 and co have 14-bit size, thus it's valid, though.)
105 * As a workaround for skipping the size-limit check, here we don't use the
106 * normal _IOW() macro but _IOC() with the manual argument.
107 */
108#define SNDRV_SB_CSP_IOCTL_LOAD_CODE \
109 _IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode))
110/* unload microcode from CSP */
111#define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12)
112/* start CSP */
113#define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, struct snd_sb_csp_start)
114/* stop CSP */
115#define SNDRV_SB_CSP_IOCTL_STOP _IO('H', 0x14)
116/* pause CSP and DMA transfer */
117#define SNDRV_SB_CSP_IOCTL_PAUSE _IO('H', 0x15)
118/* restart CSP and DMA transfer */
119#define SNDRV_SB_CSP_IOCTL_RESTART _IO('H', 0x16)
120
121#ifdef __KERNEL__
122#include <sound/sb.h> 25#include <sound/sb.h>
123#include <sound/hwdep.h> 26#include <sound/hwdep.h>
124#include <linux/firmware.h> 27#include <linux/firmware.h>
28#include <uapi/sound/sb16_csp.h>
125 29
126struct snd_sb_csp; 30struct snd_sb_csp;
127 31
@@ -183,6 +87,4 @@ struct snd_sb_csp {
183}; 87};
184 88
185int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep); 89int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep);
186#endif
187
188#endif /* __SOUND_SB16_CSP */ 90#endif /* __SOUND_SB16_CSP */
diff --git a/include/uapi/sound/Kbuild b/include/uapi/sound/Kbuild
index aafaa5aa54d4..0f7d279ebde3 100644
--- a/include/uapi/sound/Kbuild
+++ b/include/uapi/sound/Kbuild
@@ -1 +1,11 @@
1# UAPI Header export list 1# UAPI Header export list
2header-y += asequencer.h
3header-y += asound.h
4header-y += asound_fm.h
5header-y += compress_offload.h
6header-y += compress_params.h
7header-y += emu10k1.h
8header-y += hdsp.h
9header-y += hdspm.h
10header-y += sb16_csp.h
11header-y += sfnt_info.h
diff --git a/include/uapi/sound/asequencer.h b/include/uapi/sound/asequencer.h
new file mode 100644
index 000000000000..09c8a00ea503
--- /dev/null
+++ b/include/uapi/sound/asequencer.h
@@ -0,0 +1,614 @@
1/*
2 * Main header file for the ALSA sequencer
3 * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22#ifndef _UAPI__SOUND_ASEQUENCER_H
23#define _UAPI__SOUND_ASEQUENCER_H
24
25
26/** version of the sequencer */
27#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 1)
28
29/**
30 * definition of sequencer event types
31 */
32
33/** system messages
34 * event data type = #snd_seq_result
35 */
36#define SNDRV_SEQ_EVENT_SYSTEM 0
37#define SNDRV_SEQ_EVENT_RESULT 1
38
39/** note messages (channel specific)
40 * event data type = #snd_seq_ev_note
41 */
42#define SNDRV_SEQ_EVENT_NOTE 5
43#define SNDRV_SEQ_EVENT_NOTEON 6
44#define SNDRV_SEQ_EVENT_NOTEOFF 7
45#define SNDRV_SEQ_EVENT_KEYPRESS 8
46
47/** control messages (channel specific)
48 * event data type = #snd_seq_ev_ctrl
49 */
50#define SNDRV_SEQ_EVENT_CONTROLLER 10
51#define SNDRV_SEQ_EVENT_PGMCHANGE 11
52#define SNDRV_SEQ_EVENT_CHANPRESS 12
53#define SNDRV_SEQ_EVENT_PITCHBEND 13 /**< from -8192 to 8191 */
54#define SNDRV_SEQ_EVENT_CONTROL14 14 /**< 14 bit controller value */
55#define SNDRV_SEQ_EVENT_NONREGPARAM 15 /**< 14 bit NRPN address + 14 bit unsigned value */
56#define SNDRV_SEQ_EVENT_REGPARAM 16 /**< 14 bit RPN address + 14 bit unsigned value */
57
58/** synchronisation messages
59 * event data type = #snd_seq_ev_ctrl
60 */
61#define SNDRV_SEQ_EVENT_SONGPOS 20 /* Song Position Pointer with LSB and MSB values */
62#define SNDRV_SEQ_EVENT_SONGSEL 21 /* Song Select with song ID number */
63#define SNDRV_SEQ_EVENT_QFRAME 22 /* midi time code quarter frame */
64#define SNDRV_SEQ_EVENT_TIMESIGN 23 /* SMF Time Signature event */
65#define SNDRV_SEQ_EVENT_KEYSIGN 24 /* SMF Key Signature event */
66
67/** timer messages
68 * event data type = snd_seq_ev_queue_control
69 */
70#define SNDRV_SEQ_EVENT_START 30 /* midi Real Time Start message */
71#define SNDRV_SEQ_EVENT_CONTINUE 31 /* midi Real Time Continue message */
72#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */
73#define SNDRV_SEQ_EVENT_SETPOS_TICK 33 /* set tick queue position */
74#define SNDRV_SEQ_EVENT_SETPOS_TIME 34 /* set realtime queue position */
75#define SNDRV_SEQ_EVENT_TEMPO 35 /* (SMF) Tempo event */
76#define SNDRV_SEQ_EVENT_CLOCK 36 /* midi Real Time Clock message */
77#define SNDRV_SEQ_EVENT_TICK 37 /* midi Real Time Tick message */
78#define SNDRV_SEQ_EVENT_QUEUE_SKEW 38 /* skew queue tempo */
79
80/** others
81 * event data type = none
82 */
83#define SNDRV_SEQ_EVENT_TUNE_REQUEST 40 /* tune request */
84#define SNDRV_SEQ_EVENT_RESET 41 /* reset to power-on state */
85#define SNDRV_SEQ_EVENT_SENSING 42 /* "active sensing" event */
86
87/** echo back, kernel private messages
88 * event data type = any type
89 */
90#define SNDRV_SEQ_EVENT_ECHO 50 /* echo event */
91#define SNDRV_SEQ_EVENT_OSS 51 /* OSS raw event */
92
93/** system status messages (broadcast for subscribers)
94 * event data type = snd_seq_addr
95 */
96#define SNDRV_SEQ_EVENT_CLIENT_START 60 /* new client has connected */
97#define SNDRV_SEQ_EVENT_CLIENT_EXIT 61 /* client has left the system */
98#define SNDRV_SEQ_EVENT_CLIENT_CHANGE 62 /* client status/info has changed */
99#define SNDRV_SEQ_EVENT_PORT_START 63 /* new port was created */
100#define SNDRV_SEQ_EVENT_PORT_EXIT 64 /* port was deleted from system */
101#define SNDRV_SEQ_EVENT_PORT_CHANGE 65 /* port status/info has changed */
102
103/** port connection changes
104 * event data type = snd_seq_connect
105 */
106#define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */
107#define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */
108
109/* 70-89: synthesizer events - obsoleted */
110
111/** user-defined events with fixed length
112 * event data type = any
113 */
114#define SNDRV_SEQ_EVENT_USR0 90
115#define SNDRV_SEQ_EVENT_USR1 91
116#define SNDRV_SEQ_EVENT_USR2 92
117#define SNDRV_SEQ_EVENT_USR3 93
118#define SNDRV_SEQ_EVENT_USR4 94
119#define SNDRV_SEQ_EVENT_USR5 95
120#define SNDRV_SEQ_EVENT_USR6 96
121#define SNDRV_SEQ_EVENT_USR7 97
122#define SNDRV_SEQ_EVENT_USR8 98
123#define SNDRV_SEQ_EVENT_USR9 99
124
125/* 100-118: instrument layer - obsoleted */
126/* 119-129: reserved */
127
128/* 130-139: variable length events
129 * event data type = snd_seq_ev_ext
130 * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set)
131 */
132#define SNDRV_SEQ_EVENT_SYSEX 130 /* system exclusive data (variable length) */
133#define SNDRV_SEQ_EVENT_BOUNCE 131 /* error event */
134/* 132-134: reserved */
135#define SNDRV_SEQ_EVENT_USR_VAR0 135
136#define SNDRV_SEQ_EVENT_USR_VAR1 136
137#define SNDRV_SEQ_EVENT_USR_VAR2 137
138#define SNDRV_SEQ_EVENT_USR_VAR3 138
139#define SNDRV_SEQ_EVENT_USR_VAR4 139
140
141/* 150-151: kernel events with quote - DO NOT use in user clients */
142#define SNDRV_SEQ_EVENT_KERNEL_ERROR 150
143#define SNDRV_SEQ_EVENT_KERNEL_QUOTE 151 /* obsolete */
144
145/* 152-191: reserved */
146
147/* 192-254: hardware specific events */
148
149/* 255: special event */
150#define SNDRV_SEQ_EVENT_NONE 255
151
152
153typedef unsigned char snd_seq_event_type_t;
154
155/** event address */
156struct snd_seq_addr {
157 unsigned char client; /**< Client number: 0..255, 255 = broadcast to all clients */
158 unsigned char port; /**< Port within client: 0..255, 255 = broadcast to all ports */
159};
160
161/** port connection */
162struct snd_seq_connect {
163 struct snd_seq_addr sender;
164 struct snd_seq_addr dest;
165};
166
167
168#define SNDRV_SEQ_ADDRESS_UNKNOWN 253 /* unknown source */
169#define SNDRV_SEQ_ADDRESS_SUBSCRIBERS 254 /* send event to all subscribed ports */
170#define SNDRV_SEQ_ADDRESS_BROADCAST 255 /* send event to all queues/clients/ports/channels */
171#define SNDRV_SEQ_QUEUE_DIRECT 253 /* direct dispatch */
172
173 /* event mode flag - NOTE: only 8 bits available! */
174#define SNDRV_SEQ_TIME_STAMP_TICK (0<<0) /* timestamp in clock ticks */
175#define SNDRV_SEQ_TIME_STAMP_REAL (1<<0) /* timestamp in real time */
176#define SNDRV_SEQ_TIME_STAMP_MASK (1<<0)
177
178#define SNDRV_SEQ_TIME_MODE_ABS (0<<1) /* absolute timestamp */
179#define SNDRV_SEQ_TIME_MODE_REL (1<<1) /* relative to current time */
180#define SNDRV_SEQ_TIME_MODE_MASK (1<<1)
181
182#define SNDRV_SEQ_EVENT_LENGTH_FIXED (0<<2) /* fixed event size */
183#define SNDRV_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /* variable event size */
184#define SNDRV_SEQ_EVENT_LENGTH_VARUSR (2<<2) /* variable event size - user memory space */
185#define SNDRV_SEQ_EVENT_LENGTH_MASK (3<<2)
186
187#define SNDRV_SEQ_PRIORITY_NORMAL (0<<4) /* normal priority */
188#define SNDRV_SEQ_PRIORITY_HIGH (1<<4) /* event should be processed before others */
189#define SNDRV_SEQ_PRIORITY_MASK (1<<4)
190
191
192 /* note event */
193struct snd_seq_ev_note {
194 unsigned char channel;
195 unsigned char note;
196 unsigned char velocity;
197 unsigned char off_velocity; /* only for SNDRV_SEQ_EVENT_NOTE */
198 unsigned int duration; /* only for SNDRV_SEQ_EVENT_NOTE */
199};
200
201 /* controller event */
202struct snd_seq_ev_ctrl {
203 unsigned char channel;
204 unsigned char unused1, unused2, unused3; /* pad */
205 unsigned int param;
206 signed int value;
207};
208
209 /* generic set of bytes (12x8 bit) */
210struct snd_seq_ev_raw8 {
211 unsigned char d[12]; /* 8 bit value */
212};
213
214 /* generic set of integers (3x32 bit) */
215struct snd_seq_ev_raw32 {
216 unsigned int d[3]; /* 32 bit value */
217};
218
219 /* external stored data */
220struct snd_seq_ev_ext {
221 unsigned int len; /* length of data */
222 void *ptr; /* pointer to data (note: maybe 64-bit) */
223} __attribute__((packed));
224
225struct snd_seq_result {
226 int event; /* processed event type */
227 int result;
228};
229
230
231struct snd_seq_real_time {
232 unsigned int tv_sec; /* seconds */
233 unsigned int tv_nsec; /* nanoseconds */
234};
235
236typedef unsigned int snd_seq_tick_time_t; /* midi ticks */
237
238union snd_seq_timestamp {
239 snd_seq_tick_time_t tick;
240 struct snd_seq_real_time time;
241};
242
243struct snd_seq_queue_skew {
244 unsigned int value;
245 unsigned int base;
246};
247
248 /* queue timer control */
249struct snd_seq_ev_queue_control {
250 unsigned char queue; /* affected queue */
251 unsigned char pad[3]; /* reserved */
252 union {
253 signed int value; /* affected value (e.g. tempo) */
254 union snd_seq_timestamp time; /* time */
255 unsigned int position; /* sync position */
256 struct snd_seq_queue_skew skew;
257 unsigned int d32[2];
258 unsigned char d8[8];
259 } param;
260};
261
262 /* quoted event - inside the kernel only */
263struct snd_seq_ev_quote {
264 struct snd_seq_addr origin; /* original sender */
265 unsigned short value; /* optional data */
266 struct snd_seq_event *event; /* quoted event */
267} __attribute__((packed));
268
269
270 /* sequencer event */
271struct snd_seq_event {
272 snd_seq_event_type_t type; /* event type */
273 unsigned char flags; /* event flags */
274 char tag;
275
276 unsigned char queue; /* schedule queue */
277 union snd_seq_timestamp time; /* schedule time */
278
279
280 struct snd_seq_addr source; /* source address */
281 struct snd_seq_addr dest; /* destination address */
282
283 union { /* event data... */
284 struct snd_seq_ev_note note;
285 struct snd_seq_ev_ctrl control;
286 struct snd_seq_ev_raw8 raw8;
287 struct snd_seq_ev_raw32 raw32;
288 struct snd_seq_ev_ext ext;
289 struct snd_seq_ev_queue_control queue;
290 union snd_seq_timestamp time;
291 struct snd_seq_addr addr;
292 struct snd_seq_connect connect;
293 struct snd_seq_result result;
294 struct snd_seq_ev_quote quote;
295 } data;
296};
297
298
299/*
300 * bounce event - stored as variable size data
301 */
302struct snd_seq_event_bounce {
303 int err;
304 struct snd_seq_event event;
305 /* external data follows here. */
306};
307
308
309 /* system information */
310struct snd_seq_system_info {
311 int queues; /* maximum queues count */
312 int clients; /* maximum clients count */
313 int ports; /* maximum ports per client */
314 int channels; /* maximum channels per port */
315 int cur_clients; /* current clients */
316 int cur_queues; /* current queues */
317 char reserved[24];
318};
319
320
321 /* system running information */
322struct snd_seq_running_info {
323 unsigned char client; /* client id */
324 unsigned char big_endian; /* 1 = big-endian */
325 unsigned char cpu_mode; /* 4 = 32bit, 8 = 64bit */
326 unsigned char pad; /* reserved */
327 unsigned char reserved[12];
328};
329
330
331 /* known client numbers */
332#define SNDRV_SEQ_CLIENT_SYSTEM 0
333 /* internal client numbers */
334#define SNDRV_SEQ_CLIENT_DUMMY 14 /* midi through */
335#define SNDRV_SEQ_CLIENT_OSS 15 /* oss sequencer emulator */
336
337
338 /* client types */
339typedef int __bitwise snd_seq_client_type_t;
340#define NO_CLIENT ((__force snd_seq_client_type_t) 0)
341#define USER_CLIENT ((__force snd_seq_client_type_t) 1)
342#define KERNEL_CLIENT ((__force snd_seq_client_type_t) 2)
343
344 /* event filter flags */
345#define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */
346#define SNDRV_SEQ_FILTER_MULTICAST (1<<1) /* accept multicast messages */
347#define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */
348#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */
349
350struct snd_seq_client_info {
351 int client; /* client number to inquire */
352 snd_seq_client_type_t type; /* client type */
353 char name[64]; /* client name */
354 unsigned int filter; /* filter flags */
355 unsigned char multicast_filter[8]; /* multicast filter bitmap */
356 unsigned char event_filter[32]; /* event filter bitmap */
357 int num_ports; /* RO: number of ports */
358 int event_lost; /* number of lost events */
359 char reserved[64]; /* for future use */
360};
361
362
363/* client pool size */
364struct snd_seq_client_pool {
365 int client; /* client number to inquire */
366 int output_pool; /* outgoing (write) pool size */
367 int input_pool; /* incoming (read) pool size */
368 int output_room; /* minimum free pool size for select/blocking mode */
369 int output_free; /* unused size */
370 int input_free; /* unused size */
371 char reserved[64];
372};
373
374
375/* Remove events by specified criteria */
376
377#define SNDRV_SEQ_REMOVE_INPUT (1<<0) /* Flush input queues */
378#define SNDRV_SEQ_REMOVE_OUTPUT (1<<1) /* Flush output queues */
379#define SNDRV_SEQ_REMOVE_DEST (1<<2) /* Restrict by destination q:client:port */
380#define SNDRV_SEQ_REMOVE_DEST_CHANNEL (1<<3) /* Restrict by channel */
381#define SNDRV_SEQ_REMOVE_TIME_BEFORE (1<<4) /* Restrict to before time */
382#define SNDRV_SEQ_REMOVE_TIME_AFTER (1<<5) /* Restrict to time or after */
383#define SNDRV_SEQ_REMOVE_TIME_TICK (1<<6) /* Time is in ticks */
384#define SNDRV_SEQ_REMOVE_EVENT_TYPE (1<<7) /* Restrict to event type */
385#define SNDRV_SEQ_REMOVE_IGNORE_OFF (1<<8) /* Do not flush off events */
386#define SNDRV_SEQ_REMOVE_TAG_MATCH (1<<9) /* Restrict to events with given tag */
387
388struct snd_seq_remove_events {
389 unsigned int remove_mode; /* Flags that determine what gets removed */
390
391 union snd_seq_timestamp time;
392
393 unsigned char queue; /* Queue for REMOVE_DEST */
394 struct snd_seq_addr dest; /* Address for REMOVE_DEST */
395 unsigned char channel; /* Channel for REMOVE_DEST */
396
397 int type; /* For REMOVE_EVENT_TYPE */
398 char tag; /* Tag for REMOVE_TAG */
399
400 int reserved[10]; /* To allow for future binary compatibility */
401
402};
403
404
405 /* known port numbers */
406#define SNDRV_SEQ_PORT_SYSTEM_TIMER 0
407#define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE 1
408
409 /* port capabilities (32 bits) */
410#define SNDRV_SEQ_PORT_CAP_READ (1<<0) /* readable from this port */
411#define SNDRV_SEQ_PORT_CAP_WRITE (1<<1) /* writable to this port */
412
413#define SNDRV_SEQ_PORT_CAP_SYNC_READ (1<<2)
414#define SNDRV_SEQ_PORT_CAP_SYNC_WRITE (1<<3)
415
416#define SNDRV_SEQ_PORT_CAP_DUPLEX (1<<4)
417
418#define SNDRV_SEQ_PORT_CAP_SUBS_READ (1<<5) /* allow read subscription */
419#define SNDRV_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /* allow write subscription */
420#define SNDRV_SEQ_PORT_CAP_NO_EXPORT (1<<7) /* routing not allowed */
421
422 /* port type */
423#define SNDRV_SEQ_PORT_TYPE_SPECIFIC (1<<0) /* hardware specific */
424#define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /* generic MIDI device */
425#define SNDRV_SEQ_PORT_TYPE_MIDI_GM (1<<2) /* General MIDI compatible device */
426#define SNDRV_SEQ_PORT_TYPE_MIDI_GS (1<<3) /* GS compatible device */
427#define SNDRV_SEQ_PORT_TYPE_MIDI_XG (1<<4) /* XG compatible device */
428#define SNDRV_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /* MT-32 compatible device */
429#define SNDRV_SEQ_PORT_TYPE_MIDI_GM2 (1<<6) /* General MIDI 2 compatible device */
430
431/* other standards...*/
432#define SNDRV_SEQ_PORT_TYPE_SYNTH (1<<10) /* Synth device (no MIDI compatible - direct wavetable) */
433#define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /* Sampling device (support sample download) */
434#define SNDRV_SEQ_PORT_TYPE_SAMPLE (1<<12) /* Sampling device (sample can be downloaded at any time) */
435/*...*/
436#define SNDRV_SEQ_PORT_TYPE_HARDWARE (1<<16) /* driver for a hardware device */
437#define SNDRV_SEQ_PORT_TYPE_SOFTWARE (1<<17) /* implemented in software */
438#define SNDRV_SEQ_PORT_TYPE_SYNTHESIZER (1<<18) /* generates sound */
439#define SNDRV_SEQ_PORT_TYPE_PORT (1<<19) /* connects to other device(s) */
440#define SNDRV_SEQ_PORT_TYPE_APPLICATION (1<<20) /* application (sequencer/editor) */
441
442/* misc. conditioning flags */
443#define SNDRV_SEQ_PORT_FLG_GIVEN_PORT (1<<0)
444#define SNDRV_SEQ_PORT_FLG_TIMESTAMP (1<<1)
445#define SNDRV_SEQ_PORT_FLG_TIME_REAL (1<<2)
446
447struct snd_seq_port_info {
448 struct snd_seq_addr addr; /* client/port numbers */
449 char name[64]; /* port name */
450
451 unsigned int capability; /* port capability bits */
452 unsigned int type; /* port type bits */
453 int midi_channels; /* channels per MIDI port */
454 int midi_voices; /* voices per MIDI port */
455 int synth_voices; /* voices per SYNTH port */
456
457 int read_use; /* R/O: subscribers for output (from this port) */
458 int write_use; /* R/O: subscribers for input (to this port) */
459
460 void *kernel; /* reserved for kernel use (must be NULL) */
461 unsigned int flags; /* misc. conditioning */
462 unsigned char time_queue; /* queue # for timestamping */
463 char reserved[59]; /* for future use */
464};
465
466
467/* queue flags */
468#define SNDRV_SEQ_QUEUE_FLG_SYNC (1<<0) /* sync enabled */
469
470/* queue information */
471struct snd_seq_queue_info {
472 int queue; /* queue id */
473
474 /*
475 * security settings, only owner of this queue can start/stop timer
476 * etc. if the queue is locked for other clients
477 */
478 int owner; /* client id for owner of the queue */
479 unsigned locked:1; /* timing queue locked for other queues */
480 char name[64]; /* name of this queue */
481 unsigned int flags; /* flags */
482 char reserved[60]; /* for future use */
483
484};
485
486/* queue info/status */
487struct snd_seq_queue_status {
488 int queue; /* queue id */
489 int events; /* read-only - queue size */
490 snd_seq_tick_time_t tick; /* current tick */
491 struct snd_seq_real_time time; /* current time */
492 int running; /* running state of queue */
493 int flags; /* various flags */
494 char reserved[64]; /* for the future */
495};
496
497
498/* queue tempo */
499struct snd_seq_queue_tempo {
500 int queue; /* sequencer queue */
501 unsigned int tempo; /* current tempo, us/tick */
502 int ppq; /* time resolution, ticks/quarter */
503 unsigned int skew_value; /* queue skew */
504 unsigned int skew_base; /* queue skew base */
505 char reserved[24]; /* for the future */
506};
507
508
509/* sequencer timer sources */
510#define SNDRV_SEQ_TIMER_ALSA 0 /* ALSA timer */
511#define SNDRV_SEQ_TIMER_MIDI_CLOCK 1 /* Midi Clock (CLOCK event) */
512#define SNDRV_SEQ_TIMER_MIDI_TICK 2 /* Midi Timer Tick (TICK event) */
513
514/* queue timer info */
515struct snd_seq_queue_timer {
516 int queue; /* sequencer queue */
517 int type; /* source timer type */
518 union {
519 struct {
520 struct snd_timer_id id; /* ALSA's timer ID */
521 unsigned int resolution; /* resolution in Hz */
522 } alsa;
523 } u;
524 char reserved[64]; /* for the future use */
525};
526
527
528struct snd_seq_queue_client {
529 int queue; /* sequencer queue */
530 int client; /* sequencer client */
531 int used; /* queue is used with this client
532 (must be set for accepting events) */
533 /* per client watermarks */
534 char reserved[64]; /* for future use */
535};
536
537
538#define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE (1<<0) /* exclusive connection */
539#define SNDRV_SEQ_PORT_SUBS_TIMESTAMP (1<<1)
540#define SNDRV_SEQ_PORT_SUBS_TIME_REAL (1<<2)
541
542struct snd_seq_port_subscribe {
543 struct snd_seq_addr sender; /* sender address */
544 struct snd_seq_addr dest; /* destination address */
545 unsigned int voices; /* number of voices to be allocated (0 = don't care) */
546 unsigned int flags; /* modes */
547 unsigned char queue; /* input time-stamp queue (optional) */
548 unsigned char pad[3]; /* reserved */
549 char reserved[64];
550};
551
552/* type of query subscription */
553#define SNDRV_SEQ_QUERY_SUBS_READ 0
554#define SNDRV_SEQ_QUERY_SUBS_WRITE 1
555
556struct snd_seq_query_subs {
557 struct snd_seq_addr root; /* client/port id to be searched */
558 int type; /* READ or WRITE */
559 int index; /* 0..N-1 */
560 int num_subs; /* R/O: number of subscriptions on this port */
561 struct snd_seq_addr addr; /* R/O: result */
562 unsigned char queue; /* R/O: result */
563 unsigned int flags; /* R/O: result */
564 char reserved[64]; /* for future use */
565};
566
567
568/*
569 * IOCTL commands
570 */
571
572#define SNDRV_SEQ_IOCTL_PVERSION _IOR ('S', 0x00, int)
573#define SNDRV_SEQ_IOCTL_CLIENT_ID _IOR ('S', 0x01, int)
574#define SNDRV_SEQ_IOCTL_SYSTEM_INFO _IOWR('S', 0x02, struct snd_seq_system_info)
575#define SNDRV_SEQ_IOCTL_RUNNING_MODE _IOWR('S', 0x03, struct snd_seq_running_info)
576
577#define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct snd_seq_client_info)
578#define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW ('S', 0x11, struct snd_seq_client_info)
579
580#define SNDRV_SEQ_IOCTL_CREATE_PORT _IOWR('S', 0x20, struct snd_seq_port_info)
581#define SNDRV_SEQ_IOCTL_DELETE_PORT _IOW ('S', 0x21, struct snd_seq_port_info)
582#define SNDRV_SEQ_IOCTL_GET_PORT_INFO _IOWR('S', 0x22, struct snd_seq_port_info)
583#define SNDRV_SEQ_IOCTL_SET_PORT_INFO _IOW ('S', 0x23, struct snd_seq_port_info)
584
585#define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT _IOW ('S', 0x30, struct snd_seq_port_subscribe)
586#define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct snd_seq_port_subscribe)
587
588#define SNDRV_SEQ_IOCTL_CREATE_QUEUE _IOWR('S', 0x32, struct snd_seq_queue_info)
589#define SNDRV_SEQ_IOCTL_DELETE_QUEUE _IOW ('S', 0x33, struct snd_seq_queue_info)
590#define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO _IOWR('S', 0x34, struct snd_seq_queue_info)
591#define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO _IOWR('S', 0x35, struct snd_seq_queue_info)
592#define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct snd_seq_queue_info)
593#define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status)
594#define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct snd_seq_queue_tempo)
595#define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW ('S', 0x42, struct snd_seq_queue_tempo)
596#define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct snd_seq_queue_owner)
597#define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW ('S', 0x44, struct snd_seq_queue_owner)
598#define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct snd_seq_queue_timer)
599#define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW ('S', 0x46, struct snd_seq_queue_timer)
600/* XXX
601#define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC _IOWR('S', 0x53, struct snd_seq_queue_sync)
602#define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC _IOW ('S', 0x54, struct snd_seq_queue_sync)
603*/
604#define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT _IOWR('S', 0x49, struct snd_seq_queue_client)
605#define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT _IOW ('S', 0x4a, struct snd_seq_queue_client)
606#define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL _IOWR('S', 0x4b, struct snd_seq_client_pool)
607#define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL _IOW ('S', 0x4c, struct snd_seq_client_pool)
608#define SNDRV_SEQ_IOCTL_REMOVE_EVENTS _IOW ('S', 0x4e, struct snd_seq_remove_events)
609#define SNDRV_SEQ_IOCTL_QUERY_SUBS _IOWR('S', 0x4f, struct snd_seq_query_subs)
610#define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION _IOWR('S', 0x50, struct snd_seq_port_subscribe)
611#define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT _IOWR('S', 0x51, struct snd_seq_client_info)
612#define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT _IOWR('S', 0x52, struct snd_seq_port_info)
613
614#endif /* _UAPI__SOUND_ASEQUENCER_H */
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
new file mode 100644
index 000000000000..515b8fcd1ca9
--- /dev/null
+++ b/include/uapi/sound/asound.h
@@ -0,0 +1,961 @@
1/*
2 * Advanced Linux Sound Architecture - ALSA - Driver
3 * Copyright (c) 1994-2003 by Jaroslav Kysela <perex@perex.cz>,
4 * Abramo Bagnara <abramo@alsa-project.org>
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef _UAPI__SOUND_ASOUND_H
24#define _UAPI__SOUND_ASOUND_H
25
26#include <linux/types.h>
27
28
29/*
30 * protocol version
31 */
32
33#define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor))
34#define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff)
35#define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff)
36#define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff)
37#define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) \
38 (SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || \
39 (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && \
40 SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion)))
41
42/****************************************************************************
43 * *
44 * Digital audio interface *
45 * *
46 ****************************************************************************/
47
48struct snd_aes_iec958 {
49 unsigned char status[24]; /* AES/IEC958 channel status bits */
50 unsigned char subcode[147]; /* AES/IEC958 subcode bits */
51 unsigned char pad; /* nothing */
52 unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */
53};
54
55/****************************************************************************
56 * *
57 * CEA-861 Audio InfoFrame. Used in HDMI and DisplayPort *
58 * *
59 ****************************************************************************/
60
61struct snd_cea_861_aud_if {
62 unsigned char db1_ct_cc; /* coding type and channel count */
63 unsigned char db2_sf_ss; /* sample frequency and size */
64 unsigned char db3; /* not used, all zeros */
65 unsigned char db4_ca; /* channel allocation code */
66 unsigned char db5_dminh_lsv; /* downmix inhibit & level-shit values */
67};
68
69/****************************************************************************
70 * *
71 * Section for driver hardware dependent interface - /dev/snd/hw? *
72 * *
73 ****************************************************************************/
74
75#define SNDRV_HWDEP_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1)
76
77enum {
78 SNDRV_HWDEP_IFACE_OPL2 = 0,
79 SNDRV_HWDEP_IFACE_OPL3,
80 SNDRV_HWDEP_IFACE_OPL4,
81 SNDRV_HWDEP_IFACE_SB16CSP, /* Creative Signal Processor */
82 SNDRV_HWDEP_IFACE_EMU10K1, /* FX8010 processor in EMU10K1 chip */
83 SNDRV_HWDEP_IFACE_YSS225, /* Yamaha FX processor */
84 SNDRV_HWDEP_IFACE_ICS2115, /* Wavetable synth */
85 SNDRV_HWDEP_IFACE_SSCAPE, /* Ensoniq SoundScape ISA card (MC68EC000) */
86 SNDRV_HWDEP_IFACE_VX, /* Digigram VX cards */
87 SNDRV_HWDEP_IFACE_MIXART, /* Digigram miXart cards */
88 SNDRV_HWDEP_IFACE_USX2Y, /* Tascam US122, US224 & US428 usb */
89 SNDRV_HWDEP_IFACE_EMUX_WAVETABLE, /* EmuX wavetable */
90 SNDRV_HWDEP_IFACE_BLUETOOTH, /* Bluetooth audio */
91 SNDRV_HWDEP_IFACE_USX2Y_PCM, /* Tascam US122, US224 & US428 rawusb pcm */
92 SNDRV_HWDEP_IFACE_PCXHR, /* Digigram PCXHR */
93 SNDRV_HWDEP_IFACE_SB_RC, /* SB Extigy/Audigy2NX remote control */
94 SNDRV_HWDEP_IFACE_HDA, /* HD-audio */
95 SNDRV_HWDEP_IFACE_USB_STREAM, /* direct access to usb stream */
96
97 /* Don't forget to change the following: */
98 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM
99};
100
101struct snd_hwdep_info {
102 unsigned int device; /* WR: device number */
103 int card; /* R: card number */
104 unsigned char id[64]; /* ID (user selectable) */
105 unsigned char name[80]; /* hwdep name */
106 int iface; /* hwdep interface */
107 unsigned char reserved[64]; /* reserved for future */
108};
109
110/* generic DSP loader */
111struct snd_hwdep_dsp_status {
112 unsigned int version; /* R: driver-specific version */
113 unsigned char id[32]; /* R: driver-specific ID string */
114 unsigned int num_dsps; /* R: number of DSP images to transfer */
115 unsigned int dsp_loaded; /* R: bit flags indicating the loaded DSPs */
116 unsigned int chip_ready; /* R: 1 = initialization finished */
117 unsigned char reserved[16]; /* reserved for future use */
118};
119
120struct snd_hwdep_dsp_image {
121 unsigned int index; /* W: DSP index */
122 unsigned char name[64]; /* W: ID (e.g. file name) */
123 unsigned char __user *image; /* W: binary image */
124 size_t length; /* W: size of image in bytes */
125 unsigned long driver_data; /* W: driver-specific data */
126};
127
128#define SNDRV_HWDEP_IOCTL_PVERSION _IOR ('H', 0x00, int)
129#define SNDRV_HWDEP_IOCTL_INFO _IOR ('H', 0x01, struct snd_hwdep_info)
130#define SNDRV_HWDEP_IOCTL_DSP_STATUS _IOR('H', 0x02, struct snd_hwdep_dsp_status)
131#define SNDRV_HWDEP_IOCTL_DSP_LOAD _IOW('H', 0x03, struct snd_hwdep_dsp_image)
132
133/*****************************************************************************
134 * *
135 * Digital Audio (PCM) interface - /dev/snd/pcm?? *
136 * *
137 *****************************************************************************/
138
139#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 11)
140
141typedef unsigned long snd_pcm_uframes_t;
142typedef signed long snd_pcm_sframes_t;
143
144enum {
145 SNDRV_PCM_CLASS_GENERIC = 0, /* standard mono or stereo device */
146 SNDRV_PCM_CLASS_MULTI, /* multichannel device */
147 SNDRV_PCM_CLASS_MODEM, /* software modem class */
148 SNDRV_PCM_CLASS_DIGITIZER, /* digitizer class */
149 /* Don't forget to change the following: */
150 SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER,
151};
152
153enum {
154 SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, /* mono or stereo subdevices are mixed together */
155 SNDRV_PCM_SUBCLASS_MULTI_MIX, /* multichannel subdevices are mixed together */
156 /* Don't forget to change the following: */
157 SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX,
158};
159
160enum {
161 SNDRV_PCM_STREAM_PLAYBACK = 0,
162 SNDRV_PCM_STREAM_CAPTURE,
163 SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE,
164};
165
166typedef int __bitwise snd_pcm_access_t;
167#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0) /* interleaved mmap */
168#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1) /* noninterleaved mmap */
169#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2) /* complex mmap */
170#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3) /* readi/writei */
171#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4) /* readn/writen */
172#define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_RW_NONINTERLEAVED
173
174typedef int __bitwise snd_pcm_format_t;
175#define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0)
176#define SNDRV_PCM_FORMAT_U8 ((__force snd_pcm_format_t) 1)
177#define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2)
178#define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3)
179#define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4)
180#define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5)
181#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) /* low three bytes */
182#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */
183#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */
184#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */
185#define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10)
186#define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11)
187#define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12)
188#define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13)
189#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
190#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
191#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
192#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
193#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) /* IEC-958 subframe, Little Endian */
194#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) /* IEC-958 subframe, Big Endian */
195#define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20)
196#define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21)
197#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22)
198#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23)
199#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24)
200#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31)
201#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) /* in three bytes */
202#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) /* in three bytes */
203#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34) /* in three bytes */
204#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35) /* in three bytes */
205#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36) /* in three bytes */
206#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37) /* in three bytes */
207#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38) /* in three bytes */
208#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39) /* in three bytes */
209#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40) /* in three bytes */
210#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41) /* in three bytes */
211#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42) /* in three bytes */
212#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43) /* in three bytes */
213#define SNDRV_PCM_FORMAT_G723_24 ((__force snd_pcm_format_t) 44) /* 8 samples in 3 bytes */
214#define SNDRV_PCM_FORMAT_G723_24_1B ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */
215#define SNDRV_PCM_FORMAT_G723_40 ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */
216#define SNDRV_PCM_FORMAT_G723_40_1B ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */
217#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_G723_40_1B
218
219#ifdef SNDRV_LITTLE_ENDIAN
220#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE
221#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_LE
222#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_LE
223#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_LE
224#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_LE
225#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_LE
226#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE
227#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE
228#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
229#endif
230#ifdef SNDRV_BIG_ENDIAN
231#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE
232#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_BE
233#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_BE
234#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_BE
235#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_BE
236#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_BE
237#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE
238#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE
239#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
240#endif
241
242typedef int __bitwise snd_pcm_subformat_t;
243#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0)
244#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD
245
246#define SNDRV_PCM_INFO_MMAP 0x00000001 /* hardware supports mmap */
247#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 /* period data are valid during transfer */
248#define SNDRV_PCM_INFO_DOUBLE 0x00000004 /* Double buffering needed for PCM start/stop */
249#define SNDRV_PCM_INFO_BATCH 0x00000010 /* double buffering */
250#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100 /* channels are interleaved */
251#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200 /* channels are not interleaved */
252#define SNDRV_PCM_INFO_COMPLEX 0x00000400 /* complex frame organization (mmap only) */
253#define SNDRV_PCM_INFO_BLOCK_TRANSFER 0x00010000 /* hardware transfer block of samples */
254#define SNDRV_PCM_INFO_OVERRANGE 0x00020000 /* hardware supports ADC (capture) overrange detection */
255#define SNDRV_PCM_INFO_RESUME 0x00040000 /* hardware supports stream resume after suspend */
256#define SNDRV_PCM_INFO_PAUSE 0x00080000 /* pause ioctl is supported */
257#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000 /* only half duplex */
258#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */
259#define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */
260#define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */
261#define SNDRV_PCM_INFO_HAS_WALL_CLOCK 0x01000000 /* has audio wall clock for audio/system time sync */
262#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
263
264typedef int __bitwise snd_pcm_state_t;
265#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */
266#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) /* stream has a setup */
267#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2) /* stream is ready to start */
268#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3) /* stream is running */
269#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4) /* stream reached an xrun */
270#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5) /* stream is draining */
271#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6) /* stream is paused */
272#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7) /* hardware is suspended */
273#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8) /* hardware is disconnected */
274#define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED
275
276enum {
277 SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
278 SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
279 SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
280};
281
282union snd_pcm_sync_id {
283 unsigned char id[16];
284 unsigned short id16[8];
285 unsigned int id32[4];
286};
287
288struct snd_pcm_info {
289 unsigned int device; /* RO/WR (control): device number */
290 unsigned int subdevice; /* RO/WR (control): subdevice number */
291 int stream; /* RO/WR (control): stream direction */
292 int card; /* R: card number */
293 unsigned char id[64]; /* ID (user selectable) */
294 unsigned char name[80]; /* name of this device */
295 unsigned char subname[32]; /* subdevice name */
296 int dev_class; /* SNDRV_PCM_CLASS_* */
297 int dev_subclass; /* SNDRV_PCM_SUBCLASS_* */
298 unsigned int subdevices_count;
299 unsigned int subdevices_avail;
300 union snd_pcm_sync_id sync; /* hardware synchronization ID */
301 unsigned char reserved[64]; /* reserved for future... */
302};
303
304typedef int snd_pcm_hw_param_t;
305#define SNDRV_PCM_HW_PARAM_ACCESS 0 /* Access type */
306#define SNDRV_PCM_HW_PARAM_FORMAT 1 /* Format */
307#define SNDRV_PCM_HW_PARAM_SUBFORMAT 2 /* Subformat */
308#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS
309#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT
310
311#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS 8 /* Bits per sample */
312#define SNDRV_PCM_HW_PARAM_FRAME_BITS 9 /* Bits per frame */
313#define SNDRV_PCM_HW_PARAM_CHANNELS 10 /* Channels */
314#define SNDRV_PCM_HW_PARAM_RATE 11 /* Approx rate */
315#define SNDRV_PCM_HW_PARAM_PERIOD_TIME 12 /* Approx distance between
316 * interrupts in us
317 */
318#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE 13 /* Approx frames between
319 * interrupts
320 */
321#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14 /* Approx bytes between
322 * interrupts
323 */
324#define SNDRV_PCM_HW_PARAM_PERIODS 15 /* Approx interrupts per
325 * buffer
326 */
327#define SNDRV_PCM_HW_PARAM_BUFFER_TIME 16 /* Approx duration of buffer
328 * in us
329 */
330#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE 17 /* Size of buffer in frames */
331#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18 /* Size of buffer in bytes */
332#define SNDRV_PCM_HW_PARAM_TICK_TIME 19 /* Approx tick duration in us */
333#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS
334#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME
335
336#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
337#define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER (1<<1) /* export buffer */
338#define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) /* disable period wakeups */
339
340struct snd_interval {
341 unsigned int min, max;
342 unsigned int openmin:1,
343 openmax:1,
344 integer:1,
345 empty:1;
346};
347
348#define SNDRV_MASK_MAX 256
349
350struct snd_mask {
351 __u32 bits[(SNDRV_MASK_MAX+31)/32];
352};
353
354struct snd_pcm_hw_params {
355 unsigned int flags;
356 struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
357 SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
358 struct snd_mask mres[5]; /* reserved masks */
359 struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
360 SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
361 struct snd_interval ires[9]; /* reserved intervals */
362 unsigned int rmask; /* W: requested masks */
363 unsigned int cmask; /* R: changed masks */
364 unsigned int info; /* R: Info flags for returned setup */
365 unsigned int msbits; /* R: used most significant bits */
366 unsigned int rate_num; /* R: rate numerator */
367 unsigned int rate_den; /* R: rate denominator */
368 snd_pcm_uframes_t fifo_size; /* R: chip FIFO size in frames */
369 unsigned char reserved[64]; /* reserved for future */
370};
371
372enum {
373 SNDRV_PCM_TSTAMP_NONE = 0,
374 SNDRV_PCM_TSTAMP_ENABLE,
375 SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE,
376};
377
378struct snd_pcm_sw_params {
379 int tstamp_mode; /* timestamp mode */
380 unsigned int period_step;
381 unsigned int sleep_min; /* min ticks to sleep */
382 snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */
383 snd_pcm_uframes_t xfer_align; /* obsolete: xfer size need to be a multiple */
384 snd_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */
385 snd_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */
386 snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */
387 snd_pcm_uframes_t silence_size; /* silence block size */
388 snd_pcm_uframes_t boundary; /* pointers wrap point */
389 unsigned char reserved[64]; /* reserved for future */
390};
391
392struct snd_pcm_channel_info {
393 unsigned int channel;
394 __kernel_off_t offset; /* mmap offset */
395 unsigned int first; /* offset to first sample in bits */
396 unsigned int step; /* samples distance in bits */
397};
398
399struct snd_pcm_status {
400 snd_pcm_state_t state; /* stream state */
401 struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */
402 struct timespec tstamp; /* reference timestamp */
403 snd_pcm_uframes_t appl_ptr; /* appl ptr */
404 snd_pcm_uframes_t hw_ptr; /* hw ptr */
405 snd_pcm_sframes_t delay; /* current delay in frames */
406 snd_pcm_uframes_t avail; /* number of frames available */
407 snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */
408 snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */
409 snd_pcm_state_t suspended_state; /* suspended stream state */
410 __u32 reserved_alignment; /* must be filled with zero */
411 struct timespec audio_tstamp; /* from sample counter or wall clock */
412 unsigned char reserved[56-sizeof(struct timespec)]; /* must be filled with zero */
413};
414
415struct snd_pcm_mmap_status {
416 snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */
417 int pad1; /* Needed for 64 bit alignment */
418 snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
419 struct timespec tstamp; /* Timestamp */
420 snd_pcm_state_t suspended_state; /* RO: suspended stream state */
421 struct timespec audio_tstamp; /* from sample counter or wall clock */
422};
423
424struct snd_pcm_mmap_control {
425 snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
426 snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
427};
428
429#define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0) /* execute hwsync */
430#define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */
431#define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */
432
433struct snd_pcm_sync_ptr {
434 unsigned int flags;
435 union {
436 struct snd_pcm_mmap_status status;
437 unsigned char reserved[64];
438 } s;
439 union {
440 struct snd_pcm_mmap_control control;
441 unsigned char reserved[64];
442 } c;
443};
444
445struct snd_xferi {
446 snd_pcm_sframes_t result;
447 void __user *buf;
448 snd_pcm_uframes_t frames;
449};
450
451struct snd_xfern {
452 snd_pcm_sframes_t result;
453 void __user * __user *bufs;
454 snd_pcm_uframes_t frames;
455};
456
457enum {
458 SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /* gettimeofday equivalent */
459 SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, /* posix_clock_monotonic equivalent */
460 SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,
461};
462
463/* channel positions */
464enum {
465 SNDRV_CHMAP_UNKNOWN = 0,
466 SNDRV_CHMAP_NA, /* N/A, silent */
467 SNDRV_CHMAP_MONO, /* mono stream */
468 /* this follows the alsa-lib mixer channel value + 3 */
469 SNDRV_CHMAP_FL, /* front left */
470 SNDRV_CHMAP_FR, /* front right */
471 SNDRV_CHMAP_RL, /* rear left */
472 SNDRV_CHMAP_RR, /* rear right */
473 SNDRV_CHMAP_FC, /* front center */
474 SNDRV_CHMAP_LFE, /* LFE */
475 SNDRV_CHMAP_SL, /* side left */
476 SNDRV_CHMAP_SR, /* side right */
477 SNDRV_CHMAP_RC, /* rear center */
478 /* new definitions */
479 SNDRV_CHMAP_FLC, /* front left center */
480 SNDRV_CHMAP_FRC, /* front right center */
481 SNDRV_CHMAP_RLC, /* rear left center */
482 SNDRV_CHMAP_RRC, /* rear right center */
483 SNDRV_CHMAP_FLW, /* front left wide */
484 SNDRV_CHMAP_FRW, /* front right wide */
485 SNDRV_CHMAP_FLH, /* front left high */
486 SNDRV_CHMAP_FCH, /* front center high */
487 SNDRV_CHMAP_FRH, /* front right high */
488 SNDRV_CHMAP_TC, /* top center */
489 SNDRV_CHMAP_TFL, /* top front left */
490 SNDRV_CHMAP_TFR, /* top front right */
491 SNDRV_CHMAP_TFC, /* top front center */
492 SNDRV_CHMAP_TRL, /* top rear left */
493 SNDRV_CHMAP_TRR, /* top rear right */
494 SNDRV_CHMAP_TRC, /* top rear center */
495 SNDRV_CHMAP_LAST = SNDRV_CHMAP_TRC,
496};
497
498#define SNDRV_CHMAP_POSITION_MASK 0xffff
499#define SNDRV_CHMAP_PHASE_INVERSE (0x01 << 16)
500#define SNDRV_CHMAP_DRIVER_SPEC (0x02 << 16)
501
502#define SNDRV_PCM_IOCTL_PVERSION _IOR('A', 0x00, int)
503#define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info)
504#define SNDRV_PCM_IOCTL_TSTAMP _IOW('A', 0x02, int)
505#define SNDRV_PCM_IOCTL_TTSTAMP _IOW('A', 0x03, int)
506#define SNDRV_PCM_IOCTL_HW_REFINE _IOWR('A', 0x10, struct snd_pcm_hw_params)
507#define SNDRV_PCM_IOCTL_HW_PARAMS _IOWR('A', 0x11, struct snd_pcm_hw_params)
508#define SNDRV_PCM_IOCTL_HW_FREE _IO('A', 0x12)
509#define SNDRV_PCM_IOCTL_SW_PARAMS _IOWR('A', 0x13, struct snd_pcm_sw_params)
510#define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status)
511#define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t)
512#define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22)
513#define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr)
514#define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info)
515#define SNDRV_PCM_IOCTL_PREPARE _IO('A', 0x40)
516#define SNDRV_PCM_IOCTL_RESET _IO('A', 0x41)
517#define SNDRV_PCM_IOCTL_START _IO('A', 0x42)
518#define SNDRV_PCM_IOCTL_DROP _IO('A', 0x43)
519#define SNDRV_PCM_IOCTL_DRAIN _IO('A', 0x44)
520#define SNDRV_PCM_IOCTL_PAUSE _IOW('A', 0x45, int)
521#define SNDRV_PCM_IOCTL_REWIND _IOW('A', 0x46, snd_pcm_uframes_t)
522#define SNDRV_PCM_IOCTL_RESUME _IO('A', 0x47)
523#define SNDRV_PCM_IOCTL_XRUN _IO('A', 0x48)
524#define SNDRV_PCM_IOCTL_FORWARD _IOW('A', 0x49, snd_pcm_uframes_t)
525#define SNDRV_PCM_IOCTL_WRITEI_FRAMES _IOW('A', 0x50, struct snd_xferi)
526#define SNDRV_PCM_IOCTL_READI_FRAMES _IOR('A', 0x51, struct snd_xferi)
527#define SNDRV_PCM_IOCTL_WRITEN_FRAMES _IOW('A', 0x52, struct snd_xfern)
528#define SNDRV_PCM_IOCTL_READN_FRAMES _IOR('A', 0x53, struct snd_xfern)
529#define SNDRV_PCM_IOCTL_LINK _IOW('A', 0x60, int)
530#define SNDRV_PCM_IOCTL_UNLINK _IO('A', 0x61)
531
532/*****************************************************************************
533 * *
534 * MIDI v1.0 interface *
535 * *
536 *****************************************************************************/
537
538/*
539 * Raw MIDI section - /dev/snd/midi??
540 */
541
542#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0)
543
544enum {
545 SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
546 SNDRV_RAWMIDI_STREAM_INPUT,
547 SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT,
548};
549
550#define SNDRV_RAWMIDI_INFO_OUTPUT 0x00000001
551#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002
552#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004
553
554struct snd_rawmidi_info {
555 unsigned int device; /* RO/WR (control): device number */
556 unsigned int subdevice; /* RO/WR (control): subdevice number */
557 int stream; /* WR: stream */
558 int card; /* R: card number */
559 unsigned int flags; /* SNDRV_RAWMIDI_INFO_XXXX */
560 unsigned char id[64]; /* ID (user selectable) */
561 unsigned char name[80]; /* name of device */
562 unsigned char subname[32]; /* name of active or selected subdevice */
563 unsigned int subdevices_count;
564 unsigned int subdevices_avail;
565 unsigned char reserved[64]; /* reserved for future use */
566};
567
568struct snd_rawmidi_params {
569 int stream;
570 size_t buffer_size; /* queue size in bytes */
571 size_t avail_min; /* minimum avail bytes for wakeup */
572 unsigned int no_active_sensing: 1; /* do not send active sensing byte in close() */
573 unsigned char reserved[16]; /* reserved for future use */
574};
575
576struct snd_rawmidi_status {
577 int stream;
578 struct timespec tstamp; /* Timestamp */
579 size_t avail; /* available bytes */
580 size_t xruns; /* count of overruns since last status (in bytes) */
581 unsigned char reserved[16]; /* reserved for future use */
582};
583
584#define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
585#define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
586#define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params)
587#define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status)
588#define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)
589#define SNDRV_RAWMIDI_IOCTL_DRAIN _IOW('W', 0x31, int)
590
591/*
592 * Timer section - /dev/snd/timer
593 */
594
595#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6)
596
597enum {
598 SNDRV_TIMER_CLASS_NONE = -1,
599 SNDRV_TIMER_CLASS_SLAVE = 0,
600 SNDRV_TIMER_CLASS_GLOBAL,
601 SNDRV_TIMER_CLASS_CARD,
602 SNDRV_TIMER_CLASS_PCM,
603 SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM,
604};
605
606/* slave timer classes */
607enum {
608 SNDRV_TIMER_SCLASS_NONE = 0,
609 SNDRV_TIMER_SCLASS_APPLICATION,
610 SNDRV_TIMER_SCLASS_SEQUENCER, /* alias */
611 SNDRV_TIMER_SCLASS_OSS_SEQUENCER, /* alias */
612 SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER,
613};
614
615/* global timers (device member) */
616#define SNDRV_TIMER_GLOBAL_SYSTEM 0
617#define SNDRV_TIMER_GLOBAL_RTC 1
618#define SNDRV_TIMER_GLOBAL_HPET 2
619#define SNDRV_TIMER_GLOBAL_HRTIMER 3
620
621/* info flags */
622#define SNDRV_TIMER_FLG_SLAVE (1<<0) /* cannot be controlled */
623
624struct snd_timer_id {
625 int dev_class;
626 int dev_sclass;
627 int card;
628 int device;
629 int subdevice;
630};
631
632struct snd_timer_ginfo {
633 struct snd_timer_id tid; /* requested timer ID */
634 unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
635 int card; /* card number */
636 unsigned char id[64]; /* timer identification */
637 unsigned char name[80]; /* timer name */
638 unsigned long reserved0; /* reserved for future use */
639 unsigned long resolution; /* average period resolution in ns */
640 unsigned long resolution_min; /* minimal period resolution in ns */
641 unsigned long resolution_max; /* maximal period resolution in ns */
642 unsigned int clients; /* active timer clients */
643 unsigned char reserved[32];
644};
645
646struct snd_timer_gparams {
647 struct snd_timer_id tid; /* requested timer ID */
648 unsigned long period_num; /* requested precise period duration (in seconds) - numerator */
649 unsigned long period_den; /* requested precise period duration (in seconds) - denominator */
650 unsigned char reserved[32];
651};
652
653struct snd_timer_gstatus {
654 struct snd_timer_id tid; /* requested timer ID */
655 unsigned long resolution; /* current period resolution in ns */
656 unsigned long resolution_num; /* precise current period resolution (in seconds) - numerator */
657 unsigned long resolution_den; /* precise current period resolution (in seconds) - denominator */
658 unsigned char reserved[32];
659};
660
661struct snd_timer_select {
662 struct snd_timer_id id; /* bind to timer ID */
663 unsigned char reserved[32]; /* reserved */
664};
665
666struct snd_timer_info {
667 unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
668 int card; /* card number */
669 unsigned char id[64]; /* timer identificator */
670 unsigned char name[80]; /* timer name */
671 unsigned long reserved0; /* reserved for future use */
672 unsigned long resolution; /* average period resolution in ns */
673 unsigned char reserved[64]; /* reserved */
674};
675
676#define SNDRV_TIMER_PSFLG_AUTO (1<<0) /* auto start, otherwise one-shot */
677#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) /* exclusive use, precise start/stop/pause/continue */
678#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2) /* write early event to the poll queue */
679
680struct snd_timer_params {
681 unsigned int flags; /* flags - SNDRV_MIXER_PSFLG_* */
682 unsigned int ticks; /* requested resolution in ticks */
683 unsigned int queue_size; /* total size of queue (32-1024) */
684 unsigned int reserved0; /* reserved, was: failure locations */
685 unsigned int filter; /* event filter (bitmask of SNDRV_TIMER_EVENT_*) */
686 unsigned char reserved[60]; /* reserved */
687};
688
689struct snd_timer_status {
690 struct timespec tstamp; /* Timestamp - last update */
691 unsigned int resolution; /* current period resolution in ns */
692 unsigned int lost; /* counter of master tick lost */
693 unsigned int overrun; /* count of read queue overruns */
694 unsigned int queue; /* used queue size */
695 unsigned char reserved[64]; /* reserved */
696};
697
698#define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int)
699#define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id)
700#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int)
701#define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo)
702#define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams)
703#define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus)
704#define SNDRV_TIMER_IOCTL_SELECT _IOW('T', 0x10, struct snd_timer_select)
705#define SNDRV_TIMER_IOCTL_INFO _IOR('T', 0x11, struct snd_timer_info)
706#define SNDRV_TIMER_IOCTL_PARAMS _IOW('T', 0x12, struct snd_timer_params)
707#define SNDRV_TIMER_IOCTL_STATUS _IOR('T', 0x14, struct snd_timer_status)
708/* The following four ioctls are changed since 1.0.9 due to confliction */
709#define SNDRV_TIMER_IOCTL_START _IO('T', 0xa0)
710#define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1)
711#define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2)
712#define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3)
713
714struct snd_timer_read {
715 unsigned int resolution;
716 unsigned int ticks;
717};
718
719enum {
720 SNDRV_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */
721 SNDRV_TIMER_EVENT_TICK, /* val = ticks */
722 SNDRV_TIMER_EVENT_START, /* val = resolution in ns */
723 SNDRV_TIMER_EVENT_STOP, /* val = 0 */
724 SNDRV_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
725 SNDRV_TIMER_EVENT_PAUSE, /* val = 0 */
726 SNDRV_TIMER_EVENT_EARLY, /* val = 0, early event */
727 SNDRV_TIMER_EVENT_SUSPEND, /* val = 0 */
728 SNDRV_TIMER_EVENT_RESUME, /* val = resolution in ns */
729 /* master timer events for slave timer instances */
730 SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
731 SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10,
732 SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10,
733 SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10,
734 SNDRV_TIMER_EVENT_MSUSPEND = SNDRV_TIMER_EVENT_SUSPEND + 10,
735 SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
736};
737
738struct snd_timer_tread {
739 int event;
740 struct timespec tstamp;
741 unsigned int val;
742};
743
744/****************************************************************************
745 * *
746 * Section for driver control interface - /dev/snd/control? *
747 * *
748 ****************************************************************************/
749
750#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7)
751
752struct snd_ctl_card_info {
753 int card; /* card number */
754 int pad; /* reserved for future (was type) */
755 unsigned char id[16]; /* ID of card (user selectable) */
756 unsigned char driver[16]; /* Driver name */
757 unsigned char name[32]; /* Short name of soundcard */
758 unsigned char longname[80]; /* name + info text about soundcard */
759 unsigned char reserved_[16]; /* reserved for future (was ID of mixer) */
760 unsigned char mixername[80]; /* visual mixer identification */
761 unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */
762};
763
764typedef int __bitwise snd_ctl_elem_type_t;
765#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0) /* invalid */
766#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1) /* boolean type */
767#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2) /* integer type */
768#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3) /* enumerated type */
769#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4) /* byte array */
770#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5) /* IEC958 (S/PDIF) setup */
771#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6) /* 64-bit integer type */
772#define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64
773
774typedef int __bitwise snd_ctl_elem_iface_t;
775#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0) /* global control */
776#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1) /* hardware dependent device */
777#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2) /* virtual mixer device */
778#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3) /* PCM device */
779#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4) /* RawMidi device */
780#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5) /* timer device */
781#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6) /* sequencer client */
782#define SNDRV_CTL_ELEM_IFACE_LAST SNDRV_CTL_ELEM_IFACE_SEQUENCER
783
784#define SNDRV_CTL_ELEM_ACCESS_READ (1<<0)
785#define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1)
786#define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE)
787#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) /* control value may be changed without a notification */
788#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3) /* when was control changed */
789#define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) /* TLV read is possible */
790#define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) /* TLV write is possible */
791#define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE)
792#define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6) /* TLV command is possible */
793#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) /* control does actually nothing, but may be updated */
794#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) /* write lock */
795#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */
796#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */
797#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */
798/* bits 30 and 31 are obsoleted (for indirect access) */
799
800/* for further details see the ACPI and PCI power management specification */
801#define SNDRV_CTL_POWER_D0 0x0000 /* full On */
802#define SNDRV_CTL_POWER_D1 0x0100 /* partial On */
803#define SNDRV_CTL_POWER_D2 0x0200 /* partial On */
804#define SNDRV_CTL_POWER_D3 0x0300 /* Off */
805#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000) /* Off, with power */
806#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001) /* Off, without power */
807
808struct snd_ctl_elem_id {
809 unsigned int numid; /* numeric identifier, zero = invalid */
810 snd_ctl_elem_iface_t iface; /* interface identifier */
811 unsigned int device; /* device/client number */
812 unsigned int subdevice; /* subdevice (substream) number */
813 unsigned char name[44]; /* ASCII name of item */
814 unsigned int index; /* index of item */
815};
816
817struct snd_ctl_elem_list {
818 unsigned int offset; /* W: first element ID to get */
819 unsigned int space; /* W: count of element IDs to get */
820 unsigned int used; /* R: count of element IDs set */
821 unsigned int count; /* R: count of all elements */
822 struct snd_ctl_elem_id __user *pids; /* R: IDs */
823 unsigned char reserved[50];
824};
825
826struct snd_ctl_elem_info {
827 struct snd_ctl_elem_id id; /* W: element ID */
828 snd_ctl_elem_type_t type; /* R: value type - SNDRV_CTL_ELEM_TYPE_* */
829 unsigned int access; /* R: value access (bitmask) - SNDRV_CTL_ELEM_ACCESS_* */
830 unsigned int count; /* count of values */
831 __kernel_pid_t owner; /* owner's PID of this control */
832 union {
833 struct {
834 long min; /* R: minimum value */
835 long max; /* R: maximum value */
836 long step; /* R: step (0 variable) */
837 } integer;
838 struct {
839 long long min; /* R: minimum value */
840 long long max; /* R: maximum value */
841 long long step; /* R: step (0 variable) */
842 } integer64;
843 struct {
844 unsigned int items; /* R: number of items */
845 unsigned int item; /* W: item number */
846 char name[64]; /* R: value name */
847 __u64 names_ptr; /* W: names list (ELEM_ADD only) */
848 unsigned int names_length;
849 } enumerated;
850 unsigned char reserved[128];
851 } value;
852 union {
853 unsigned short d[4]; /* dimensions */
854 unsigned short *d_ptr; /* indirect - obsoleted */
855 } dimen;
856 unsigned char reserved[64-4*sizeof(unsigned short)];
857};
858
859struct snd_ctl_elem_value {
860 struct snd_ctl_elem_id id; /* W: element ID */
861 unsigned int indirect: 1; /* W: indirect access - obsoleted */
862 union {
863 union {
864 long value[128];
865 long *value_ptr; /* obsoleted */
866 } integer;
867 union {
868 long long value[64];
869 long long *value_ptr; /* obsoleted */
870 } integer64;
871 union {
872 unsigned int item[128];
873 unsigned int *item_ptr; /* obsoleted */
874 } enumerated;
875 union {
876 unsigned char data[512];
877 unsigned char *data_ptr; /* obsoleted */
878 } bytes;
879 struct snd_aes_iec958 iec958;
880 } value; /* RO */
881 struct timespec tstamp;
882 unsigned char reserved[128-sizeof(struct timespec)];
883};
884
885struct snd_ctl_tlv {
886 unsigned int numid; /* control element numeric identification */
887 unsigned int length; /* in bytes aligned to 4 */
888 unsigned int tlv[0]; /* first TLV */
889};
890
891#define SNDRV_CTL_IOCTL_PVERSION _IOR('U', 0x00, int)
892#define SNDRV_CTL_IOCTL_CARD_INFO _IOR('U', 0x01, struct snd_ctl_card_info)
893#define SNDRV_CTL_IOCTL_ELEM_LIST _IOWR('U', 0x10, struct snd_ctl_elem_list)
894#define SNDRV_CTL_IOCTL_ELEM_INFO _IOWR('U', 0x11, struct snd_ctl_elem_info)
895#define SNDRV_CTL_IOCTL_ELEM_READ _IOWR('U', 0x12, struct snd_ctl_elem_value)
896#define SNDRV_CTL_IOCTL_ELEM_WRITE _IOWR('U', 0x13, struct snd_ctl_elem_value)
897#define SNDRV_CTL_IOCTL_ELEM_LOCK _IOW('U', 0x14, struct snd_ctl_elem_id)
898#define SNDRV_CTL_IOCTL_ELEM_UNLOCK _IOW('U', 0x15, struct snd_ctl_elem_id)
899#define SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS _IOWR('U', 0x16, int)
900#define SNDRV_CTL_IOCTL_ELEM_ADD _IOWR('U', 0x17, struct snd_ctl_elem_info)
901#define SNDRV_CTL_IOCTL_ELEM_REPLACE _IOWR('U', 0x18, struct snd_ctl_elem_info)
902#define SNDRV_CTL_IOCTL_ELEM_REMOVE _IOWR('U', 0x19, struct snd_ctl_elem_id)
903#define SNDRV_CTL_IOCTL_TLV_READ _IOWR('U', 0x1a, struct snd_ctl_tlv)
904#define SNDRV_CTL_IOCTL_TLV_WRITE _IOWR('U', 0x1b, struct snd_ctl_tlv)
905#define SNDRV_CTL_IOCTL_TLV_COMMAND _IOWR('U', 0x1c, struct snd_ctl_tlv)
906#define SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE _IOWR('U', 0x20, int)
907#define SNDRV_CTL_IOCTL_HWDEP_INFO _IOR('U', 0x21, struct snd_hwdep_info)
908#define SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE _IOR('U', 0x30, int)
909#define SNDRV_CTL_IOCTL_PCM_INFO _IOWR('U', 0x31, struct snd_pcm_info)
910#define SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE _IOW('U', 0x32, int)
911#define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int)
912#define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info)
913#define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int)
914#define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int)
915#define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int)
916
917/*
918 * Read interface.
919 */
920
921enum sndrv_ctl_event_type {
922 SNDRV_CTL_EVENT_ELEM = 0,
923 SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM,
924};
925
926#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0) /* element value was changed */
927#define SNDRV_CTL_EVENT_MASK_INFO (1<<1) /* element info was changed */
928#define SNDRV_CTL_EVENT_MASK_ADD (1<<2) /* element was added */
929#define SNDRV_CTL_EVENT_MASK_TLV (1<<3) /* element TLV tree was changed */
930#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) /* element was removed */
931
932struct snd_ctl_event {
933 int type; /* event type - SNDRV_CTL_EVENT_* */
934 union {
935 struct {
936 unsigned int mask;
937 struct snd_ctl_elem_id id;
938 } elem;
939 unsigned char data8[60];
940 } data;
941};
942
943/*
944 * Control names
945 */
946
947#define SNDRV_CTL_NAME_NONE ""
948#define SNDRV_CTL_NAME_PLAYBACK "Playback "
949#define SNDRV_CTL_NAME_CAPTURE "Capture "
950
951#define SNDRV_CTL_NAME_IEC958_NONE ""
952#define SNDRV_CTL_NAME_IEC958_SWITCH "Switch"
953#define SNDRV_CTL_NAME_IEC958_VOLUME "Volume"
954#define SNDRV_CTL_NAME_IEC958_DEFAULT "Default"
955#define SNDRV_CTL_NAME_IEC958_MASK "Mask"
956#define SNDRV_CTL_NAME_IEC958_CON_MASK "Con Mask"
957#define SNDRV_CTL_NAME_IEC958_PRO_MASK "Pro Mask"
958#define SNDRV_CTL_NAME_IEC958_PCM_STREAM "PCM Stream"
959#define SNDRV_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what
960
961#endif /* _UAPI__SOUND_ASOUND_H */
diff --git a/include/sound/asound_fm.h b/include/uapi/sound/asound_fm.h
index c2a4b967d5be..c2a4b967d5be 100644
--- a/include/sound/asound_fm.h
+++ b/include/uapi/sound/asound_fm.h
diff --git a/include/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
index 05341a43fedf..05341a43fedf 100644
--- a/include/sound/compress_offload.h
+++ b/include/uapi/sound/compress_offload.h
diff --git a/include/sound/compress_params.h b/include/uapi/sound/compress_params.h
index 602dc6c45d1a..602dc6c45d1a 100644
--- a/include/sound/compress_params.h
+++ b/include/uapi/sound/compress_params.h
diff --git a/include/uapi/sound/emu10k1.h b/include/uapi/sound/emu10k1.h
new file mode 100644
index 000000000000..d1bbaf78457a
--- /dev/null
+++ b/include/uapi/sound/emu10k1.h
@@ -0,0 +1,373 @@
1/*
2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
3 * Creative Labs, Inc.
4 * Definitions for EMU10K1 (SB Live!) chips
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22#ifndef _UAPI__SOUND_EMU10K1_H
23#define _UAPI__SOUND_EMU10K1_H
24
25#include <linux/types.h>
26
27
28
29/*
30 * ---- FX8010 ----
31 */
32
33#define EMU10K1_CARD_CREATIVE 0x00000000
34#define EMU10K1_CARD_EMUAPS 0x00000001
35
36#define EMU10K1_FX8010_PCM_COUNT 8
37
38/* instruction set */
39#define iMAC0 0x00 /* R = A + (X * Y >> 31) ; saturation */
40#define iMAC1 0x01 /* R = A + (-X * Y >> 31) ; saturation */
41#define iMAC2 0x02 /* R = A + (X * Y >> 31) ; wraparound */
42#define iMAC3 0x03 /* R = A + (-X * Y >> 31) ; wraparound */
43#define iMACINT0 0x04 /* R = A + X * Y ; saturation */
44#define iMACINT1 0x05 /* R = A + X * Y ; wraparound (31-bit) */
45#define iACC3 0x06 /* R = A + X + Y ; saturation */
46#define iMACMV 0x07 /* R = A, acc += X * Y >> 31 */
47#define iANDXOR 0x08 /* R = (A & X) ^ Y */
48#define iTSTNEG 0x09 /* R = (A >= Y) ? X : ~X */
49#define iLIMITGE 0x0a /* R = (A >= Y) ? X : Y */
50#define iLIMITLT 0x0b /* R = (A < Y) ? X : Y */
51#define iLOG 0x0c /* R = linear_data, A (log_data), X (max_exp), Y (format_word) */
52#define iEXP 0x0d /* R = log_data, A (linear_data), X (max_exp), Y (format_word) */
53#define iINTERP 0x0e /* R = A + (X * (Y - A) >> 31) ; saturation */
54#define iSKIP 0x0f /* R = A (cc_reg), X (count), Y (cc_test) */
55
56/* GPRs */
57#define FXBUS(x) (0x00 + (x)) /* x = 0x00 - 0x0f */
58#define EXTIN(x) (0x10 + (x)) /* x = 0x00 - 0x0f */
59#define EXTOUT(x) (0x20 + (x)) /* x = 0x00 - 0x0f physical outs -> FXWC low 16 bits */
60#define FXBUS2(x) (0x30 + (x)) /* x = 0x00 - 0x0f copies of fx buses for capture -> FXWC high 16 bits */
61 /* NB: 0x31 and 0x32 are shared with Center/LFE on SB live 5.1 */
62
63#define C_00000000 0x40
64#define C_00000001 0x41
65#define C_00000002 0x42
66#define C_00000003 0x43
67#define C_00000004 0x44
68#define C_00000008 0x45
69#define C_00000010 0x46
70#define C_00000020 0x47
71#define C_00000100 0x48
72#define C_00010000 0x49
73#define C_00080000 0x4a
74#define C_10000000 0x4b
75#define C_20000000 0x4c
76#define C_40000000 0x4d
77#define C_80000000 0x4e
78#define C_7fffffff 0x4f
79#define C_ffffffff 0x50
80#define C_fffffffe 0x51
81#define C_c0000000 0x52
82#define C_4f1bbcdc 0x53
83#define C_5a7ef9db 0x54
84#define C_00100000 0x55 /* ?? */
85#define GPR_ACCU 0x56 /* ACCUM, accumulator */
86#define GPR_COND 0x57 /* CCR, condition register */
87#define GPR_NOISE0 0x58 /* noise source */
88#define GPR_NOISE1 0x59 /* noise source */
89#define GPR_IRQ 0x5a /* IRQ register */
90#define GPR_DBAC 0x5b /* TRAM Delay Base Address Counter */
91#define GPR(x) (FXGPREGBASE + (x)) /* free GPRs: x = 0x00 - 0xff */
92#define ITRAM_DATA(x) (TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
93#define ETRAM_DATA(x) (TANKMEMDATAREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
94#define ITRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
95#define ETRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
96
97#define A_ITRAM_DATA(x) (TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
98#define A_ETRAM_DATA(x) (TANKMEMDATAREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
99#define A_ITRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
100#define A_ETRAM_ADDR(x) (TANKMEMADDRREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
101#define A_ITRAM_CTL(x) (A_TANKMEMCTLREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
102#define A_ETRAM_CTL(x) (A_TANKMEMCTLREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
103
104#define A_FXBUS(x) (0x00 + (x)) /* x = 0x00 - 0x3f FX buses */
105#define A_EXTIN(x) (0x40 + (x)) /* x = 0x00 - 0x0f physical ins */
106#define A_P16VIN(x) (0x50 + (x)) /* x = 0x00 - 0x0f p16v ins (A2 only) "EMU32 inputs" */
107#define A_EXTOUT(x) (0x60 + (x)) /* x = 0x00 - 0x1f physical outs -> A_FXWC1 0x79-7f unknown */
108#define A_FXBUS2(x) (0x80 + (x)) /* x = 0x00 - 0x1f extra outs used for EFX capture -> A_FXWC2 */
109#define A_EMU32OUTH(x) (0xa0 + (x)) /* x = 0x00 - 0x0f "EMU32_OUT_10 - _1F" - ??? */
110#define A_EMU32OUTL(x) (0xb0 + (x)) /* x = 0x00 - 0x0f "EMU32_OUT_1 - _F" - ??? */
111#define A3_EMU32IN(x) (0x160 + (x)) /* x = 0x00 - 0x3f "EMU32_IN_00 - _3F" - Only when .device = 0x0008 */
112#define A3_EMU32OUT(x) (0x1E0 + (x)) /* x = 0x00 - 0x0f "EMU32_OUT_00 - _3F" - Only when .device = 0x0008 */
113#define A_GPR(x) (A_FXGPREGBASE + (x))
114
115/* cc_reg constants */
116#define CC_REG_NORMALIZED C_00000001
117#define CC_REG_BORROW C_00000002
118#define CC_REG_MINUS C_00000004
119#define CC_REG_ZERO C_00000008
120#define CC_REG_SATURATE C_00000010
121#define CC_REG_NONZERO C_00000100
122
123/* FX buses */
124#define FXBUS_PCM_LEFT 0x00
125#define FXBUS_PCM_RIGHT 0x01
126#define FXBUS_PCM_LEFT_REAR 0x02
127#define FXBUS_PCM_RIGHT_REAR 0x03
128#define FXBUS_MIDI_LEFT 0x04
129#define FXBUS_MIDI_RIGHT 0x05
130#define FXBUS_PCM_CENTER 0x06
131#define FXBUS_PCM_LFE 0x07
132#define FXBUS_PCM_LEFT_FRONT 0x08
133#define FXBUS_PCM_RIGHT_FRONT 0x09
134#define FXBUS_MIDI_REVERB 0x0c
135#define FXBUS_MIDI_CHORUS 0x0d
136#define FXBUS_PCM_LEFT_SIDE 0x0e
137#define FXBUS_PCM_RIGHT_SIDE 0x0f
138#define FXBUS_PT_LEFT 0x14
139#define FXBUS_PT_RIGHT 0x15
140
141/* Inputs */
142#define EXTIN_AC97_L 0x00 /* AC'97 capture channel - left */
143#define EXTIN_AC97_R 0x01 /* AC'97 capture channel - right */
144#define EXTIN_SPDIF_CD_L 0x02 /* internal S/PDIF CD - onboard - left */
145#define EXTIN_SPDIF_CD_R 0x03 /* internal S/PDIF CD - onboard - right */
146#define EXTIN_ZOOM_L 0x04 /* Zoom Video I2S - left */
147#define EXTIN_ZOOM_R 0x05 /* Zoom Video I2S - right */
148#define EXTIN_TOSLINK_L 0x06 /* LiveDrive - TOSLink Optical - left */
149#define EXTIN_TOSLINK_R 0x07 /* LiveDrive - TOSLink Optical - right */
150#define EXTIN_LINE1_L 0x08 /* LiveDrive - Line/Mic 1 - left */
151#define EXTIN_LINE1_R 0x09 /* LiveDrive - Line/Mic 1 - right */
152#define EXTIN_COAX_SPDIF_L 0x0a /* LiveDrive - Coaxial S/PDIF - left */
153#define EXTIN_COAX_SPDIF_R 0x0b /* LiveDrive - Coaxial S/PDIF - right */
154#define EXTIN_LINE2_L 0x0c /* LiveDrive - Line/Mic 2 - left */
155#define EXTIN_LINE2_R 0x0d /* LiveDrive - Line/Mic 2 - right */
156
157/* Outputs */
158#define EXTOUT_AC97_L 0x00 /* AC'97 playback channel - left */
159#define EXTOUT_AC97_R 0x01 /* AC'97 playback channel - right */
160#define EXTOUT_TOSLINK_L 0x02 /* LiveDrive - TOSLink Optical - left */
161#define EXTOUT_TOSLINK_R 0x03 /* LiveDrive - TOSLink Optical - right */
162#define EXTOUT_AC97_CENTER 0x04 /* SB Live 5.1 - center */
163#define EXTOUT_AC97_LFE 0x05 /* SB Live 5.1 - LFE */
164#define EXTOUT_HEADPHONE_L 0x06 /* LiveDrive - Headphone - left */
165#define EXTOUT_HEADPHONE_R 0x07 /* LiveDrive - Headphone - right */
166#define EXTOUT_REAR_L 0x08 /* Rear channel - left */
167#define EXTOUT_REAR_R 0x09 /* Rear channel - right */
168#define EXTOUT_ADC_CAP_L 0x0a /* ADC Capture buffer - left */
169#define EXTOUT_ADC_CAP_R 0x0b /* ADC Capture buffer - right */
170#define EXTOUT_MIC_CAP 0x0c /* MIC Capture buffer */
171#define EXTOUT_AC97_REAR_L 0x0d /* SB Live 5.1 (c) 2003 - Rear Left */
172#define EXTOUT_AC97_REAR_R 0x0e /* SB Live 5.1 (c) 2003 - Rear Right */
173#define EXTOUT_ACENTER 0x11 /* Analog Center */
174#define EXTOUT_ALFE 0x12 /* Analog LFE */
175
176/* Audigy Inputs */
177#define A_EXTIN_AC97_L 0x00 /* AC'97 capture channel - left */
178#define A_EXTIN_AC97_R 0x01 /* AC'97 capture channel - right */
179#define A_EXTIN_SPDIF_CD_L 0x02 /* digital CD left */
180#define A_EXTIN_SPDIF_CD_R 0x03 /* digital CD left */
181#define A_EXTIN_OPT_SPDIF_L 0x04 /* audigy drive Optical SPDIF - left */
182#define A_EXTIN_OPT_SPDIF_R 0x05 /* right */
183#define A_EXTIN_LINE2_L 0x08 /* audigy drive line2/mic2 - left */
184#define A_EXTIN_LINE2_R 0x09 /* right */
185#define A_EXTIN_ADC_L 0x0a /* Philips ADC - left */
186#define A_EXTIN_ADC_R 0x0b /* right */
187#define A_EXTIN_AUX2_L 0x0c /* audigy drive aux2 - left */
188#define A_EXTIN_AUX2_R 0x0d /* - right */
189
190/* Audigiy Outputs */
191#define A_EXTOUT_FRONT_L 0x00 /* digital front left */
192#define A_EXTOUT_FRONT_R 0x01 /* right */
193#define A_EXTOUT_CENTER 0x02 /* digital front center */
194#define A_EXTOUT_LFE 0x03 /* digital front lfe */
195#define A_EXTOUT_HEADPHONE_L 0x04 /* headphone audigy drive left */
196#define A_EXTOUT_HEADPHONE_R 0x05 /* right */
197#define A_EXTOUT_REAR_L 0x06 /* digital rear left */
198#define A_EXTOUT_REAR_R 0x07 /* right */
199#define A_EXTOUT_AFRONT_L 0x08 /* analog front left */
200#define A_EXTOUT_AFRONT_R 0x09 /* right */
201#define A_EXTOUT_ACENTER 0x0a /* analog center */
202#define A_EXTOUT_ALFE 0x0b /* analog LFE */
203#define A_EXTOUT_ASIDE_L 0x0c /* analog side left - Audigy 2 ZS */
204#define A_EXTOUT_ASIDE_R 0x0d /* right - Audigy 2 ZS */
205#define A_EXTOUT_AREAR_L 0x0e /* analog rear left */
206#define A_EXTOUT_AREAR_R 0x0f /* right */
207#define A_EXTOUT_AC97_L 0x10 /* AC97 left (front) */
208#define A_EXTOUT_AC97_R 0x11 /* right */
209#define A_EXTOUT_ADC_CAP_L 0x16 /* ADC capture buffer left */
210#define A_EXTOUT_ADC_CAP_R 0x17 /* right */
211#define A_EXTOUT_MIC_CAP 0x18 /* Mic capture buffer */
212
213/* Audigy constants */
214#define A_C_00000000 0xc0
215#define A_C_00000001 0xc1
216#define A_C_00000002 0xc2
217#define A_C_00000003 0xc3
218#define A_C_00000004 0xc4
219#define A_C_00000008 0xc5
220#define A_C_00000010 0xc6
221#define A_C_00000020 0xc7
222#define A_C_00000100 0xc8
223#define A_C_00010000 0xc9
224#define A_C_00000800 0xca
225#define A_C_10000000 0xcb
226#define A_C_20000000 0xcc
227#define A_C_40000000 0xcd
228#define A_C_80000000 0xce
229#define A_C_7fffffff 0xcf
230#define A_C_ffffffff 0xd0
231#define A_C_fffffffe 0xd1
232#define A_C_c0000000 0xd2
233#define A_C_4f1bbcdc 0xd3
234#define A_C_5a7ef9db 0xd4
235#define A_C_00100000 0xd5
236#define A_GPR_ACCU 0xd6 /* ACCUM, accumulator */
237#define A_GPR_COND 0xd7 /* CCR, condition register */
238#define A_GPR_NOISE0 0xd8 /* noise source */
239#define A_GPR_NOISE1 0xd9 /* noise source */
240#define A_GPR_IRQ 0xda /* IRQ register */
241#define A_GPR_DBAC 0xdb /* TRAM Delay Base Address Counter - internal */
242#define A_GPR_DBACE 0xde /* TRAM Delay Base Address Counter - external */
243
244/* definitions for debug register */
245#define EMU10K1_DBG_ZC 0x80000000 /* zero tram counter */
246#define EMU10K1_DBG_SATURATION_OCCURED 0x02000000 /* saturation control */
247#define EMU10K1_DBG_SATURATION_ADDR 0x01ff0000 /* saturation address */
248#define EMU10K1_DBG_SINGLE_STEP 0x00008000 /* single step mode */
249#define EMU10K1_DBG_STEP 0x00004000 /* start single step */
250#define EMU10K1_DBG_CONDITION_CODE 0x00003e00 /* condition code */
251#define EMU10K1_DBG_SINGLE_STEP_ADDR 0x000001ff /* single step address */
252
253/* tank memory address line */
254#ifndef __KERNEL__
255#define TANKMEMADDRREG_ADDR_MASK 0x000fffff /* 20 bit tank address field */
256#define TANKMEMADDRREG_CLEAR 0x00800000 /* Clear tank memory */
257#define TANKMEMADDRREG_ALIGN 0x00400000 /* Align read or write relative to tank access */
258#define TANKMEMADDRREG_WRITE 0x00200000 /* Write to tank memory */
259#define TANKMEMADDRREG_READ 0x00100000 /* Read from tank memory */
260#endif
261
262struct snd_emu10k1_fx8010_info {
263 unsigned int internal_tram_size; /* in samples */
264 unsigned int external_tram_size; /* in samples */
265 char fxbus_names[16][32]; /* names of FXBUSes */
266 char extin_names[16][32]; /* names of external inputs */
267 char extout_names[32][32]; /* names of external outputs */
268 unsigned int gpr_controls; /* count of GPR controls */
269};
270
271#define EMU10K1_GPR_TRANSLATION_NONE 0
272#define EMU10K1_GPR_TRANSLATION_TABLE100 1
273#define EMU10K1_GPR_TRANSLATION_BASS 2
274#define EMU10K1_GPR_TRANSLATION_TREBLE 3
275#define EMU10K1_GPR_TRANSLATION_ONOFF 4
276
277struct snd_emu10k1_fx8010_control_gpr {
278 struct snd_ctl_elem_id id; /* full control ID definition */
279 unsigned int vcount; /* visible count */
280 unsigned int count; /* count of GPR (1..16) */
281 unsigned short gpr[32]; /* GPR number(s) */
282 unsigned int value[32]; /* initial values */
283 unsigned int min; /* minimum range */
284 unsigned int max; /* maximum range */
285 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */
286 const unsigned int *tlv;
287};
288
289/* old ABI without TLV support */
290struct snd_emu10k1_fx8010_control_old_gpr {
291 struct snd_ctl_elem_id id;
292 unsigned int vcount;
293 unsigned int count;
294 unsigned short gpr[32];
295 unsigned int value[32];
296 unsigned int min;
297 unsigned int max;
298 unsigned int translation;
299};
300
301struct snd_emu10k1_fx8010_code {
302 char name[128];
303
304 DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */
305 __u32 __user *gpr_map; /* initializers */
306
307 unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */
308 struct snd_emu10k1_fx8010_control_gpr __user *gpr_add_controls; /* GPR controls to add/replace */
309
310 unsigned int gpr_del_control_count; /* count of GPR controls to remove */
311 struct snd_ctl_elem_id __user *gpr_del_controls; /* IDs of GPR controls to remove */
312
313 unsigned int gpr_list_control_count; /* count of GPR controls to list */
314 unsigned int gpr_list_control_total; /* total count of GPR controls */
315 struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /* listed GPR controls */
316
317 DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */
318 __u32 __user *tram_data_map; /* data initializers */
319 __u32 __user *tram_addr_map; /* map initializers */
320
321 DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */
322 __u32 __user *code; /* one instruction - 64 bits */
323};
324
325struct snd_emu10k1_fx8010_tram {
326 unsigned int address; /* 31.bit == 1 -> external TRAM */
327 unsigned int size; /* size in samples (4 bytes) */
328 unsigned int *samples; /* pointer to samples (20-bit) */
329 /* NULL->clear memory */
330};
331
332struct snd_emu10k1_fx8010_pcm_rec {
333 unsigned int substream; /* substream number */
334 unsigned int res1; /* reserved */
335 unsigned int channels; /* 16-bit channels count, zero = remove this substream */
336 unsigned int tram_start; /* ring buffer position in TRAM (in samples) */
337 unsigned int buffer_size; /* count of buffered samples */
338 unsigned short gpr_size; /* GPR containing size of ringbuffer in samples (host) */
339 unsigned short gpr_ptr; /* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
340 unsigned short gpr_count; /* GPR containing count of samples between two interrupts (host) */
341 unsigned short gpr_tmpcount; /* GPR containing current count of samples to interrupt (host = set, FX8010) */
342 unsigned short gpr_trigger; /* GPR containing trigger (activate) information (host) */
343 unsigned short gpr_running; /* GPR containing info if PCM is running (FX8010) */
344 unsigned char pad; /* reserved */
345 unsigned char etram[32]; /* external TRAM address & data (one per channel) */
346 unsigned int res2; /* reserved */
347};
348
349#define SNDRV_EMU10K1_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1)
350
351#define SNDRV_EMU10K1_IOCTL_INFO _IOR ('H', 0x10, struct snd_emu10k1_fx8010_info)
352#define SNDRV_EMU10K1_IOCTL_CODE_POKE _IOW ('H', 0x11, struct snd_emu10k1_fx8010_code)
353#define SNDRV_EMU10K1_IOCTL_CODE_PEEK _IOWR('H', 0x12, struct snd_emu10k1_fx8010_code)
354#define SNDRV_EMU10K1_IOCTL_TRAM_SETUP _IOW ('H', 0x20, int)
355#define SNDRV_EMU10K1_IOCTL_TRAM_POKE _IOW ('H', 0x21, struct snd_emu10k1_fx8010_tram)
356#define SNDRV_EMU10K1_IOCTL_TRAM_PEEK _IOWR('H', 0x22, struct snd_emu10k1_fx8010_tram)
357#define SNDRV_EMU10K1_IOCTL_PCM_POKE _IOW ('H', 0x30, struct snd_emu10k1_fx8010_pcm_rec)
358#define SNDRV_EMU10K1_IOCTL_PCM_PEEK _IOWR('H', 0x31, struct snd_emu10k1_fx8010_pcm_rec)
359#define SNDRV_EMU10K1_IOCTL_PVERSION _IOR ('H', 0x40, int)
360#define SNDRV_EMU10K1_IOCTL_STOP _IO ('H', 0x80)
361#define SNDRV_EMU10K1_IOCTL_CONTINUE _IO ('H', 0x81)
362#define SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER _IO ('H', 0x82)
363#define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int)
364#define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int)
365
366/* typedefs for compatibility to user-space */
367typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t;
368typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t;
369typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t;
370typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t;
371typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t;
372
373#endif /* _UAPI__SOUND_EMU10K1_H */
diff --git a/include/sound/hdsp.h b/include/uapi/sound/hdsp.h
index 0909a3843479..0909a3843479 100644
--- a/include/sound/hdsp.h
+++ b/include/uapi/sound/hdsp.h
diff --git a/include/sound/hdspm.h b/include/uapi/sound/hdspm.h
index 1f59ea2a4a76..1f59ea2a4a76 100644
--- a/include/sound/hdspm.h
+++ b/include/uapi/sound/hdspm.h
diff --git a/include/uapi/sound/sb16_csp.h b/include/uapi/sound/sb16_csp.h
new file mode 100644
index 000000000000..3b96907e2afb
--- /dev/null
+++ b/include/uapi/sound/sb16_csp.h
@@ -0,0 +1,122 @@
1/*
2 * Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
3 * Takashi Iwai <tiwai@suse.de>
4 *
5 * SB16ASP/AWE32 CSP control
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22#ifndef _UAPI__SOUND_SB16_CSP_H
23#define _UAPI__SOUND_SB16_CSP_H
24
25
26/* CSP modes */
27#define SNDRV_SB_CSP_MODE_NONE 0x00
28#define SNDRV_SB_CSP_MODE_DSP_READ 0x01 /* Record from DSP */
29#define SNDRV_SB_CSP_MODE_DSP_WRITE 0x02 /* Play to DSP */
30#define SNDRV_SB_CSP_MODE_QSOUND 0x04 /* QSound */
31
32/* CSP load flags */
33#define SNDRV_SB_CSP_LOAD_FROMUSER 0x01
34#define SNDRV_SB_CSP_LOAD_INITBLOCK 0x02
35
36/* CSP sample width */
37#define SNDRV_SB_CSP_SAMPLE_8BIT 0x01
38#define SNDRV_SB_CSP_SAMPLE_16BIT 0x02
39
40/* CSP channels */
41#define SNDRV_SB_CSP_MONO 0x01
42#define SNDRV_SB_CSP_STEREO 0x02
43
44/* CSP rates */
45#define SNDRV_SB_CSP_RATE_8000 0x01
46#define SNDRV_SB_CSP_RATE_11025 0x02
47#define SNDRV_SB_CSP_RATE_22050 0x04
48#define SNDRV_SB_CSP_RATE_44100 0x08
49#define SNDRV_SB_CSP_RATE_ALL 0x0f
50
51/* CSP running state */
52#define SNDRV_SB_CSP_ST_IDLE 0x00
53#define SNDRV_SB_CSP_ST_LOADED 0x01
54#define SNDRV_SB_CSP_ST_RUNNING 0x02
55#define SNDRV_SB_CSP_ST_PAUSED 0x04
56#define SNDRV_SB_CSP_ST_AUTO 0x08
57#define SNDRV_SB_CSP_ST_QSOUND 0x10
58
59/* maximum QSound value (180 degrees right) */
60#define SNDRV_SB_CSP_QSOUND_MAX_RIGHT 0x20
61
62/* maximum microcode RIFF file size */
63#define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE 0x3000
64
65/* microcode header */
66struct snd_sb_csp_mc_header {
67 char codec_name[16]; /* id name of codec */
68 unsigned short func_req; /* requested function */
69};
70
71/* microcode to be loaded */
72struct snd_sb_csp_microcode {
73 struct snd_sb_csp_mc_header info;
74 unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
75};
76
77/* start CSP with sample_width in mono/stereo */
78struct snd_sb_csp_start {
79 int sample_width; /* sample width, look above */
80 int channels; /* channels, look above */
81};
82
83/* CSP information */
84struct snd_sb_csp_info {
85 char codec_name[16]; /* id name of codec */
86 unsigned short func_nr; /* function number */
87 unsigned int acc_format; /* accepted PCM formats */
88 unsigned short acc_channels; /* accepted channels */
89 unsigned short acc_width; /* accepted sample width */
90 unsigned short acc_rates; /* accepted sample rates */
91 unsigned short csp_mode; /* CSP mode, see above */
92 unsigned short run_channels; /* current channels */
93 unsigned short run_width; /* current sample width */
94 unsigned short version; /* version id: 0x10 - 0x1f */
95 unsigned short state; /* state bits */
96};
97
98/* HWDEP controls */
99/* get CSP information */
100#define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info)
101/* load microcode to CSP */
102/* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits)
103 * defined for some architectures like MIPS, and it leads to build errors.
104 * (x86 and co have 14-bit size, thus it's valid, though.)
105 * As a workaround for skipping the size-limit check, here we don't use the
106 * normal _IOW() macro but _IOC() with the manual argument.
107 */
108#define SNDRV_SB_CSP_IOCTL_LOAD_CODE \
109 _IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode))
110/* unload microcode from CSP */
111#define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12)
112/* start CSP */
113#define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, struct snd_sb_csp_start)
114/* stop CSP */
115#define SNDRV_SB_CSP_IOCTL_STOP _IO('H', 0x14)
116/* pause CSP and DMA transfer */
117#define SNDRV_SB_CSP_IOCTL_PAUSE _IO('H', 0x15)
118/* restart CSP and DMA transfer */
119#define SNDRV_SB_CSP_IOCTL_RESTART _IO('H', 0x16)
120
121
122#endif /* _UAPI__SOUND_SB16_CSP_H */
diff --git a/include/sound/sfnt_info.h b/include/uapi/sound/sfnt_info.h
index 1bce7fd1725f..1bce7fd1725f 100644
--- a/include/sound/sfnt_info.h
+++ b/include/uapi/sound/sfnt_info.h
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 91cdf9435fec..af49721ba0e3 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -190,7 +190,9 @@ struct snd_pcm_status32 {
190 u32 avail_max; 190 u32 avail_max;
191 u32 overrange; 191 u32 overrange;
192 s32 suspended_state; 192 s32 suspended_state;
193 unsigned char reserved[60]; 193 u32 reserved_alignment;
194 struct compat_timespec audio_tstamp;
195 unsigned char reserved[56-sizeof(struct compat_timespec)];
194} __attribute__((packed)); 196} __attribute__((packed));
195 197
196 198
@@ -205,17 +207,16 @@ static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
205 return err; 207 return err;
206 208
207 if (put_user(status.state, &src->state) || 209 if (put_user(status.state, &src->state) ||
208 put_user(status.trigger_tstamp.tv_sec, &src->trigger_tstamp.tv_sec) || 210 compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
209 put_user(status.trigger_tstamp.tv_nsec, &src->trigger_tstamp.tv_nsec) || 211 compat_put_timespec(&status.tstamp, &src->tstamp) ||
210 put_user(status.tstamp.tv_sec, &src->tstamp.tv_sec) ||
211 put_user(status.tstamp.tv_nsec, &src->tstamp.tv_nsec) ||
212 put_user(status.appl_ptr, &src->appl_ptr) || 212 put_user(status.appl_ptr, &src->appl_ptr) ||
213 put_user(status.hw_ptr, &src->hw_ptr) || 213 put_user(status.hw_ptr, &src->hw_ptr) ||
214 put_user(status.delay, &src->delay) || 214 put_user(status.delay, &src->delay) ||
215 put_user(status.avail, &src->avail) || 215 put_user(status.avail, &src->avail) ||
216 put_user(status.avail_max, &src->avail_max) || 216 put_user(status.avail_max, &src->avail_max) ||
217 put_user(status.overrange, &src->overrange) || 217 put_user(status.overrange, &src->overrange) ||
218 put_user(status.suspended_state, &src->suspended_state)) 218 put_user(status.suspended_state, &src->suspended_state) ||
219 compat_put_timespec(&status.audio_tstamp, &src->audio_tstamp))
219 return -EFAULT; 220 return -EFAULT;
220 221
221 return err; 222 return err;
@@ -364,6 +365,7 @@ struct snd_pcm_mmap_status32 {
364 u32 hw_ptr; 365 u32 hw_ptr;
365 struct compat_timespec tstamp; 366 struct compat_timespec tstamp;
366 s32 suspended_state; 367 s32 suspended_state;
368 struct compat_timespec audio_tstamp;
367} __attribute__((packed)); 369} __attribute__((packed));
368 370
369struct snd_pcm_mmap_control32 { 371struct snd_pcm_mmap_control32 {
@@ -426,12 +428,14 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
426 sstatus.hw_ptr = status->hw_ptr % boundary; 428 sstatus.hw_ptr = status->hw_ptr % boundary;
427 sstatus.tstamp = status->tstamp; 429 sstatus.tstamp = status->tstamp;
428 sstatus.suspended_state = status->suspended_state; 430 sstatus.suspended_state = status->suspended_state;
431 sstatus.audio_tstamp = status->audio_tstamp;
429 snd_pcm_stream_unlock_irq(substream); 432 snd_pcm_stream_unlock_irq(substream);
430 if (put_user(sstatus.state, &src->s.status.state) || 433 if (put_user(sstatus.state, &src->s.status.state) ||
431 put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || 434 put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) ||
432 put_user(sstatus.tstamp.tv_sec, &src->s.status.tstamp.tv_sec) || 435 compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) ||
433 put_user(sstatus.tstamp.tv_nsec, &src->s.status.tstamp.tv_nsec) ||
434 put_user(sstatus.suspended_state, &src->s.status.suspended_state) || 436 put_user(sstatus.suspended_state, &src->s.status.suspended_state) ||
437 compat_put_timespec(&sstatus.audio_tstamp,
438 &src->s.status.audio_tstamp) ||
435 put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || 439 put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
436 put_user(scontrol.avail_min, &src->c.control.avail_min)) 440 put_user(scontrol.avail_min, &src->c.control.avail_min))
437 return -EFAULT; 441 return -EFAULT;
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index f42c10a43315..c4840ff75d00 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -316,6 +316,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
316 unsigned long jdelta; 316 unsigned long jdelta;
317 unsigned long curr_jiffies; 317 unsigned long curr_jiffies;
318 struct timespec curr_tstamp; 318 struct timespec curr_tstamp;
319 struct timespec audio_tstamp;
320 int crossed_boundary = 0;
319 321
320 old_hw_ptr = runtime->status->hw_ptr; 322 old_hw_ptr = runtime->status->hw_ptr;
321 323
@@ -327,9 +329,14 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
327 */ 329 */
328 pos = substream->ops->pointer(substream); 330 pos = substream->ops->pointer(substream);
329 curr_jiffies = jiffies; 331 curr_jiffies = jiffies;
330 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) 332 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
331 snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); 333 snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
332 334
335 if ((runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK) &&
336 (substream->ops->wall_clock))
337 substream->ops->wall_clock(substream, &audio_tstamp);
338 }
339
333 if (pos == SNDRV_PCM_POS_XRUN) { 340 if (pos == SNDRV_PCM_POS_XRUN) {
334 xrun(substream); 341 xrun(substream);
335 return -EPIPE; 342 return -EPIPE;
@@ -360,8 +367,10 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
360 hdelta = curr_jiffies - runtime->hw_ptr_jiffies; 367 hdelta = curr_jiffies - runtime->hw_ptr_jiffies;
361 if (hdelta > runtime->hw_ptr_buffer_jiffies/2) { 368 if (hdelta > runtime->hw_ptr_buffer_jiffies/2) {
362 hw_base += runtime->buffer_size; 369 hw_base += runtime->buffer_size;
363 if (hw_base >= runtime->boundary) 370 if (hw_base >= runtime->boundary) {
364 hw_base = 0; 371 hw_base = 0;
372 crossed_boundary++;
373 }
365 new_hw_ptr = hw_base + pos; 374 new_hw_ptr = hw_base + pos;
366 goto __delta; 375 goto __delta;
367 } 376 }
@@ -371,8 +380,10 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
371 /* pointer crosses the end of the ring buffer */ 380 /* pointer crosses the end of the ring buffer */
372 if (new_hw_ptr < old_hw_ptr) { 381 if (new_hw_ptr < old_hw_ptr) {
373 hw_base += runtime->buffer_size; 382 hw_base += runtime->buffer_size;
374 if (hw_base >= runtime->boundary) 383 if (hw_base >= runtime->boundary) {
375 hw_base = 0; 384 hw_base = 0;
385 crossed_boundary++;
386 }
376 new_hw_ptr = hw_base + pos; 387 new_hw_ptr = hw_base + pos;
377 } 388 }
378 __delta: 389 __delta:
@@ -410,8 +421,10 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
410 while (hdelta > xrun_threshold) { 421 while (hdelta > xrun_threshold) {
411 delta += runtime->buffer_size; 422 delta += runtime->buffer_size;
412 hw_base += runtime->buffer_size; 423 hw_base += runtime->buffer_size;
413 if (hw_base >= runtime->boundary) 424 if (hw_base >= runtime->boundary) {
414 hw_base = 0; 425 hw_base = 0;
426 crossed_boundary++;
427 }
415 new_hw_ptr = hw_base + pos; 428 new_hw_ptr = hw_base + pos;
416 hdelta -= runtime->hw_ptr_buffer_jiffies; 429 hdelta -= runtime->hw_ptr_buffer_jiffies;
417 } 430 }
@@ -456,8 +469,10 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
456 /* the delta value is small or zero in most cases */ 469 /* the delta value is small or zero in most cases */
457 while (delta > 0) { 470 while (delta > 0) {
458 new_hw_ptr += runtime->period_size; 471 new_hw_ptr += runtime->period_size;
459 if (new_hw_ptr >= runtime->boundary) 472 if (new_hw_ptr >= runtime->boundary) {
460 new_hw_ptr -= runtime->boundary; 473 new_hw_ptr -= runtime->boundary;
474 crossed_boundary--;
475 }
461 delta--; 476 delta--;
462 } 477 }
463 /* align hw_base to buffer_size */ 478 /* align hw_base to buffer_size */
@@ -507,9 +522,35 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
507 runtime->hw_ptr_base = hw_base; 522 runtime->hw_ptr_base = hw_base;
508 runtime->status->hw_ptr = new_hw_ptr; 523 runtime->status->hw_ptr = new_hw_ptr;
509 runtime->hw_ptr_jiffies = curr_jiffies; 524 runtime->hw_ptr_jiffies = curr_jiffies;
510 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) 525 if (crossed_boundary) {
526 snd_BUG_ON(crossed_boundary != 1);
527 runtime->hw_ptr_wrap += runtime->boundary;
528 }
529 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
511 runtime->status->tstamp = curr_tstamp; 530 runtime->status->tstamp = curr_tstamp;
512 531
532 if (!(runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK)) {
533 /*
534 * no wall clock available, provide audio timestamp
535 * derived from pointer position+delay
536 */
537 u64 audio_frames, audio_nsecs;
538
539 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
540 audio_frames = runtime->hw_ptr_wrap
541 + runtime->status->hw_ptr
542 - runtime->delay;
543 else
544 audio_frames = runtime->hw_ptr_wrap
545 + runtime->status->hw_ptr
546 + runtime->delay;
547 audio_nsecs = div_u64(audio_frames * 1000000000LL,
548 runtime->rate);
549 audio_tstamp = ns_to_timespec(audio_nsecs);
550 }
551 runtime->status->audio_tstamp = audio_tstamp;
552 }
553
513 return snd_pcm_update_state(substream, runtime); 554 return snd_pcm_update_state(substream, runtime);
514} 555}
515 556
@@ -1661,8 +1702,10 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream,
1661 if (snd_pcm_running(substream) && 1702 if (snd_pcm_running(substream) &&
1662 snd_pcm_update_hw_ptr(substream) >= 0) 1703 snd_pcm_update_hw_ptr(substream) >= 0)
1663 runtime->status->hw_ptr %= runtime->buffer_size; 1704 runtime->status->hw_ptr %= runtime->buffer_size;
1664 else 1705 else {
1665 runtime->status->hw_ptr = 0; 1706 runtime->status->hw_ptr = 0;
1707 runtime->hw_ptr_wrap = 0;
1708 }
1666 snd_pcm_stream_unlock_irqrestore(substream, flags); 1709 snd_pcm_stream_unlock_irqrestore(substream, flags);
1667 return 0; 1710 return 0;
1668} 1711}
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 6e8872de5ba0..b329ca58e63c 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -602,6 +602,8 @@ int snd_pcm_status(struct snd_pcm_substream *substream,
602 snd_pcm_update_hw_ptr(substream); 602 snd_pcm_update_hw_ptr(substream);
603 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { 603 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
604 status->tstamp = runtime->status->tstamp; 604 status->tstamp = runtime->status->tstamp;
605 status->audio_tstamp =
606 runtime->status->audio_tstamp;
605 goto _tstamp_end; 607 goto _tstamp_end;
606 } 608 }
607 } 609 }
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index fe5ae09ffccb..5e4384137a76 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -35,7 +35,6 @@ config SND_PCSP
35 tristate "PC-Speaker support (READ HELP!)" 35 tristate "PC-Speaker support (READ HELP!)"
36 depends on PCSPKR_PLATFORM && X86 && HIGH_RES_TIMERS 36 depends on PCSPKR_PLATFORM && X86 && HIGH_RES_TIMERS
37 depends on INPUT 37 depends on INPUT
38 depends on EXPERIMENTAL
39 select SND_PCM 38 select SND_PCM
40 help 39 help
41 If you don't have a sound card in your computer, you can include a 40 If you don't have a sound card in your computer, you can include a
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 0fe6d64ff840..1904046686e2 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -120,7 +120,6 @@ struct loopback_pcm {
120 unsigned int last_drift; 120 unsigned int last_drift;
121 unsigned long last_jiffies; 121 unsigned long last_jiffies;
122 struct timer_list timer; 122 struct timer_list timer;
123 spinlock_t timer_lock;
124}; 123};
125 124
126static struct platform_device *devices[SNDRV_CARDS]; 125static struct platform_device *devices[SNDRV_CARDS];
@@ -166,12 +165,12 @@ static inline unsigned int get_rate_shift(struct loopback_pcm *dpcm)
166 return get_setup(dpcm)->rate_shift; 165 return get_setup(dpcm)->rate_shift;
167} 166}
168 167
168/* call in cable->lock */
169static void loopback_timer_start(struct loopback_pcm *dpcm) 169static void loopback_timer_start(struct loopback_pcm *dpcm)
170{ 170{
171 unsigned long tick; 171 unsigned long tick;
172 unsigned int rate_shift = get_rate_shift(dpcm); 172 unsigned int rate_shift = get_rate_shift(dpcm);
173 173
174 spin_lock(&dpcm->timer_lock);
175 if (rate_shift != dpcm->pcm_rate_shift) { 174 if (rate_shift != dpcm->pcm_rate_shift) {
176 dpcm->pcm_rate_shift = rate_shift; 175 dpcm->pcm_rate_shift = rate_shift;
177 dpcm->period_size_frac = frac_pos(dpcm, dpcm->pcm_period_size); 176 dpcm->period_size_frac = frac_pos(dpcm, dpcm->pcm_period_size);
@@ -184,15 +183,13 @@ static void loopback_timer_start(struct loopback_pcm *dpcm)
184 tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps; 183 tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps;
185 dpcm->timer.expires = jiffies + tick; 184 dpcm->timer.expires = jiffies + tick;
186 add_timer(&dpcm->timer); 185 add_timer(&dpcm->timer);
187 spin_unlock(&dpcm->timer_lock);
188} 186}
189 187
188/* call in cable->lock */
190static inline void loopback_timer_stop(struct loopback_pcm *dpcm) 189static inline void loopback_timer_stop(struct loopback_pcm *dpcm)
191{ 190{
192 spin_lock(&dpcm->timer_lock);
193 del_timer(&dpcm->timer); 191 del_timer(&dpcm->timer);
194 dpcm->timer.expires = 0; 192 dpcm->timer.expires = 0;
195 spin_unlock(&dpcm->timer_lock);
196} 193}
197 194
198#define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK) 195#define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK)
@@ -274,8 +271,8 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
274 spin_lock(&cable->lock); 271 spin_lock(&cable->lock);
275 cable->running |= stream; 272 cable->running |= stream;
276 cable->pause &= ~stream; 273 cable->pause &= ~stream;
277 spin_unlock(&cable->lock);
278 loopback_timer_start(dpcm); 274 loopback_timer_start(dpcm);
275 spin_unlock(&cable->lock);
279 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 276 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
280 loopback_active_notify(dpcm); 277 loopback_active_notify(dpcm);
281 break; 278 break;
@@ -283,23 +280,23 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
283 spin_lock(&cable->lock); 280 spin_lock(&cable->lock);
284 cable->running &= ~stream; 281 cable->running &= ~stream;
285 cable->pause &= ~stream; 282 cable->pause &= ~stream;
286 spin_unlock(&cable->lock);
287 loopback_timer_stop(dpcm); 283 loopback_timer_stop(dpcm);
284 spin_unlock(&cable->lock);
288 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 285 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
289 loopback_active_notify(dpcm); 286 loopback_active_notify(dpcm);
290 break; 287 break;
291 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 288 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
292 spin_lock(&cable->lock); 289 spin_lock(&cable->lock);
293 cable->pause |= stream; 290 cable->pause |= stream;
294 spin_unlock(&cable->lock);
295 loopback_timer_stop(dpcm); 291 loopback_timer_stop(dpcm);
292 spin_unlock(&cable->lock);
296 break; 293 break;
297 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 294 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
298 spin_lock(&cable->lock); 295 spin_lock(&cable->lock);
299 dpcm->last_jiffies = jiffies; 296 dpcm->last_jiffies = jiffies;
300 cable->pause &= ~stream; 297 cable->pause &= ~stream;
301 spin_unlock(&cable->lock);
302 loopback_timer_start(dpcm); 298 loopback_timer_start(dpcm);
299 spin_unlock(&cable->lock);
303 break; 300 break;
304 default: 301 default:
305 return -EINVAL; 302 return -EINVAL;
@@ -477,6 +474,7 @@ static inline void bytepos_finish(struct loopback_pcm *dpcm,
477 dpcm->buf_pos %= dpcm->pcm_buffer_size; 474 dpcm->buf_pos %= dpcm->pcm_buffer_size;
478} 475}
479 476
477/* call in cable->lock */
480static unsigned int loopback_pos_update(struct loopback_cable *cable) 478static unsigned int loopback_pos_update(struct loopback_cable *cable)
481{ 479{
482 struct loopback_pcm *dpcm_play = 480 struct loopback_pcm *dpcm_play =
@@ -485,9 +483,7 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable)
485 cable->streams[SNDRV_PCM_STREAM_CAPTURE]; 483 cable->streams[SNDRV_PCM_STREAM_CAPTURE];
486 unsigned long delta_play = 0, delta_capt = 0; 484 unsigned long delta_play = 0, delta_capt = 0;
487 unsigned int running, count1, count2; 485 unsigned int running, count1, count2;
488 unsigned long flags;
489 486
490 spin_lock_irqsave(&cable->lock, flags);
491 running = cable->running ^ cable->pause; 487 running = cable->running ^ cable->pause;
492 if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { 488 if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
493 delta_play = jiffies - dpcm_play->last_jiffies; 489 delta_play = jiffies - dpcm_play->last_jiffies;
@@ -529,32 +525,39 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable)
529 bytepos_finish(dpcm_play, count1); 525 bytepos_finish(dpcm_play, count1);
530 bytepos_finish(dpcm_capt, count1); 526 bytepos_finish(dpcm_capt, count1);
531 unlock: 527 unlock:
532 spin_unlock_irqrestore(&cable->lock, flags);
533 return running; 528 return running;
534} 529}
535 530
536static void loopback_timer_function(unsigned long data) 531static void loopback_timer_function(unsigned long data)
537{ 532{
538 struct loopback_pcm *dpcm = (struct loopback_pcm *)data; 533 struct loopback_pcm *dpcm = (struct loopback_pcm *)data;
539 unsigned int running; 534 unsigned long flags;
540 535
541 running = loopback_pos_update(dpcm->cable); 536 spin_lock_irqsave(&dpcm->cable->lock, flags);
542 if (running & (1 << dpcm->substream->stream)) { 537 if (loopback_pos_update(dpcm->cable) & (1 << dpcm->substream->stream)) {
543 loopback_timer_start(dpcm); 538 loopback_timer_start(dpcm);
544 if (dpcm->period_update_pending) { 539 if (dpcm->period_update_pending) {
545 dpcm->period_update_pending = 0; 540 dpcm->period_update_pending = 0;
541 spin_unlock_irqrestore(&dpcm->cable->lock, flags);
542 /* need to unlock before calling below */
546 snd_pcm_period_elapsed(dpcm->substream); 543 snd_pcm_period_elapsed(dpcm->substream);
544 return;
547 } 545 }
548 } 546 }
547 spin_unlock_irqrestore(&dpcm->cable->lock, flags);
549} 548}
550 549
551static snd_pcm_uframes_t loopback_pointer(struct snd_pcm_substream *substream) 550static snd_pcm_uframes_t loopback_pointer(struct snd_pcm_substream *substream)
552{ 551{
553 struct snd_pcm_runtime *runtime = substream->runtime; 552 struct snd_pcm_runtime *runtime = substream->runtime;
554 struct loopback_pcm *dpcm = runtime->private_data; 553 struct loopback_pcm *dpcm = runtime->private_data;
554 snd_pcm_uframes_t pos;
555 555
556 spin_lock(&dpcm->cable->lock);
556 loopback_pos_update(dpcm->cable); 557 loopback_pos_update(dpcm->cable);
557 return bytes_to_frames(runtime, dpcm->buf_pos); 558 pos = dpcm->buf_pos;
559 spin_unlock(&dpcm->cable->lock);
560 return bytes_to_frames(runtime, pos);
558} 561}
559 562
560static struct snd_pcm_hardware loopback_pcm_hardware = 563static struct snd_pcm_hardware loopback_pcm_hardware =
@@ -672,7 +675,6 @@ static int loopback_open(struct snd_pcm_substream *substream)
672 dpcm->substream = substream; 675 dpcm->substream = substream;
673 setup_timer(&dpcm->timer, loopback_timer_function, 676 setup_timer(&dpcm->timer, loopback_timer_function,
674 (unsigned long)dpcm); 677 (unsigned long)dpcm);
675 spin_lock_init(&dpcm->timer_lock);
676 678
677 cable = loopback->cables[substream->number][dev]; 679 cable = loopback->cables[substream->number][dev];
678 if (!cable) { 680 if (!cable) {
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 54bb6644a598..4f522cf48455 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -134,6 +134,9 @@ struct snd_dummy {
134 spinlock_t mixer_lock; 134 spinlock_t mixer_lock;
135 int mixer_volume[MIXER_ADDR_LAST+1][2]; 135 int mixer_volume[MIXER_ADDR_LAST+1][2];
136 int capture_source[MIXER_ADDR_LAST+1][2]; 136 int capture_source[MIXER_ADDR_LAST+1][2];
137 int iobox;
138 struct snd_kcontrol *cd_volume_ctl;
139 struct snd_kcontrol *cd_switch_ctl;
137 const struct dummy_timer_ops *timer_ops; 140 const struct dummy_timer_ops *timer_ops;
138}; 141};
139 142
@@ -817,6 +820,57 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
817 return change; 820 return change;
818} 821}
819 822
823static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
824 struct snd_ctl_elem_info *info)
825{
826 const char *const names[] = { "None", "CD Player" };
827
828 return snd_ctl_enum_info(info, 1, 2, names);
829}
830
831static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
832 struct snd_ctl_elem_value *value)
833{
834 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
835
836 value->value.enumerated.item[0] = dummy->iobox;
837 return 0;
838}
839
840static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
841 struct snd_ctl_elem_value *value)
842{
843 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
844 int changed;
845
846 if (value->value.enumerated.item[0] > 1)
847 return -EINVAL;
848
849 changed = value->value.enumerated.item[0] != dummy->iobox;
850 if (changed) {
851 dummy->iobox = value->value.enumerated.item[0];
852
853 if (dummy->iobox) {
854 dummy->cd_volume_ctl->vd[0].access &=
855 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
856 dummy->cd_switch_ctl->vd[0].access &=
857 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
858 } else {
859 dummy->cd_volume_ctl->vd[0].access |=
860 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
861 dummy->cd_switch_ctl->vd[0].access |=
862 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
863 }
864
865 snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
866 &dummy->cd_volume_ctl->id);
867 snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
868 &dummy->cd_switch_ctl->id);
869 }
870
871 return changed;
872}
873
820static struct snd_kcontrol_new snd_dummy_controls[] = { 874static struct snd_kcontrol_new snd_dummy_controls[] = {
821DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER), 875DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
822DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER), 876DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
@@ -827,22 +881,37 @@ DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
827DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC), 881DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
828DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC), 882DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
829DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD), 883DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
830DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD) 884DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
885{
886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
887 .name = "External I/O Box",
888 .info = snd_dummy_iobox_info,
889 .get = snd_dummy_iobox_get,
890 .put = snd_dummy_iobox_put,
891},
831}; 892};
832 893
833static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy) 894static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
834{ 895{
835 struct snd_card *card = dummy->card; 896 struct snd_card *card = dummy->card;
897 struct snd_kcontrol *kcontrol;
836 unsigned int idx; 898 unsigned int idx;
837 int err; 899 int err;
838 900
839 spin_lock_init(&dummy->mixer_lock); 901 spin_lock_init(&dummy->mixer_lock);
840 strcpy(card->mixername, "Dummy Mixer"); 902 strcpy(card->mixername, "Dummy Mixer");
903 dummy->iobox = 1;
841 904
842 for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) { 905 for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
843 err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy)); 906 kcontrol = snd_ctl_new1(&snd_dummy_controls[idx], dummy);
907 err = snd_ctl_add(card, kcontrol);
844 if (err < 0) 908 if (err < 0)
845 return err; 909 return err;
910 if (!strcmp(kcontrol->id.name, "CD Volume"))
911 dummy->cd_volume_ctl = kcontrol;
912 else if (!strcmp(kcontrol->id.name, "CD Capture Switch"))
913 dummy->cd_switch_ctl = kcontrol;
914
846 } 915 }
847 return 0; 916 return 0;
848} 917}
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index a38d9643e9d8..affa13480659 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -425,7 +425,7 @@ config SND_WAVEFRONT
425 425
426config SND_MSND_PINNACLE 426config SND_MSND_PINNACLE
427 tristate "Turtle Beach MultiSound Pinnacle/Fiji driver" 427 tristate "Turtle Beach MultiSound Pinnacle/Fiji driver"
428 depends on X86 && EXPERIMENTAL 428 depends on X86
429 select FW_LOADER 429 select FW_LOADER
430 select SND_MPU401_UART 430 select SND_MPU401_UART
431 select SND_PCM 431 select SND_PCM
@@ -438,7 +438,7 @@ config SND_MSND_PINNACLE
438 438
439config SND_MSND_CLASSIC 439config SND_MSND_CLASSIC
440 tristate "Support for Turtle Beach MultiSound Classic, Tahiti, Monterey" 440 tristate "Support for Turtle Beach MultiSound Classic, Tahiti, Monterey"
441 depends on X86 && EXPERIMENTAL 441 depends on X86
442 select FW_LOADER 442 select FW_LOADER
443 select SND_MPU401_UART 443 select SND_MPU401_UART
444 select SND_PCM 444 select SND_PCM
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index f99fa2512286..6150eb1582ae 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -630,7 +630,7 @@ config SND_ICE1724
630 AudioTrak Prodigy 192, 7.1 (HIFI/LT/XT), HD2; Hercules 630 AudioTrak Prodigy 192, 7.1 (HIFI/LT/XT), HD2; Hercules
631 Fortissimo IV; ESI Juli@; Pontis MS300; EGO-SYS WaveTerminal 631 Fortissimo IV; ESI Juli@; Pontis MS300; EGO-SYS WaveTerminal
632 192M; Albatron K8X800 Pro II; Chaintech ZNF3-150/250, 9CJS, 632 192M; Albatron K8X800 Pro II; Chaintech ZNF3-150/250, 9CJS,
633 AV-710; Shuttle SN25P. 633 AV-710; Shuttle SN25P; Philips PSC724 Ultimate Edge.
634 634
635 To compile this driver as a module, choose M here: the module 635 To compile this driver as a module, choose M here: the module
636 will be called snd-ice1724. 636 will be called snd-ice1724.
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index 456a758f04f6..ac9163770013 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -49,14 +49,12 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
49 err = request_firmware(&firmware, fw_name, &dev->dev); 49 err = request_firmware(&firmware, fw_name, &dev->dev);
50 50
51 if (err || !firmware) { 51 if (err || !firmware) {
52 dev_printk(KERN_ERR, &dev->dev, 52 dev_err(&dev->dev, "%d, request_firmware failed for %s\n",
53 "%d, request_firmware failed for %s\n", err, 53 err, fw_name);
54 fw_name);
55 goto error1; 54 goto error1;
56 } 55 }
57 if (firmware->size < sizeof(header)) { 56 if (firmware->size < sizeof(header)) {
58 dev_printk(KERN_ERR, &dev->dev, "Header size too small %s\n", 57 dev_err(&dev->dev, "Header size too small %s\n", fw_name);
59 fw_name);
60 goto error2; 58 goto error2;
61 } 59 }
62 memcpy(&header, firmware->data, sizeof(header)); 60 memcpy(&header, firmware->data, sizeof(header));
@@ -64,7 +62,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
64 if ((header.type != 0x45444F43) || /* "CODE" */ 62 if ((header.type != 0x45444F43) || /* "CODE" */
65 (header.adapter != adapter) 63 (header.adapter != adapter)
66 || (header.size != firmware->size)) { 64 || (header.size != firmware->size)) {
67 dev_printk(KERN_ERR, &dev->dev, 65 dev_err(&dev->dev,
68 "Invalid firmware header size %d != file %zd\n", 66 "Invalid firmware header size %d != file %zd\n",
69 header.size, firmware->size); 67 header.size, firmware->size);
70 goto error2; 68 goto error2;
@@ -72,17 +70,15 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
72 70
73 if ((header.version >> 9) != (HPI_VER >> 9)) { 71 if ((header.version >> 9) != (HPI_VER >> 9)) {
74 /* Consider even and subsequent odd minor versions to be compatible */ 72 /* Consider even and subsequent odd minor versions to be compatible */
75 dev_printk(KERN_ERR, &dev->dev, 73 dev_err(&dev->dev, "Incompatible firmware version DSP image %X != Driver %X\n",
76 "Incompatible firmware version " 74 header.version, HPI_VER);
77 "DSP image %X != Driver %X\n", header.version,
78 HPI_VER);
79 goto error2; 75 goto error2;
80 } 76 }
81 77
82 if (header.version != HPI_VER) { 78 if (header.version != HPI_VER) {
83 dev_printk(KERN_INFO, &dev->dev, 79 dev_info(&dev->dev,
84 "Firmware: release version mismatch DSP image %X != Driver %X\n", 80 "Firmware: release version mismatch DSP image %X != Driver %X\n",
85 header.version, HPI_VER); 81 header.version, HPI_VER);
86 } 82 }
87 83
88 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); 84 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 609156205562..8f9674972376 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -326,7 +326,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
326 pci_dev->subsystem_device, pci_dev->devfn); 326 pci_dev->subsystem_device, pci_dev->devfn);
327 327
328 if (pci_enable_device(pci_dev) < 0) { 328 if (pci_enable_device(pci_dev) < 0) {
329 dev_printk(KERN_ERR, &pci_dev->dev, 329 dev_err(&pci_dev->dev,
330 "pci_enable_device failed, disabling device\n"); 330 "pci_enable_device failed, disabling device\n");
331 return -EIO; 331 return -EIO;
332 } 332 }
@@ -398,9 +398,8 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
398 mutex_init(&adapters[adapter_index].mutex); 398 mutex_init(&adapters[adapter_index].mutex);
399 pci_set_drvdata(pci_dev, &adapters[adapter_index]); 399 pci_set_drvdata(pci_dev, &adapters[adapter_index]);
400 400
401 dev_printk(KERN_INFO, &pci_dev->dev, 401 dev_info(&pci_dev->dev, "probe succeeded for ASI%04X HPI index %d\n",
402 "probe succeeded for ASI%04X HPI index %d\n", 402 adapter.adapter->type, adapter_index);
403 adapter.adapter->type, adapter_index);
404 403
405 return 0; 404 return 0;
406 405
@@ -448,11 +447,11 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
448 447
449 pci_set_drvdata(pci_dev, NULL); 448 pci_set_drvdata(pci_dev, NULL);
450 if (1) 449 if (1)
451 dev_printk(KERN_INFO, &pci_dev->dev, 450 dev_info(&pci_dev->dev,
452 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n", 451 "remove %04x:%04x,%04x:%04x,%04x, HPI index %d\n",
453 pci_dev->vendor, pci_dev->device, 452 pci_dev->vendor, pci_dev->device,
454 pci_dev->subsystem_vendor, pci_dev->subsystem_device, 453 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
455 pci_dev->devfn, pa->adapter->index); 454 pci_dev->devfn, pa->adapter->index);
456 455
457 memset(pa, 0, sizeof(*pa)); 456 memset(pa, 0, sizeof(*pa));
458} 457}
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 525f881f0409..2698abf5d05d 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -2461,7 +2461,12 @@ static irqreturn_t vortex_interrupt(int irq, void *dev_id)
2461#ifndef CHIP_AU8810 2461#ifndef CHIP_AU8810
2462 for (i = 0; i < NR_WT; i++) { 2462 for (i = 0; i < NR_WT; i++) {
2463 if (vortex->dma_wt[i].fifo_status == FIFO_START) { 2463 if (vortex->dma_wt[i].fifo_status == FIFO_START) {
2464 if (vortex_wtdma_bufshift(vortex, i)) ; 2464 /* FIXME: we ignore the return value from
2465 * vortex_wtdma_bufshift() below as the delta
2466 * calculation seems not working for wavetable
2467 * by some reason
2468 */
2469 vortex_wtdma_bufshift(vortex, i);
2465 spin_unlock(&vortex->lock); 2470 spin_unlock(&vortex->lock);
2466 snd_pcm_period_elapsed(vortex->dma_wt[i]. 2471 snd_pcm_period_elapsed(vortex->dma_wt[i].
2467 substream); 2472 substream);
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
index 7105c3de1bca..6eeb8897624b 100644
--- a/sound/pci/hda/Kconfig
+++ b/sound/pci/hda/Kconfig
@@ -37,8 +37,8 @@ config SND_HDA_HWDEP
37 with codecs for debugging purposes. 37 with codecs for debugging purposes.
38 38
39config SND_HDA_RECONFIG 39config SND_HDA_RECONFIG
40 bool "Allow dynamic codec reconfiguration (EXPERIMENTAL)" 40 bool "Allow dynamic codec reconfiguration"
41 depends on SND_HDA_HWDEP && EXPERIMENTAL 41 depends on SND_HDA_HWDEP
42 help 42 help
43 Say Y here to enable the HD-audio codec re-configuration feature. 43 Say Y here to enable the HD-audio codec re-configuration feature.
44 This adds the sysfs interfaces to allow user to clear the whole 44 This adds the sysfs interfaces to allow user to clear the whole
@@ -72,7 +72,6 @@ config SND_HDA_INPUT_JACK
72 72
73config SND_HDA_PATCH_LOADER 73config SND_HDA_PATCH_LOADER
74 bool "Support initialization patch loading for HD-audio" 74 bool "Support initialization patch loading for HD-audio"
75 depends on EXPERIMENTAL
76 select FW_LOADER 75 select FW_LOADER
77 select SND_HDA_HWDEP 76 select SND_HDA_HWDEP
78 select SND_HDA_RECONFIG 77 select SND_HDA_RECONFIG
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index bd4149f1aaf4..24a251497a1f 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -8,6 +8,7 @@ snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
8 8
9# for trace-points 9# for trace-points
10CFLAGS_hda_codec.o := -I$(src) 10CFLAGS_hda_codec.o := -I$(src)
11CFLAGS_hda_intel.o := -I$(src)
11 12
12snd-hda-codec-realtek-objs := patch_realtek.o 13snd-hda-codec-realtek-objs := patch_realtek.o
13snd-hda-codec-cmedia-objs := patch_cmedia.o 14snd-hda-codec-cmedia-objs := patch_cmedia.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 70d4848b5cd0..2da787519513 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1135,6 +1135,19 @@ static void restore_shutup_pins(struct hda_codec *codec)
1135} 1135}
1136#endif 1136#endif
1137 1137
1138static void hda_jackpoll_work(struct work_struct *work)
1139{
1140 struct hda_codec *codec =
1141 container_of(work, struct hda_codec, jackpoll_work.work);
1142 if (!codec->jackpoll_interval)
1143 return;
1144
1145 snd_hda_jack_set_dirty_all(codec);
1146 snd_hda_jack_poll_all(codec);
1147 queue_delayed_work(codec->bus->workq, &codec->jackpoll_work,
1148 codec->jackpoll_interval);
1149}
1150
1138static void init_hda_cache(struct hda_cache_rec *cache, 1151static void init_hda_cache(struct hda_cache_rec *cache,
1139 unsigned int record_size); 1152 unsigned int record_size);
1140static void free_hda_cache(struct hda_cache_rec *cache); 1153static void free_hda_cache(struct hda_cache_rec *cache);
@@ -1190,6 +1203,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1190{ 1203{
1191 if (!codec) 1204 if (!codec)
1192 return; 1205 return;
1206 cancel_delayed_work_sync(&codec->jackpoll_work);
1193 snd_hda_jack_tbl_clear(codec); 1207 snd_hda_jack_tbl_clear(codec);
1194 restore_init_pincfgs(codec); 1208 restore_init_pincfgs(codec);
1195#ifdef CONFIG_PM 1209#ifdef CONFIG_PM
@@ -1273,6 +1287,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
1273 snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); 1287 snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8);
1274 snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); 1288 snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64);
1275 snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); 1289 snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16);
1290 INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
1276 1291
1277#ifdef CONFIG_PM 1292#ifdef CONFIG_PM
1278 spin_lock_init(&codec->power_lock); 1293 spin_lock_init(&codec->power_lock);
@@ -2151,12 +2166,12 @@ EXPORT_SYMBOL_HDA(snd_hda_set_vmaster_tlv);
2151 2166
2152/* find a mixer control element with the given name */ 2167/* find a mixer control element with the given name */
2153static struct snd_kcontrol * 2168static struct snd_kcontrol *
2154_snd_hda_find_mixer_ctl(struct hda_codec *codec, 2169find_mixer_ctl(struct hda_codec *codec, const char *name, int dev, int idx)
2155 const char *name, int idx)
2156{ 2170{
2157 struct snd_ctl_elem_id id; 2171 struct snd_ctl_elem_id id;
2158 memset(&id, 0, sizeof(id)); 2172 memset(&id, 0, sizeof(id));
2159 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2173 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2174 id.device = dev;
2160 id.index = idx; 2175 id.index = idx;
2161 if (snd_BUG_ON(strlen(name) >= sizeof(id.name))) 2176 if (snd_BUG_ON(strlen(name) >= sizeof(id.name)))
2162 return NULL; 2177 return NULL;
@@ -2174,15 +2189,16 @@ _snd_hda_find_mixer_ctl(struct hda_codec *codec,
2174struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, 2189struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
2175 const char *name) 2190 const char *name)
2176{ 2191{
2177 return _snd_hda_find_mixer_ctl(codec, name, 0); 2192 return find_mixer_ctl(codec, name, 0, 0);
2178} 2193}
2179EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); 2194EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl);
2180 2195
2181static int find_empty_mixer_ctl_idx(struct hda_codec *codec, const char *name) 2196static int find_empty_mixer_ctl_idx(struct hda_codec *codec, const char *name,
2197 int dev)
2182{ 2198{
2183 int idx; 2199 int idx;
2184 for (idx = 0; idx < 16; idx++) { /* 16 ctlrs should be large enough */ 2200 for (idx = 0; idx < 16; idx++) { /* 16 ctlrs should be large enough */
2185 if (!_snd_hda_find_mixer_ctl(codec, name, idx)) 2201 if (!find_mixer_ctl(codec, name, dev, idx))
2186 return idx; 2202 return idx;
2187 } 2203 }
2188 return -EBUSY; 2204 return -EBUSY;
@@ -2349,7 +2365,7 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2349 return -EBUSY; 2365 return -EBUSY;
2350 2366
2351 /* OK, let it free */ 2367 /* OK, let it free */
2352 2368 cancel_delayed_work_sync(&codec->jackpoll_work);
2353#ifdef CONFIG_PM 2369#ifdef CONFIG_PM
2354 cancel_delayed_work_sync(&codec->power_work); 2370 cancel_delayed_work_sync(&codec->power_work);
2355 codec->power_on = 0; 2371 codec->power_on = 0;
@@ -3133,26 +3149,48 @@ static struct snd_kcontrol_new dig_mixes[] = {
3133}; 3149};
3134 3150
3135/** 3151/**
3136 * snd_hda_create_spdif_out_ctls - create Output SPDIF-related controls 3152 * snd_hda_create_dig_out_ctls - create Output SPDIF-related controls
3137 * @codec: the HDA codec 3153 * @codec: the HDA codec
3138 * @nid: audio out widget NID 3154 * @associated_nid: NID that new ctls associated with
3139 * 3155 * @cvt_nid: converter NID
3140 * Creates controls related with the SPDIF output. 3156 * @type: HDA_PCM_TYPE_*
3141 * Called from each patch supporting the SPDIF out. 3157 * Creates controls related with the digital output.
3158 * Called from each patch supporting the digital out.
3142 * 3159 *
3143 * Returns 0 if successful, or a negative error code. 3160 * Returns 0 if successful, or a negative error code.
3144 */ 3161 */
3145int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, 3162int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
3146 hda_nid_t associated_nid, 3163 hda_nid_t associated_nid,
3147 hda_nid_t cvt_nid) 3164 hda_nid_t cvt_nid,
3165 int type)
3148{ 3166{
3149 int err; 3167 int err;
3150 struct snd_kcontrol *kctl; 3168 struct snd_kcontrol *kctl;
3151 struct snd_kcontrol_new *dig_mix; 3169 struct snd_kcontrol_new *dig_mix;
3152 int idx; 3170 int idx, dev = 0;
3171 const int spdif_pcm_dev = 1;
3153 struct hda_spdif_out *spdif; 3172 struct hda_spdif_out *spdif;
3154 3173
3155 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch"); 3174 if (codec->primary_dig_out_type == HDA_PCM_TYPE_HDMI &&
3175 type == HDA_PCM_TYPE_SPDIF) {
3176 dev = spdif_pcm_dev;
3177 } else if (codec->primary_dig_out_type == HDA_PCM_TYPE_SPDIF &&
3178 type == HDA_PCM_TYPE_HDMI) {
3179 for (idx = 0; idx < codec->spdif_out.used; idx++) {
3180 spdif = snd_array_elem(&codec->spdif_out, idx);
3181 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
3182 kctl = find_mixer_ctl(codec, dig_mix->name, 0, idx);
3183 if (!kctl)
3184 break;
3185 kctl->id.device = spdif_pcm_dev;
3186 }
3187 }
3188 codec->primary_dig_out_type = HDA_PCM_TYPE_HDMI;
3189 }
3190 if (!codec->primary_dig_out_type)
3191 codec->primary_dig_out_type = type;
3192
3193 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch", dev);
3156 if (idx < 0) { 3194 if (idx < 0) {
3157 printk(KERN_ERR "hda_codec: too many IEC958 outputs\n"); 3195 printk(KERN_ERR "hda_codec: too many IEC958 outputs\n");
3158 return -EBUSY; 3196 return -EBUSY;
@@ -3162,6 +3200,7 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
3162 kctl = snd_ctl_new1(dig_mix, codec); 3200 kctl = snd_ctl_new1(dig_mix, codec);
3163 if (!kctl) 3201 if (!kctl)
3164 return -ENOMEM; 3202 return -ENOMEM;
3203 kctl->id.device = dev;
3165 kctl->id.index = idx; 3204 kctl->id.index = idx;
3166 kctl->private_value = codec->spdif_out.used - 1; 3205 kctl->private_value = codec->spdif_out.used - 1;
3167 err = snd_hda_ctl_add(codec, associated_nid, kctl); 3206 err = snd_hda_ctl_add(codec, associated_nid, kctl);
@@ -3174,7 +3213,7 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
3174 spdif->status = convert_to_spdif_status(spdif->ctls); 3213 spdif->status = convert_to_spdif_status(spdif->ctls);
3175 return 0; 3214 return 0;
3176} 3215}
3177EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls); 3216EXPORT_SYMBOL_HDA(snd_hda_create_dig_out_ctls);
3178 3217
3179/* get the hda_spdif_out entry from the given NID 3218/* get the hda_spdif_out entry from the given NID
3180 * call within spdif_mutex lock 3219 * call within spdif_mutex lock
@@ -3349,7 +3388,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
3349 struct snd_kcontrol_new *dig_mix; 3388 struct snd_kcontrol_new *dig_mix;
3350 int idx; 3389 int idx;
3351 3390
3352 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch"); 3391 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0);
3353 if (idx < 0) { 3392 if (idx < 0) {
3354 printk(KERN_ERR "hda_codec: too many IEC958 inputs\n"); 3393 printk(KERN_ERR "hda_codec: too many IEC958 inputs\n");
3355 return -EBUSY; 3394 return -EBUSY;
@@ -3646,7 +3685,6 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3646 restore_pincfgs(codec); /* restore all current pin configs */ 3685 restore_pincfgs(codec); /* restore all current pin configs */
3647 restore_shutup_pins(codec); 3686 restore_shutup_pins(codec);
3648 hda_exec_init_verbs(codec); 3687 hda_exec_init_verbs(codec);
3649 snd_hda_jack_set_dirty_all(codec);
3650 if (codec->patch_ops.resume) 3688 if (codec->patch_ops.resume)
3651 codec->patch_ops.resume(codec); 3689 codec->patch_ops.resume(codec);
3652 else { 3690 else {
@@ -3655,7 +3693,13 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3655 snd_hda_codec_resume_amp(codec); 3693 snd_hda_codec_resume_amp(codec);
3656 snd_hda_codec_resume_cache(codec); 3694 snd_hda_codec_resume_cache(codec);
3657 } 3695 }
3658 snd_hda_jack_report_sync(codec); 3696
3697 if (codec->jackpoll_interval)
3698 hda_jackpoll_work(&codec->jackpoll_work.work);
3699 else {
3700 snd_hda_jack_set_dirty_all(codec);
3701 snd_hda_jack_report_sync(codec);
3702 }
3659 snd_hda_power_down(codec); /* flag down before returning */ 3703 snd_hda_power_down(codec); /* flag down before returning */
3660} 3704}
3661#endif /* CONFIG_PM */ 3705#endif /* CONFIG_PM */
@@ -3737,7 +3781,10 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)
3737 if (err < 0) 3781 if (err < 0)
3738 return err; 3782 return err;
3739 3783
3740 snd_hda_jack_report_sync(codec); /* call at the last init point */ 3784 if (codec->jackpoll_interval)
3785 hda_jackpoll_work(&codec->jackpoll_work.work);
3786 else
3787 snd_hda_jack_report_sync(codec); /* call at the last init point */
3741 return 0; 3788 return 0;
3742} 3789}
3743 3790
@@ -4449,7 +4496,7 @@ int snd_hda_add_new_ctls(struct hda_codec *codec,
4449 addr = codec->addr; 4496 addr = codec->addr;
4450 else if (!idx && !knew->index) { 4497 else if (!idx && !knew->index) {
4451 idx = find_empty_mixer_ctl_idx(codec, 4498 idx = find_empty_mixer_ctl_idx(codec,
4452 knew->name); 4499 knew->name, 0);
4453 if (idx <= 0) 4500 if (idx <= 0)
4454 return err; 4501 return err;
4455 } else 4502 } else
@@ -5128,6 +5175,7 @@ int snd_hda_suspend(struct hda_bus *bus)
5128 struct hda_codec *codec; 5175 struct hda_codec *codec;
5129 5176
5130 list_for_each_entry(codec, &bus->codec_list, list) { 5177 list_for_each_entry(codec, &bus->codec_list, list) {
5178 cancel_delayed_work_sync(&codec->jackpoll_work);
5131 if (hda_codec_is_power_on(codec)) 5179 if (hda_codec_is_power_on(codec))
5132 hda_call_codec_suspend(codec, false); 5180 hda_call_codec_suspend(codec, false);
5133 } 5181 }
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 507fe8a917b6..62d4229c7b95 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -836,6 +836,7 @@ struct hda_codec {
836 struct mutex hash_mutex; 836 struct mutex hash_mutex;
837 struct snd_array spdif_out; 837 struct snd_array spdif_out;
838 unsigned int spdif_in_enable; /* SPDIF input enable? */ 838 unsigned int spdif_in_enable; /* SPDIF input enable? */
839 int primary_dig_out_type; /* primary digital out PCM type */
839 const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ 840 const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
840 struct snd_array init_pins; /* initial (BIOS) pin configurations */ 841 struct snd_array init_pins; /* initial (BIOS) pin configurations */
841 struct snd_array driver_pins; /* pin configs set by codec parser */ 842 struct snd_array driver_pins; /* pin configs set by codec parser */
@@ -884,6 +885,8 @@ struct hda_codec {
884 885
885 /* jack detection */ 886 /* jack detection */
886 struct snd_array jacktbl; 887 struct snd_array jacktbl;
888 unsigned long jackpoll_interval; /* In jiffies. Zero means no poll, rely on unsol events */
889 struct delayed_work jackpoll_work;
887 890
888#ifdef CONFIG_SND_HDA_INPUT_JACK 891#ifdef CONFIG_SND_HDA_INPUT_JACK
889 /* jack detection */ 892 /* jack detection */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 72b085ae7d46..bffaaeb0b4ba 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -47,6 +47,9 @@
47#include <linux/reboot.h> 47#include <linux/reboot.h>
48#include <linux/io.h> 48#include <linux/io.h>
49#include <linux/pm_runtime.h> 49#include <linux/pm_runtime.h>
50#include <linux/clocksource.h>
51#include <linux/time.h>
52
50#ifdef CONFIG_X86 53#ifdef CONFIG_X86
51/* for snoop control */ 54/* for snoop control */
52#include <asm/pgtable.h> 55#include <asm/pgtable.h>
@@ -68,6 +71,7 @@ static int position_fix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
68static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; 71static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
69static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; 72static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
70static int probe_only[SNDRV_CARDS]; 73static int probe_only[SNDRV_CARDS];
74static int jackpoll_ms[SNDRV_CARDS];
71static bool single_cmd; 75static bool single_cmd;
72static int enable_msi = -1; 76static int enable_msi = -1;
73#ifdef CONFIG_SND_HDA_PATCH_LOADER 77#ifdef CONFIG_SND_HDA_PATCH_LOADER
@@ -95,6 +99,8 @@ module_param_array(probe_mask, int, NULL, 0444);
95MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); 99MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
96module_param_array(probe_only, int, NULL, 0444); 100module_param_array(probe_only, int, NULL, 0444);
97MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization."); 101MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization.");
102module_param_array(jackpoll_ms, int, NULL, 0444);
103MODULE_PARM_DESC(jackpoll_ms, "Ms between polling for jack events (default = 0, using unsol events only)");
98module_param(single_cmd, bool, 0444); 104module_param(single_cmd, bool, 0444);
99MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " 105MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
100 "(for debugging only)."); 106 "(for debugging only).");
@@ -416,6 +422,9 @@ struct azx_dev {
416 unsigned int insufficient :1; 422 unsigned int insufficient :1;
417 unsigned int wc_marked:1; 423 unsigned int wc_marked:1;
418 unsigned int no_period_wakeup:1; 424 unsigned int no_period_wakeup:1;
425
426 struct timecounter azx_tc;
427 struct cyclecounter azx_cc;
419}; 428};
420 429
421/* CORB/RIRB */ 430/* CORB/RIRB */
@@ -518,6 +527,9 @@ struct azx {
518 struct list_head list; 527 struct list_head list;
519}; 528};
520 529
530#define CREATE_TRACE_POINTS
531#include "hda_intel_trace.h"
532
521/* driver types */ 533/* driver types */
522enum { 534enum {
523 AZX_DRIVER_ICH, 535 AZX_DRIVER_ICH,
@@ -829,8 +841,9 @@ static void azx_update_rirb(struct azx *chip)
829 smp_wmb(); 841 smp_wmb();
830 chip->rirb.cmds[addr]--; 842 chip->rirb.cmds[addr]--;
831 } else 843 } else
832 snd_printk(KERN_ERR SFX "spurious response %#x:%#x, " 844 snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, "
833 "last cmd=%#08x\n", 845 "last cmd=%#08x\n",
846 pci_name(chip->pci),
834 res, res_ex, 847 res, res_ex,
835 chip->last_cmd[addr]); 848 chip->last_cmd[addr]);
836 } 849 }
@@ -1582,6 +1595,22 @@ static void azx_bus_reset(struct hda_bus *bus)
1582 bus->in_reset = 0; 1595 bus->in_reset = 0;
1583} 1596}
1584 1597
1598static int get_jackpoll_interval(struct azx *chip)
1599{
1600 int i = jackpoll_ms[chip->dev_index];
1601 unsigned int j;
1602 if (i == 0)
1603 return 0;
1604 if (i < 50 || i > 60000)
1605 j = 0;
1606 else
1607 j = msecs_to_jiffies(i);
1608 if (j == 0)
1609 snd_printk(KERN_WARNING SFX
1610 "jackpoll_ms value out of range: %d\n", i);
1611 return j;
1612}
1613
1585/* 1614/*
1586 * Codec initialization 1615 * Codec initialization
1587 */ 1616 */
@@ -1666,6 +1695,7 @@ static int DELAYED_INIT_MARK azx_codec_create(struct azx *chip, const char *mode
1666 err = snd_hda_codec_new(chip->bus, c, &codec); 1695 err = snd_hda_codec_new(chip->bus, c, &codec);
1667 if (err < 0) 1696 if (err < 0)
1668 continue; 1697 continue;
1698 codec->jackpoll_interval = get_jackpoll_interval(chip);
1669 codec->beep_mode = chip->beep_mode; 1699 codec->beep_mode = chip->beep_mode;
1670 codecs++; 1700 codecs++;
1671 } 1701 }
@@ -1728,6 +1758,64 @@ static inline void azx_release_device(struct azx_dev *azx_dev)
1728 azx_dev->opened = 0; 1758 azx_dev->opened = 0;
1729} 1759}
1730 1760
1761static cycle_t azx_cc_read(const struct cyclecounter *cc)
1762{
1763 struct azx_dev *azx_dev = container_of(cc, struct azx_dev, azx_cc);
1764 struct snd_pcm_substream *substream = azx_dev->substream;
1765 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1766 struct azx *chip = apcm->chip;
1767
1768 return azx_readl(chip, WALLCLK);
1769}
1770
1771static void azx_timecounter_init(struct snd_pcm_substream *substream,
1772 bool force, cycle_t last)
1773{
1774 struct azx_dev *azx_dev = get_azx_dev(substream);
1775 struct timecounter *tc = &azx_dev->azx_tc;
1776 struct cyclecounter *cc = &azx_dev->azx_cc;
1777 u64 nsec;
1778
1779 cc->read = azx_cc_read;
1780 cc->mask = CLOCKSOURCE_MASK(32);
1781
1782 /*
1783 * Converting from 24 MHz to ns means applying a 125/3 factor.
1784 * To avoid any saturation issues in intermediate operations,
1785 * the 125 factor is applied first. The division is applied
1786 * last after reading the timecounter value.
1787 * Applying the 1/3 factor as part of the multiplication
1788 * requires at least 20 bits for a decent precision, however
1789 * overflows occur after about 4 hours or less, not a option.
1790 */
1791
1792 cc->mult = 125; /* saturation after 195 years */
1793 cc->shift = 0;
1794
1795 nsec = 0; /* audio time is elapsed time since trigger */
1796 timecounter_init(tc, cc, nsec);
1797 if (force)
1798 /*
1799 * force timecounter to use predefined value,
1800 * used for synchronized starts
1801 */
1802 tc->cycle_last = last;
1803}
1804
1805static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream,
1806 struct timespec *ts)
1807{
1808 struct azx_dev *azx_dev = get_azx_dev(substream);
1809 u64 nsec;
1810
1811 nsec = timecounter_read(&azx_dev->azx_tc);
1812 nsec = div_u64(nsec, 3); /* can be optimized */
1813
1814 *ts = ns_to_timespec(nsec);
1815
1816 return 0;
1817}
1818
1731static struct snd_pcm_hardware azx_pcm_hw = { 1819static struct snd_pcm_hardware azx_pcm_hw = {
1732 .info = (SNDRV_PCM_INFO_MMAP | 1820 .info = (SNDRV_PCM_INFO_MMAP |
1733 SNDRV_PCM_INFO_INTERLEAVED | 1821 SNDRV_PCM_INFO_INTERLEAVED |
@@ -1737,6 +1825,7 @@ static struct snd_pcm_hardware azx_pcm_hw = {
1737 /* SNDRV_PCM_INFO_RESUME |*/ 1825 /* SNDRV_PCM_INFO_RESUME |*/
1738 SNDRV_PCM_INFO_PAUSE | 1826 SNDRV_PCM_INFO_PAUSE |
1739 SNDRV_PCM_INFO_SYNC_START | 1827 SNDRV_PCM_INFO_SYNC_START |
1828 SNDRV_PCM_INFO_HAS_WALL_CLOCK |
1740 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP), 1829 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
1741 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1830 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1742 .rates = SNDRV_PCM_RATE_48000, 1831 .rates = SNDRV_PCM_RATE_48000,
@@ -1776,6 +1865,12 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1776 runtime->hw.rates = hinfo->rates; 1865 runtime->hw.rates = hinfo->rates;
1777 snd_pcm_limit_hw_rates(runtime); 1866 snd_pcm_limit_hw_rates(runtime);
1778 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 1867 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
1868
1869 /* avoid wrap-around with wall-clock */
1870 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
1871 20,
1872 178000000);
1873
1779 if (chip->align_buffer_size) 1874 if (chip->align_buffer_size)
1780 /* constrain buffer sizes to be multiple of 128 1875 /* constrain buffer sizes to be multiple of 128
1781 bytes. This is more efficient in terms of memory 1876 bytes. This is more efficient in terms of memory
@@ -1815,6 +1910,12 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1815 mutex_unlock(&chip->open_mutex); 1910 mutex_unlock(&chip->open_mutex);
1816 return -EINVAL; 1911 return -EINVAL;
1817 } 1912 }
1913
1914 /* disable WALLCLOCK timestamps for capture streams
1915 until we figure out how to handle digital inputs */
1916 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1917 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK;
1918
1818 spin_lock_irqsave(&chip->reg_lock, flags); 1919 spin_lock_irqsave(&chip->reg_lock, flags);
1819 azx_dev->substream = substream; 1920 azx_dev->substream = substream;
1820 azx_dev->running = 0; 1921 azx_dev->running = 0;
@@ -1961,6 +2062,9 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1961 int rstart = 0, start, nsync = 0, sbits = 0; 2062 int rstart = 0, start, nsync = 0, sbits = 0;
1962 int nwait, timeout; 2063 int nwait, timeout;
1963 2064
2065 azx_dev = get_azx_dev(substream);
2066 trace_azx_pcm_trigger(chip, azx_dev, cmd);
2067
1964 switch (cmd) { 2068 switch (cmd) {
1965 case SNDRV_PCM_TRIGGER_START: 2069 case SNDRV_PCM_TRIGGER_START:
1966 rstart = 1; 2070 rstart = 1;
@@ -2051,6 +2155,22 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
2051 azx_readl(chip, OLD_SSYNC) & ~sbits); 2155 azx_readl(chip, OLD_SSYNC) & ~sbits);
2052 else 2156 else
2053 azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits); 2157 azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits);
2158 if (start) {
2159 azx_timecounter_init(substream, 0, 0);
2160 if (nsync > 1) {
2161 cycle_t cycle_last;
2162
2163 /* same start cycle for master and group */
2164 azx_dev = get_azx_dev(substream);
2165 cycle_last = azx_dev->azx_tc.cycle_last;
2166
2167 snd_pcm_group_for_each_entry(s, substream) {
2168 if (s->pcm->card != substream->pcm->card)
2169 continue;
2170 azx_timecounter_init(s, 1, cycle_last);
2171 }
2172 }
2173 }
2054 spin_unlock(&chip->reg_lock); 2174 spin_unlock(&chip->reg_lock);
2055 return 0; 2175 return 0;
2056} 2176}
@@ -2117,6 +2237,7 @@ static unsigned int azx_get_position(struct azx *chip,
2117{ 2237{
2118 unsigned int pos; 2238 unsigned int pos;
2119 int stream = azx_dev->substream->stream; 2239 int stream = azx_dev->substream->stream;
2240 int delay = 0;
2120 2241
2121 switch (chip->position_fix[stream]) { 2242 switch (chip->position_fix[stream]) {
2122 case POS_FIX_LPIB: 2243 case POS_FIX_LPIB:
@@ -2150,7 +2271,6 @@ static unsigned int azx_get_position(struct azx *chip,
2150 chip->position_fix[stream] == POS_FIX_POSBUF && 2271 chip->position_fix[stream] == POS_FIX_POSBUF &&
2151 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { 2272 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
2152 unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB); 2273 unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB);
2153 int delay;
2154 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 2274 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
2155 delay = pos - lpib_pos; 2275 delay = pos - lpib_pos;
2156 else 2276 else
@@ -2168,6 +2288,7 @@ static unsigned int azx_get_position(struct azx *chip,
2168 azx_dev->substream->runtime->delay = 2288 azx_dev->substream->runtime->delay =
2169 bytes_to_frames(azx_dev->substream->runtime, delay); 2289 bytes_to_frames(azx_dev->substream->runtime, delay);
2170 } 2290 }
2291 trace_azx_get_position(chip, azx_dev, pos, delay);
2171 return pos; 2292 return pos;
2172} 2293}
2173 2294
@@ -2193,13 +2314,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
2193{ 2314{
2194 u32 wallclk; 2315 u32 wallclk;
2195 unsigned int pos; 2316 unsigned int pos;
2196 int stream;
2197 2317
2198 wallclk = azx_readl(chip, WALLCLK) - azx_dev->start_wallclk; 2318 wallclk = azx_readl(chip, WALLCLK) - azx_dev->start_wallclk;
2199 if (wallclk < (azx_dev->period_wallclk * 2) / 3) 2319 if (wallclk < (azx_dev->period_wallclk * 2) / 3)
2200 return -1; /* bogus (too early) interrupt */ 2320 return -1; /* bogus (too early) interrupt */
2201 2321
2202 stream = azx_dev->substream->stream;
2203 pos = azx_get_position(chip, azx_dev, true); 2322 pos = azx_get_position(chip, azx_dev, true);
2204 2323
2205 if (WARN_ONCE(!azx_dev->period_bytes, 2324 if (WARN_ONCE(!azx_dev->period_bytes,
@@ -2290,6 +2409,7 @@ static struct snd_pcm_ops azx_pcm_ops = {
2290 .prepare = azx_pcm_prepare, 2409 .prepare = azx_pcm_prepare,
2291 .trigger = azx_pcm_trigger, 2410 .trigger = azx_pcm_trigger,
2292 .pointer = azx_pcm_pointer, 2411 .pointer = azx_pcm_pointer,
2412 .wall_clock = azx_get_wallclock_tstamp,
2293 .mmap = azx_pcm_mmap, 2413 .mmap = azx_pcm_mmap,
2294 .page = snd_pcm_sgbuf_ops_page, 2414 .page = snd_pcm_sgbuf_ops_page,
2295}; 2415};
diff --git a/sound/pci/hda/hda_intel_trace.h b/sound/pci/hda/hda_intel_trace.h
new file mode 100644
index 000000000000..7b5e4c2cf9d5
--- /dev/null
+++ b/sound/pci/hda/hda_intel_trace.h
@@ -0,0 +1,62 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM hda_intel
3#define TRACE_INCLUDE_FILE hda_intel_trace
4
5#if !defined(_TRACE_HDA_INTEL_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_HDA_INTEL_H
7
8#include <linux/tracepoint.h>
9
10struct azx;
11struct azx_dev;
12
13TRACE_EVENT(azx_pcm_trigger,
14
15 TP_PROTO(struct azx *chip, struct azx_dev *dev, int cmd),
16
17 TP_ARGS(chip, dev, cmd),
18
19 TP_STRUCT__entry(
20 __field( int, card )
21 __field( int, idx )
22 __field( int, cmd )
23 ),
24
25 TP_fast_assign(
26 __entry->card = (chip)->card->number;
27 __entry->idx = (dev)->index;
28 __entry->cmd = cmd;
29 ),
30
31 TP_printk("[%d:%d] cmd=%d", __entry->card, __entry->idx, __entry->cmd)
32);
33
34TRACE_EVENT(azx_get_position,
35
36 TP_PROTO(struct azx *chip, struct azx_dev *dev, unsigned int pos, unsigned int delay),
37
38 TP_ARGS(chip, dev, pos, delay),
39
40 TP_STRUCT__entry(
41 __field( int, card )
42 __field( int, idx )
43 __field( unsigned int, pos )
44 __field( unsigned int, delay )
45 ),
46
47 TP_fast_assign(
48 __entry->card = (chip)->card->number;
49 __entry->idx = (dev)->index;
50 __entry->pos = pos;
51 __entry->delay = delay;
52 ),
53
54 TP_printk("[%d:%d] pos=%u, delay=%u", __entry->card, __entry->idx, __entry->pos, __entry->delay)
55);
56
57#endif /* _TRACE_HDA_INTEL_H */
58
59/* This part must be outside protection */
60#undef TRACE_INCLUDE_PATH
61#define TRACE_INCLUDE_PATH .
62#include <trace/define_trace.h>
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
index 5c690cb873d4..5bdbadaa20fe 100644
--- a/sound/pci/hda/hda_jack.c
+++ b/sound/pci/hda/hda_jack.c
@@ -206,6 +206,8 @@ int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
206 jack->action = action; 206 jack->action = action;
207 if (cb) 207 if (cb)
208 jack->callback = cb; 208 jack->callback = cb;
209 if (codec->jackpoll_interval > 0)
210 return 0; /* No unsol if we're polling instead */
209 return snd_hda_codec_write_cache(codec, nid, 0, 211 return snd_hda_codec_write_cache(codec, nid, 0,
210 AC_VERB_SET_UNSOLICITED_ENABLE, 212 AC_VERB_SET_UNSOLICITED_ENABLE,
211 AC_USRSP_EN | jack->tag); 213 AC_USRSP_EN | jack->tag);
@@ -439,3 +441,25 @@ void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res)
439} 441}
440EXPORT_SYMBOL_HDA(snd_hda_jack_unsol_event); 442EXPORT_SYMBOL_HDA(snd_hda_jack_unsol_event);
441 443
444void snd_hda_jack_poll_all(struct hda_codec *codec)
445{
446 struct hda_jack_tbl *jack = codec->jacktbl.list;
447 int i, changes = 0;
448
449 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
450 unsigned int old_sense;
451 if (!jack->nid || !jack->jack_dirty || jack->phantom_jack)
452 continue;
453 old_sense = get_jack_plug_state(jack->pin_sense);
454 jack_detect_update(codec, jack);
455 if (old_sense == get_jack_plug_state(jack->pin_sense))
456 continue;
457 changes = 1;
458 if (jack->callback)
459 jack->callback(codec, jack);
460 }
461 if (changes)
462 snd_hda_jack_report_sync(codec);
463}
464EXPORT_SYMBOL_HDA(snd_hda_jack_poll_all);
465
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
index af8dd4724da5..4487785adf34 100644
--- a/sound/pci/hda/hda_jack.h
+++ b/sound/pci/hda/hda_jack.h
@@ -84,4 +84,6 @@ void snd_hda_jack_report_sync(struct hda_codec *codec);
84 84
85void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res); 85void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res);
86 86
87void snd_hda_jack_poll_all(struct hda_codec *codec);
88
87#endif /* __SOUND_HDA_JACK_H */ 89#endif /* __SOUND_HDA_JACK_H */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 09dbdc37f781..8c43198b7f56 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -240,9 +240,11 @@ int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
240/* 240/*
241 * SPDIF I/O 241 * SPDIF I/O
242 */ 242 */
243int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, 243int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
244 hda_nid_t associated_nid, 244 hda_nid_t associated_nid,
245 hda_nid_t cvt_nid); 245 hda_nid_t cvt_nid, int type);
246#define snd_hda_create_spdif_out_ctls(codec, anid, cnid) \
247 snd_hda_create_dig_out_ctls(codec, anid, cnid, HDA_PCM_TYPE_SPDIF)
246int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); 248int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
247 249
248/* 250/*
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 61a71131711c..a7f8790ae885 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -873,8 +873,9 @@ static int build_digital_output(struct hda_codec *codec)
873 if (!spec->multiout.dig_out_nid) 873 if (!spec->multiout.dig_out_nid)
874 return 0; 874 return 0;
875 875
876 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid, 876 err = snd_hda_create_dig_out_ctls(codec, spec->multiout.dig_out_nid,
877 spec->multiout.dig_out_nid); 877 spec->multiout.dig_out_nid,
878 spec->pcm_rec[1].pcm_type);
878 if (err < 0) 879 if (err < 0)
879 return err; 880 return err;
880 err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); 881 err = snd_hda_create_spdif_share_sw(codec, &spec->multiout);
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 03b1dc317ff0..252d4197f221 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -4405,7 +4405,10 @@ static const struct hda_codec_ops cx_auto_patch_ops = {
4405enum { 4405enum {
4406 CXT_PINCFG_LENOVO_X200, 4406 CXT_PINCFG_LENOVO_X200,
4407 CXT_PINCFG_LENOVO_TP410, 4407 CXT_PINCFG_LENOVO_TP410,
4408 CXT_PINCFG_LEMOTE_A1004,
4409 CXT_PINCFG_LEMOTE_A1205,
4408 CXT_FIXUP_STEREO_DMIC, 4410 CXT_FIXUP_STEREO_DMIC,
4411 CXT_FIXUP_INC_MIC_BOOST,
4409}; 4412};
4410 4413
4411static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 4414static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
@@ -4415,6 +4418,19 @@ static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
4415 spec->fixup_stereo_dmic = 1; 4418 spec->fixup_stereo_dmic = 1;
4416} 4419}
4417 4420
4421static void cxt5066_increase_mic_boost(struct hda_codec *codec,
4422 const struct hda_fixup *fix, int action)
4423{
4424 if (action != HDA_FIXUP_ACT_PRE_PROBE)
4425 return;
4426
4427 snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
4428 (0x3 << AC_AMPCAP_OFFSET_SHIFT) |
4429 (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4430 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4431 (0 << AC_AMPCAP_MUTE_SHIFT));
4432}
4433
4418/* ThinkPad X200 & co with cxt5051 */ 4434/* ThinkPad X200 & co with cxt5051 */
4419static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 4435static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
4420 { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 4436 { 0x16, 0x042140ff }, /* HP (seq# overridden) */
@@ -4432,6 +4448,18 @@ static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = {
4432 {} 4448 {}
4433}; 4449};
4434 4450
4451/* Lemote A1004/A1205 with cxt5066 */
4452static const struct hda_pintbl cxt_pincfg_lemote[] = {
4453 { 0x1a, 0x90a10020 }, /* Internal mic */
4454 { 0x1b, 0x03a11020 }, /* External mic */
4455 { 0x1d, 0x400101f0 }, /* Not used */
4456 { 0x1e, 0x40a701f0 }, /* Not used */
4457 { 0x20, 0x404501f0 }, /* Not used */
4458 { 0x22, 0x404401f0 }, /* Not used */
4459 { 0x23, 0x40a701f0 }, /* Not used */
4460 {}
4461};
4462
4435static const struct hda_fixup cxt_fixups[] = { 4463static const struct hda_fixup cxt_fixups[] = {
4436 [CXT_PINCFG_LENOVO_X200] = { 4464 [CXT_PINCFG_LENOVO_X200] = {
4437 .type = HDA_FIXUP_PINS, 4465 .type = HDA_FIXUP_PINS,
@@ -4441,10 +4469,24 @@ static const struct hda_fixup cxt_fixups[] = {
4441 .type = HDA_FIXUP_PINS, 4469 .type = HDA_FIXUP_PINS,
4442 .v.pins = cxt_pincfg_lenovo_tp410, 4470 .v.pins = cxt_pincfg_lenovo_tp410,
4443 }, 4471 },
4472 [CXT_PINCFG_LEMOTE_A1004] = {
4473 .type = HDA_FIXUP_PINS,
4474 .chained = true,
4475 .chain_id = CXT_FIXUP_INC_MIC_BOOST,
4476 .v.pins = cxt_pincfg_lemote,
4477 },
4478 [CXT_PINCFG_LEMOTE_A1205] = {
4479 .type = HDA_FIXUP_PINS,
4480 .v.pins = cxt_pincfg_lemote,
4481 },
4444 [CXT_FIXUP_STEREO_DMIC] = { 4482 [CXT_FIXUP_STEREO_DMIC] = {
4445 .type = HDA_FIXUP_FUNC, 4483 .type = HDA_FIXUP_FUNC,
4446 .v.func = cxt_fixup_stereo_dmic, 4484 .v.func = cxt_fixup_stereo_dmic,
4447 }, 4485 },
4486 [CXT_FIXUP_INC_MIC_BOOST] = {
4487 .type = HDA_FIXUP_FUNC,
4488 .v.func = cxt5066_increase_mic_boost,
4489 },
4448}; 4490};
4449 4491
4450static const struct snd_pci_quirk cxt5051_fixups[] = { 4492static const struct snd_pci_quirk cxt5051_fixups[] = {
@@ -4461,6 +4503,8 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
4461 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 4503 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
4462 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 4504 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
4463 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 4505 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
4506 SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
4507 SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
4464 {} 4508 {}
4465}; 4509};
4466 4510
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 71555cc54db1..39ca1005995d 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1589,9 +1589,10 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
1589 if (err < 0) 1589 if (err < 0)
1590 return err; 1590 return err;
1591 1591
1592 err = snd_hda_create_spdif_out_ctls(codec, 1592 err = snd_hda_create_dig_out_ctls(codec,
1593 per_pin->pin_nid, 1593 per_pin->pin_nid,
1594 per_pin->mux_nids[0]); 1594 per_pin->mux_nids[0],
1595 HDA_PCM_TYPE_HDMI);
1595 if (err < 0) 1596 if (err < 0)
1596 return err; 1597 return err;
1597 snd_hda_spdif_ctls_unassign(codec, pin_idx); 1598 snd_hda_spdif_ctls_unassign(codec, pin_idx);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index f7397ad02a0d..96c08792d210 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1836,9 +1836,10 @@ static int __alc_build_controls(struct hda_codec *codec)
1836 return err; 1836 return err;
1837 } 1837 }
1838 if (spec->multiout.dig_out_nid) { 1838 if (spec->multiout.dig_out_nid) {
1839 err = snd_hda_create_spdif_out_ctls(codec, 1839 err = snd_hda_create_dig_out_ctls(codec,
1840 spec->multiout.dig_out_nid, 1840 spec->multiout.dig_out_nid,
1841 spec->multiout.dig_out_nid); 1841 spec->multiout.dig_out_nid,
1842 spec->pcm_rec[1].pcm_type);
1842 if (err < 0) 1843 if (err < 0)
1843 return err; 1844 return err;
1844 if (!spec->no_analog) { 1845 if (!spec->no_analog) {
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 9ba8af056170..962a948f4f10 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1136,9 +1136,10 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1136 } 1136 }
1137 1137
1138 if (spec->multiout.dig_out_nid) { 1138 if (spec->multiout.dig_out_nid) {
1139 err = snd_hda_create_spdif_out_ctls(codec, 1139 err = snd_hda_create_dig_out_ctls(codec,
1140 spec->multiout.dig_out_nid, 1140 spec->multiout.dig_out_nid,
1141 spec->multiout.dig_out_nid); 1141 spec->multiout.dig_out_nid,
1142 spec->autocfg.dig_out_type[0]);
1142 if (err < 0) 1143 if (err < 0)
1143 return err; 1144 return err;
1144 err = snd_hda_create_spdif_share_sw(codec, 1145 err = snd_hda_create_spdif_share_sw(codec,
diff --git a/sound/pci/ice1712/Makefile b/sound/pci/ice1712/Makefile
index f7ce33f00ea5..7e50c1324556 100644
--- a/sound/pci/ice1712/Makefile
+++ b/sound/pci/ice1712/Makefile
@@ -5,7 +5,7 @@
5 5
6snd-ice17xx-ak4xxx-objs := ak4xxx.o 6snd-ice17xx-ak4xxx-objs := ak4xxx.o
7snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o 7snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o
8snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o prodigy_hifi.o juli.o phase.o wtm.o se.o maya44.o quartet.o 8snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o prodigy_hifi.o juli.o phase.o wtm.o se.o maya44.o quartet.o psc724.o wm8766.o wm8776.o
9 9
10# Toplevel Module Dependency 10# Toplevel Module Dependency
11obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o 11obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index e525da2673be..d9bd27b25100 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -21,7 +21,6 @@
21 * 21 *
22 */ 22 */
23 23
24#include <asm/io.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/init.h> 26#include <linux/init.h>
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 20bcddea2eab..ce9941c5e988 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -46,7 +46,6 @@
46 * on mixer switch and other coll stuff. 46 * on mixer switch and other coll stuff.
47 */ 47 */
48 48
49#include <linux/io.h>
50#include <linux/delay.h> 49#include <linux/delay.h>
51#include <linux/interrupt.h> 50#include <linux/interrupt.h>
52#include <linux/init.h> 51#include <linux/init.h>
@@ -203,7 +202,8 @@ static void aureon_pca9554_write(struct snd_ice1712 *ice, unsigned char reg,
203static int aureon_universe_inmux_info(struct snd_kcontrol *kcontrol, 202static int aureon_universe_inmux_info(struct snd_kcontrol *kcontrol,
204 struct snd_ctl_elem_info *uinfo) 203 struct snd_ctl_elem_info *uinfo)
205{ 204{
206 char *texts[3] = {"Internal Aux", "Wavetable", "Rear Line-In"}; 205 static const char * const texts[3] =
206 {"Internal Aux", "Wavetable", "Rear Line-In"};
207 207
208 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 208 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
209 uinfo->count = 1; 209 uinfo->count = 1;
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index 20c6b079d0df..bbef99bf77df 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <asm/io.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/init.h> 27#include <linux/init.h>
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 6fe35b812040..bf289f0a1ed4 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <asm/io.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/init.h> 27#include <linux/init.h>
@@ -576,7 +575,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
576/* i/o sensitivity - this callback is shared among other devices, too */ 575/* i/o sensitivity - this callback is shared among other devices, too */
577static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){ 576static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){
578 577
579 static char *texts[2] = { 578 static const char * const texts[2] = {
580 "+4dBu", "-10dBV", 579 "+4dBu", "-10dBV",
581 }; 580 };
582 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 581 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -899,7 +898,7 @@ static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct s
899 898
900static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 899static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
901{ 900{
902 static char *texts[4] = { 901 static const char * const texts[4] = {
903 "Internal", "Front Input", "Rear Input", "Wave Table" 902 "Internal", "Front Input", "Rear Input", "Wave Table"
904 }; 903 };
905 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 904 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index 6914189073a4..3d84d21e484d 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -21,7 +21,6 @@
21 * 21 *
22 */ 22 */
23 23
24#include <asm/io.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/init.h> 26#include <linux/init.h>
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 5be2e120a14e..dd64e223f5cf 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -47,7 +47,6 @@
47 */ 47 */
48 48
49 49
50#include <linux/io.h>
51#include <linux/delay.h> 50#include <linux/delay.h>
52#include <linux/interrupt.h> 51#include <linux/interrupt.h>
53#include <linux/init.h> 52#include <linux/init.h>
@@ -2686,6 +2685,7 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2686 for (tbl = card_tables; *tbl; tbl++) { 2685 for (tbl = card_tables; *tbl; tbl++) {
2687 for (c = *tbl; c->subvendor; c++) { 2686 for (c = *tbl; c->subvendor; c++) {
2688 if (c->subvendor == ice->eeprom.subvendor) { 2687 if (c->subvendor == ice->eeprom.subvendor) {
2688 ice->card_info = c;
2689 strcpy(card->shortname, c->name); 2689 strcpy(card->shortname, c->name);
2690 if (c->driver) /* specific driver? */ 2690 if (c->driver) /* specific driver? */
2691 strcpy(card->driver, c->driver); 2691 strcpy(card->driver, c->driver);
@@ -2799,7 +2799,12 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2799 2799
2800static void __devexit snd_ice1712_remove(struct pci_dev *pci) 2800static void __devexit snd_ice1712_remove(struct pci_dev *pci)
2801{ 2801{
2802 snd_card_free(pci_get_drvdata(pci)); 2802 struct snd_card *card = pci_get_drvdata(pci);
2803 struct snd_ice1712 *ice = card->private_data;
2804
2805 if (ice->card_info && ice->card_info->chip_exit)
2806 ice->card_info->chip_exit(ice);
2807 snd_card_free(card);
2803 pci_set_drvdata(pci, NULL); 2808 pci_set_drvdata(pci, NULL);
2804} 2809}
2805 2810
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index d0e7d87f09f0..b209fc30b334 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -22,6 +22,7 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/io.h>
25#include <sound/control.h> 26#include <sound/control.h>
26#include <sound/ac97_codec.h> 27#include <sound/ac97_codec.h>
27#include <sound/rawmidi.h> 28#include <sound/rawmidi.h>
@@ -288,6 +289,7 @@ struct snd_ice1712_spdif {
288 } ops; 289 } ops;
289}; 290};
290 291
292struct snd_ice1712_card_info;
291 293
292struct snd_ice1712 { 294struct snd_ice1712 {
293 unsigned long conp_dma_size; 295 unsigned long conp_dma_size;
@@ -324,6 +326,7 @@ struct snd_ice1712 {
324 struct snd_info_entry *proc_entry; 326 struct snd_info_entry *proc_entry;
325 327
326 struct snd_ice1712_eeprom eeprom; 328 struct snd_ice1712_eeprom eeprom;
329 struct snd_ice1712_card_info *card_info;
327 330
328 unsigned int pro_volumes[20]; 331 unsigned int pro_volumes[20];
329 unsigned int omni:1; /* Delta Omni I/O */ 332 unsigned int omni:1; /* Delta Omni I/O */
@@ -381,7 +384,7 @@ struct snd_ice1712 {
381 unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); 384 unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate);
382 int (*set_spdif_clock)(struct snd_ice1712 *ice, int type); 385 int (*set_spdif_clock)(struct snd_ice1712 *ice, int type);
383 int (*get_spdif_master_type)(struct snd_ice1712 *ice); 386 int (*get_spdif_master_type)(struct snd_ice1712 *ice);
384 char **ext_clock_names; 387 const char * const *ext_clock_names;
385 int ext_clock_count; 388 int ext_clock_count;
386 void (*pro_open)(struct snd_ice1712 *, struct snd_pcm_substream *); 389 void (*pro_open)(struct snd_ice1712 *, struct snd_pcm_substream *);
387#ifdef CONFIG_PM_SLEEP 390#ifdef CONFIG_PM_SLEEP
@@ -513,10 +516,11 @@ static inline u8 snd_ice1712_read(struct snd_ice1712 *ice, u8 addr)
513 516
514struct snd_ice1712_card_info { 517struct snd_ice1712_card_info {
515 unsigned int subvendor; 518 unsigned int subvendor;
516 char *name; 519 const char *name;
517 char *model; 520 const char *model;
518 char *driver; 521 const char *driver;
519 int (*chip_init)(struct snd_ice1712 *); 522 int (*chip_init)(struct snd_ice1712 *);
523 void (*chip_exit)(struct snd_ice1712 *);
520 int (*build_controls)(struct snd_ice1712 *); 524 int (*build_controls)(struct snd_ice1712 *);
521 unsigned int no_mpu401:1; 525 unsigned int no_mpu401:1;
522 unsigned int mpu401_1_info_flags; 526 unsigned int mpu401_1_info_flags;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 3050a5279253..58b4b6f85db3 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/io.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/init.h> 27#include <linux/init.h>
@@ -54,6 +53,7 @@
54#include "wtm.h" 53#include "wtm.h"
55#include "se.h" 54#include "se.h"
56#include "quartet.h" 55#include "quartet.h"
56#include "psc724.h"
57 57
58MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 58MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
59MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)"); 59MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)");
@@ -106,7 +106,7 @@ static int PRO_RATE_LOCKED;
106static int PRO_RATE_RESET = 1; 106static int PRO_RATE_RESET = 1;
107static unsigned int PRO_RATE_DEFAULT = 44100; 107static unsigned int PRO_RATE_DEFAULT = 44100;
108 108
109static char *ext_clock_names[1] = { "IEC958 In" }; 109static const char * const ext_clock_names[1] = { "IEC958 In" };
110 110
111/* 111/*
112 * Basic I/O 112 * Basic I/O
@@ -2042,7 +2042,7 @@ static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = {
2042static int snd_vt1724_pro_route_info(struct snd_kcontrol *kcontrol, 2042static int snd_vt1724_pro_route_info(struct snd_kcontrol *kcontrol,
2043 struct snd_ctl_elem_info *uinfo) 2043 struct snd_ctl_elem_info *uinfo)
2044{ 2044{
2045 static char *texts[] = { 2045 static const char * const texts[] = {
2046 "PCM Out", /* 0 */ 2046 "PCM Out", /* 0 */
2047 "H/W In 0", "H/W In 1", /* 1-2 */ 2047 "H/W In 0", "H/W In 1", /* 1-2 */
2048 "IEC958 In L", "IEC958 In R", /* 3-4 */ 2048 "IEC958 In L", "IEC958 In R", /* 3-4 */
@@ -2232,7 +2232,7 @@ static unsigned char ooaoo_sq210_eeprom[] __devinitdata = {
2232}; 2232};
2233 2233
2234 2234
2235struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] __devinitdata = { 2235static struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] __devinitdata = {
2236 { 2236 {
2237 .name = "ooAoo SQ210a", 2237 .name = "ooAoo SQ210a",
2238 .model = "sq210a", 2238 .model = "sq210a",
@@ -2257,6 +2257,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2257 snd_vt1724_se_cards, 2257 snd_vt1724_se_cards,
2258 snd_vt1724_qtet_cards, 2258 snd_vt1724_qtet_cards,
2259 snd_vt1724_ooaoo_cards, 2259 snd_vt1724_ooaoo_cards,
2260 snd_vt1724_psc724_cards,
2260 NULL, 2261 NULL,
2261}; 2262};
2262 2263
@@ -2348,6 +2349,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2348 ice->eeprom.subvendor = c->subvendor; 2349 ice->eeprom.subvendor = c->subvendor;
2349 } else if (c->subvendor != ice->eeprom.subvendor) 2350 } else if (c->subvendor != ice->eeprom.subvendor)
2350 continue; 2351 continue;
2352 ice->card_info = c;
2351 if (!c->eeprom_size || !c->eeprom_data) 2353 if (!c->eeprom_size || !c->eeprom_data)
2352 goto found; 2354 goto found;
2353 /* if the EEPROM is given by the driver, use it */ 2355 /* if the EEPROM is given by the driver, use it */
@@ -2371,7 +2373,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2371 return -EIO; 2373 return -EIO;
2372 } 2374 }
2373 ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05); 2375 ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05);
2374 if (ice->eeprom.version != 2) 2376 if (ice->eeprom.version != 1 && ice->eeprom.version != 2)
2375 printk(KERN_WARNING "ice1724: Invalid EEPROM version %i\n", 2377 printk(KERN_WARNING "ice1724: Invalid EEPROM version %i\n",
2376 ice->eeprom.version); 2378 ice->eeprom.version);
2377 size = ice->eeprom.size - 6; 2379 size = ice->eeprom.size - 6;
@@ -2788,7 +2790,12 @@ __found:
2788 2790
2789static void __devexit snd_vt1724_remove(struct pci_dev *pci) 2791static void __devexit snd_vt1724_remove(struct pci_dev *pci)
2790{ 2792{
2791 snd_card_free(pci_get_drvdata(pci)); 2793 struct snd_card *card = pci_get_drvdata(pci);
2794 struct snd_ice1712 *ice = card->private_data;
2795
2796 if (ice->card_info && ice->card_info->chip_exit)
2797 ice->card_info->chip_exit(ice);
2798 snd_card_free(card);
2792 pci_set_drvdata(pci, NULL); 2799 pci_set_drvdata(pci, NULL);
2793} 2800}
2794 2801
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index 14fd536b6452..a6b23b421512 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -23,7 +23,6 @@
23 * 23 *
24 */ 24 */
25 25
26#include <asm/io.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include <linux/interrupt.h> 27#include <linux/interrupt.h>
29#include <linux/init.h> 28#include <linux/init.h>
@@ -435,7 +434,8 @@ static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card,
435} 434}
436 435
437static void __devinit add_slaves(struct snd_card *card, 436static void __devinit add_slaves(struct snd_card *card,
438 struct snd_kcontrol *master, char **list) 437 struct snd_kcontrol *master,
438 char * const *list)
439{ 439{
440 for (; *list; list++) { 440 for (; *list; list++) {
441 struct snd_kcontrol *slave = ctl_find(card, *list); 441 struct snd_kcontrol *slave = ctl_find(card, *list);
diff --git a/sound/pci/ice1712/maya44.c b/sound/pci/ice1712/maya44.c
index 726fd4b92e19..d8d749e5ed41 100644
--- a/sound/pci/ice1712/maya44.c
+++ b/sound/pci/ice1712/maya44.c
@@ -24,7 +24,6 @@
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/io.h>
28#include <sound/core.h> 27#include <sound/core.h>
29#include <sound/control.h> 28#include <sound/control.h>
30#include <sound/pcm.h> 29#include <sound/pcm.h>
@@ -358,7 +357,7 @@ static void wm8776_select_input(struct snd_maya44 *chip, int idx, int line)
358static int maya_rec_src_info(struct snd_kcontrol *kcontrol, 357static int maya_rec_src_info(struct snd_kcontrol *kcontrol,
359 struct snd_ctl_elem_info *uinfo) 358 struct snd_ctl_elem_info *uinfo)
360{ 359{
361 static char *texts[] = { "Line", "Mic" }; 360 static const char * const texts[] = { "Line", "Mic" };
362 361
363 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 362 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
364 uinfo->count = 1; 363 uinfo->count = 1;
@@ -407,7 +406,7 @@ static int maya_rec_src_put(struct snd_kcontrol *kcontrol,
407static int maya_pb_route_info(struct snd_kcontrol *kcontrol, 406static int maya_pb_route_info(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_info *uinfo) 407 struct snd_ctl_elem_info *uinfo)
409{ 408{
410 static char *texts[] = { 409 static const char * const texts[] = {
411 "PCM Out", /* 0 */ 410 "PCM Out", /* 0 */
412 "Input 1", "Input 2", "Input 3", "Input 4" 411 "Input 1", "Input 2", "Input 3", "Input 4"
413 }; 412 };
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index de29be8c9657..c9be75a457c3 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -42,7 +42,6 @@
42 * Digital receiver: CS8414-CS (supported in this release) 42 * Digital receiver: CS8414-CS (supported in this release)
43 */ 43 */
44 44
45#include <asm/io.h>
46#include <linux/delay.h> 45#include <linux/delay.h>
47#include <linux/interrupt.h> 46#include <linux/interrupt.h>
48#include <linux/init.h> 47#include <linux/init.h>
@@ -722,7 +721,7 @@ static int phase28_deemp_put(struct snd_kcontrol *kcontrol,
722static int phase28_oversampling_info(struct snd_kcontrol *k, 721static int phase28_oversampling_info(struct snd_kcontrol *k,
723 struct snd_ctl_elem_info *uinfo) 722 struct snd_ctl_elem_info *uinfo)
724{ 723{
725 static char *texts[2] = { "128x", "64x" }; 724 static const char * const texts[2] = { "128x", "64x" };
726 725
727 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 726 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
728 uinfo->count = 1; 727 uinfo->count = 1;
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 92c1160d7ab5..3ce1289263a3 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -21,7 +21,6 @@
21 * 21 *
22 */ 22 */
23 23
24#include <asm/io.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/init.h> 26#include <linux/init.h>
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index e36ddb94c382..3fcf581e7ef8 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -54,7 +54,6 @@
54 * 54 *
55 */ 55 */
56 56
57#include <asm/io.h>
58#include <linux/delay.h> 57#include <linux/delay.h>
59#include <linux/interrupt.h> 58#include <linux/interrupt.h>
60#include <linux/init.h> 59#include <linux/init.h>
@@ -283,7 +282,7 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
283static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, 282static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_info *uinfo) 283 struct snd_ctl_elem_info *uinfo)
285{ 284{
286 static char *texts[2] = { "Line In", "Mic" }; 285 static const char * const texts[2] = { "Line In", "Mic" };
287 286
288 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 287 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
289 uinfo->count = 1; 288 uinfo->count = 1;
@@ -562,7 +561,7 @@ static unsigned char prodigy192_ak4114_read(void *private_data,
562static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol, 561static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol,
563 struct snd_ctl_elem_info *uinfo) 562 struct snd_ctl_elem_info *uinfo)
564{ 563{
565 static char *texts[2] = { "Toslink", "Coax" }; 564 static const char * const texts[2] = { "Toslink", "Coax" };
566 565
567 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 566 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
568 uinfo->count = 1; 567 uinfo->count = 1;
diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c
index 7bf093c51ce5..4fea87fb5799 100644
--- a/sound/pci/ice1712/prodigy_hifi.c
+++ b/sound/pci/ice1712/prodigy_hifi.c
@@ -25,7 +25,6 @@
25 */ 25 */
26 26
27 27
28#include <asm/io.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
31#include <linux/init.h> 30#include <linux/init.h>
diff --git a/sound/pci/ice1712/psc724.c b/sound/pci/ice1712/psc724.c
new file mode 100644
index 000000000000..0b6c4e69b8d0
--- /dev/null
+++ b/sound/pci/ice1712/psc724.c
@@ -0,0 +1,464 @@
1/*
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 *
4 * Lowlevel functions for Philips PSC724 Ultimate Edge
5 *
6 * Copyright (c) 2012 Ondrej Zary <linux@rainbow-software.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/delay.h>
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <sound/core.h>
28
29#include "ice1712.h"
30#include "envy24ht.h"
31#include "psc724.h"
32#include "wm8766.h"
33#include "wm8776.h"
34
35struct psc724_spec {
36 struct snd_wm8766 wm8766;
37 struct snd_wm8776 wm8776;
38 bool mute_all, jack_detect;
39 struct snd_ice1712 *ice;
40 struct delayed_work hp_work;
41 bool hp_connected;
42};
43
44/****************************************************************************/
45/* PHILIPS PSC724 ULTIMATE EDGE */
46/****************************************************************************/
47/*
48 * VT1722 (Envy24GT) - 6 outputs, 4 inputs (only 2 used), 24-bit/96kHz
49 *
50 * system configuration ICE_EEP2_SYSCONF=0x42
51 * XIN1 49.152MHz
52 * no MPU401
53 * one stereo ADC, no S/PDIF receiver
54 * three stereo DACs (FRONT, REAR, CENTER+LFE)
55 *
56 * AC-Link configuration ICE_EEP2_ACLINK=0x80
57 * use I2S, not AC97
58 *
59 * I2S converters feature ICE_EEP2_I2S=0x30
60 * I2S codec has no volume/mute control feature (bug!)
61 * I2S codec does not support 96KHz or 192KHz (bug!)
62 * I2S codec 24bits
63 *
64 * S/PDIF configuration ICE_EEP2_SPDIF=0xc1
65 * Enable integrated S/PDIF transmitter
66 * internal S/PDIF out implemented
67 * No S/PDIF input
68 * External S/PDIF out implemented
69 *
70 *
71 * ** connected chips **
72 *
73 * WM8776
74 * 2-channel DAC used for main output and stereo ADC (with 10-channel MUX)
75 * AIN1: LINE IN, AIN2: CD/VIDEO, AIN3: AUX, AIN4: Front MIC, AIN5: Rear MIC
76 * Controlled by I2C using VT1722 I2C interface:
77 * MODE (pin16) -- GND
78 * CE (pin17) -- GND I2C mode (address=0x34)
79 * DI (pin18) -- SDA (VT1722 pin70)
80 * CL (pin19) -- SCLK (VT1722 pin71)
81 *
82 * WM8766
83 * 6-channel DAC used for rear & center/LFE outputs (only 4 channels used)
84 * Controlled by SPI using VT1722 GPIO pins:
85 * MODE (pin 1) -- GPIO19 (VT1722 pin99)
86 * ML/I2S (pin11) -- GPIO18 (VT1722 pin98)
87 * MC/IWL (pin12) -- GPIO17 (VT1722 pin97)
88 * MD/DM (pin13) -- GPIO16 (VT1722 pin96)
89 * MUTE (pin14) -- GPIO20 (VT1722 pin101)
90 *
91 * GPIO14 is used as input for headphone jack detection (1 = connected)
92 * GPIO22 is used as MUTE ALL output, grounding all 6 channels
93 *
94 * ** output pins and device names **
95 *
96 * 5.1ch name -- output connector color -- device (-D option)
97 *
98 * FRONT 2ch -- green -- plughw:0,0
99 * CENTER(Lch) SUBWOOFER(Rch) -- orange -- plughw:0,2,0
100 * REAR 2ch -- black -- plughw:0,2,1
101 */
102
103/* codec access low-level functions */
104
105#define GPIO_HP_JACK (1 << 14)
106#define GPIO_MUTE_SUR (1 << 20)
107#define GPIO_MUTE_ALL (1 << 22)
108
109#define JACK_INTERVAL 1000
110
111#define PSC724_SPI_DELAY 1
112
113#define PSC724_SPI_DATA (1 << 16)
114#define PSC724_SPI_CLK (1 << 17)
115#define PSC724_SPI_LOAD (1 << 18)
116#define PSC724_SPI_MASK (PSC724_SPI_DATA | PSC724_SPI_CLK | PSC724_SPI_LOAD)
117
118static void psc724_wm8766_write(struct snd_wm8766 *wm, u16 addr, u16 data)
119{
120 struct psc724_spec *spec = container_of(wm, struct psc724_spec, wm8766);
121 struct snd_ice1712 *ice = spec->ice;
122 u32 st, bits;
123 int i;
124
125 snd_ice1712_save_gpio_status(ice);
126
127 st = ((addr & 0x7f) << 9) | (data & 0x1ff);
128 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction | PSC724_SPI_MASK);
129 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask & ~PSC724_SPI_MASK);
130 bits = snd_ice1712_gpio_read(ice) & ~PSC724_SPI_MASK;
131 snd_ice1712_gpio_write(ice, bits);
132
133 for (i = 0; i < 16; i++) {
134 udelay(PSC724_SPI_DELAY);
135 bits &= ~PSC724_SPI_CLK;
136 /* MSB first */
137 st <<= 1;
138 if (st & 0x10000)
139 bits |= PSC724_SPI_DATA;
140 else
141 bits &= ~PSC724_SPI_DATA;
142 snd_ice1712_gpio_write(ice, bits);
143 /* CLOCK high */
144 udelay(PSC724_SPI_DELAY);
145 bits |= PSC724_SPI_CLK;
146 snd_ice1712_gpio_write(ice, bits);
147 }
148 /* LOAD high */
149 udelay(PSC724_SPI_DELAY);
150 bits |= PSC724_SPI_LOAD;
151 snd_ice1712_gpio_write(ice, bits);
152 /* LOAD low, DATA and CLOCK high */
153 udelay(PSC724_SPI_DELAY);
154 bits |= (PSC724_SPI_DATA | PSC724_SPI_CLK);
155 snd_ice1712_gpio_write(ice, bits);
156
157 snd_ice1712_restore_gpio_status(ice);
158}
159
160static void psc724_wm8776_write(struct snd_wm8776 *wm, u8 addr, u8 data)
161{
162 struct psc724_spec *spec = container_of(wm, struct psc724_spec, wm8776);
163
164 snd_vt1724_write_i2c(spec->ice, 0x34, addr, data);
165}
166
167/* mute all */
168
169static void psc724_set_master_switch(struct snd_ice1712 *ice, bool on)
170{
171 unsigned int bits = snd_ice1712_gpio_read(ice);
172 struct psc724_spec *spec = ice->spec;
173
174 spec->mute_all = !on;
175 if (on)
176 bits &= ~(GPIO_MUTE_ALL | GPIO_MUTE_SUR);
177 else
178 bits |= GPIO_MUTE_ALL | GPIO_MUTE_SUR;
179 snd_ice1712_gpio_write(ice, bits);
180}
181
182static bool psc724_get_master_switch(struct snd_ice1712 *ice)
183{
184 struct psc724_spec *spec = ice->spec;
185
186 return !spec->mute_all;
187}
188
189/* jack detection */
190
191static void psc724_set_jack_state(struct snd_ice1712 *ice, bool hp_connected)
192{
193 struct psc724_spec *spec = ice->spec;
194 struct snd_ctl_elem_id elem_id;
195 struct snd_kcontrol *kctl;
196 u16 power = spec->wm8776.regs[WM8776_REG_PWRDOWN] & ~WM8776_PWR_HPPD;
197
198 psc724_set_master_switch(ice, !hp_connected);
199 if (!hp_connected)
200 power |= WM8776_PWR_HPPD;
201 snd_wm8776_set_power(&spec->wm8776, power);
202 spec->hp_connected = hp_connected;
203 /* notify about master speaker mute change */
204 memset(&elem_id, 0, sizeof(elem_id));
205 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
206 strncpy(elem_id.name, "Master Speakers Playback Switch",
207 sizeof(elem_id.name));
208 kctl = snd_ctl_find_id(ice->card, &elem_id);
209 snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
210 /* and headphone mute change */
211 strncpy(elem_id.name, spec->wm8776.ctl[WM8776_CTL_HP_SW].name,
212 sizeof(elem_id.name));
213 kctl = snd_ctl_find_id(ice->card, &elem_id);
214 snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
215}
216
217static void psc724_update_hp_jack_state(struct work_struct *work)
218{
219 struct psc724_spec *spec = container_of(work, struct psc724_spec,
220 hp_work.work);
221 struct snd_ice1712 *ice = spec->ice;
222 bool hp_connected = snd_ice1712_gpio_read(ice) & GPIO_HP_JACK;
223
224 schedule_delayed_work(&spec->hp_work, msecs_to_jiffies(JACK_INTERVAL));
225 if (hp_connected == spec->hp_connected)
226 return;
227 psc724_set_jack_state(ice, hp_connected);
228}
229
230static void psc724_set_jack_detection(struct snd_ice1712 *ice, bool on)
231{
232 struct psc724_spec *spec = ice->spec;
233
234 if (spec->jack_detect == on)
235 return;
236
237 spec->jack_detect = on;
238 if (on) {
239 bool hp_connected = snd_ice1712_gpio_read(ice) & GPIO_HP_JACK;
240 psc724_set_jack_state(ice, hp_connected);
241 schedule_delayed_work(&spec->hp_work,
242 msecs_to_jiffies(JACK_INTERVAL));
243 } else
244 cancel_delayed_work_sync(&spec->hp_work);
245}
246
247static bool psc724_get_jack_detection(struct snd_ice1712 *ice)
248{
249 struct psc724_spec *spec = ice->spec;
250
251 return spec->jack_detect;
252}
253
254/* mixer controls */
255
256struct psc724_control {
257 const char *name;
258 void (*set)(struct snd_ice1712 *ice, bool on);
259 bool (*get)(struct snd_ice1712 *ice);
260};
261
262static const struct psc724_control psc724_cont[] = {
263 {
264 .name = "Master Speakers Playback Switch",
265 .set = psc724_set_master_switch,
266 .get = psc724_get_master_switch,
267 },
268 {
269 .name = "Headphone Jack Detection Playback Switch",
270 .set = psc724_set_jack_detection,
271 .get = psc724_get_jack_detection,
272 },
273};
274
275static int psc724_ctl_get(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_value *ucontrol)
277{
278 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
279 int n = kcontrol->private_value;
280
281 ucontrol->value.integer.value[0] = psc724_cont[n].get(ice);
282
283 return 0;
284}
285
286static int psc724_ctl_put(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_value *ucontrol)
288{
289 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
290 int n = kcontrol->private_value;
291
292 psc724_cont[n].set(ice, ucontrol->value.integer.value[0]);
293
294 return 0;
295}
296
297static const char *front_volume = "Front Playback Volume";
298static const char *front_switch = "Front Playback Switch";
299static const char *front_zc = "Front Zero Cross Detect Playback Switch";
300static const char *front_izd = "Front Infinite Zero Detect Playback Switch";
301static const char *front_phase = "Front Phase Invert Playback Switch";
302static const char *front_deemph = "Front Deemphasis Playback Switch";
303static const char *ain1_switch = "Line Capture Switch";
304static const char *ain2_switch = "CD Capture Switch";
305static const char *ain3_switch = "AUX Capture Switch";
306static const char *ain4_switch = "Front Mic Capture Switch";
307static const char *ain5_switch = "Rear Mic Capture Switch";
308static const char *rear_volume = "Surround Playback Volume";
309static const char *clfe_volume = "CLFE Playback Volume";
310static const char *rear_switch = "Surround Playback Switch";
311static const char *clfe_switch = "CLFE Playback Switch";
312static const char *rear_phase = "Surround Phase Invert Playback Switch";
313static const char *clfe_phase = "CLFE Phase Invert Playback Switch";
314static const char *rear_deemph = "Surround Deemphasis Playback Switch";
315static const char *clfe_deemph = "CLFE Deemphasis Playback Switch";
316static const char *rear_clfe_izd = "Rear Infinite Zero Detect Playback Switch";
317static const char *rear_clfe_zc = "Rear Zero Cross Detect Playback Switch";
318
319static int __devinit psc724_add_controls(struct snd_ice1712 *ice)
320{
321 struct snd_kcontrol_new cont;
322 struct snd_kcontrol *ctl;
323 int err, i;
324 struct psc724_spec *spec = ice->spec;
325
326 spec->wm8776.ctl[WM8776_CTL_DAC_VOL].name = front_volume;
327 spec->wm8776.ctl[WM8776_CTL_DAC_SW].name = front_switch;
328 spec->wm8776.ctl[WM8776_CTL_DAC_ZC_SW].name = front_zc;
329 spec->wm8776.ctl[WM8776_CTL_AUX_SW].name = NULL;
330 spec->wm8776.ctl[WM8776_CTL_DAC_IZD_SW].name = front_izd;
331 spec->wm8776.ctl[WM8776_CTL_PHASE_SW].name = front_phase;
332 spec->wm8776.ctl[WM8776_CTL_DEEMPH_SW].name = front_deemph;
333 spec->wm8776.ctl[WM8776_CTL_INPUT1_SW].name = ain1_switch;
334 spec->wm8776.ctl[WM8776_CTL_INPUT2_SW].name = ain2_switch;
335 spec->wm8776.ctl[WM8776_CTL_INPUT3_SW].name = ain3_switch;
336 spec->wm8776.ctl[WM8776_CTL_INPUT4_SW].name = ain4_switch;
337 spec->wm8776.ctl[WM8776_CTL_INPUT5_SW].name = ain5_switch;
338 snd_wm8776_build_controls(&spec->wm8776);
339 spec->wm8766.ctl[WM8766_CTL_CH1_VOL].name = rear_volume;
340 spec->wm8766.ctl[WM8766_CTL_CH2_VOL].name = clfe_volume;
341 spec->wm8766.ctl[WM8766_CTL_CH3_VOL].name = NULL;
342 spec->wm8766.ctl[WM8766_CTL_CH1_SW].name = rear_switch;
343 spec->wm8766.ctl[WM8766_CTL_CH2_SW].name = clfe_switch;
344 spec->wm8766.ctl[WM8766_CTL_CH3_SW].name = NULL;
345 spec->wm8766.ctl[WM8766_CTL_PHASE1_SW].name = rear_phase;
346 spec->wm8766.ctl[WM8766_CTL_PHASE2_SW].name = clfe_phase;
347 spec->wm8766.ctl[WM8766_CTL_PHASE3_SW].name = NULL;
348 spec->wm8766.ctl[WM8766_CTL_DEEMPH1_SW].name = rear_deemph;
349 spec->wm8766.ctl[WM8766_CTL_DEEMPH2_SW].name = clfe_deemph;
350 spec->wm8766.ctl[WM8766_CTL_DEEMPH3_SW].name = NULL;
351 spec->wm8766.ctl[WM8766_CTL_IZD_SW].name = rear_clfe_izd;
352 spec->wm8766.ctl[WM8766_CTL_ZC_SW].name = rear_clfe_zc;
353 snd_wm8766_build_controls(&spec->wm8766);
354
355 memset(&cont, 0, sizeof(cont));
356 cont.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
357 for (i = 0; i < ARRAY_SIZE(psc724_cont); i++) {
358 cont.private_value = i;
359 cont.name = psc724_cont[i].name;
360 cont.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
361 cont.info = snd_ctl_boolean_mono_info;
362 cont.get = psc724_ctl_get;
363 cont.put = psc724_ctl_put;
364 ctl = snd_ctl_new1(&cont, ice);
365 if (!ctl)
366 return -ENOMEM;
367 err = snd_ctl_add(ice->card, ctl);
368 if (err < 0)
369 return err;
370 }
371
372 return 0;
373}
374
375static void psc724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate)
376{
377 struct psc724_spec *spec = ice->spec;
378 /* restore codec volume settings after rate change (PMCLK stop) */
379 snd_wm8776_volume_restore(&spec->wm8776);
380 snd_wm8766_volume_restore(&spec->wm8766);
381}
382
383/* power management */
384
385#ifdef CONFIG_PM_SLEEP
386static int psc724_resume(struct snd_ice1712 *ice)
387{
388 struct psc724_spec *spec = ice->spec;
389
390 snd_wm8776_resume(&spec->wm8776);
391 snd_wm8766_resume(&spec->wm8766);
392
393 return 0;
394}
395#endif
396
397/* init */
398
399static int __devinit psc724_init(struct snd_ice1712 *ice)
400{
401 struct psc724_spec *spec;
402
403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
404 if (!spec)
405 return -ENOMEM;
406 ice->spec = spec;
407 spec->ice = ice;
408
409 ice->num_total_dacs = 6;
410 ice->num_total_adcs = 2;
411 spec->wm8776.ops.write = psc724_wm8776_write;
412 spec->wm8776.card = ice->card;
413 snd_wm8776_init(&spec->wm8776);
414 spec->wm8766.ops.write = psc724_wm8766_write;
415 spec->wm8766.card = ice->card;
416#ifdef CONFIG_PM_SLEEP
417 ice->pm_resume = psc724_resume;
418 ice->pm_suspend_enabled = 1;
419#endif
420 snd_wm8766_init(&spec->wm8766);
421 snd_wm8766_set_if(&spec->wm8766,
422 WM8766_IF_FMT_I2S | WM8766_IF_IWL_24BIT);
423 ice->gpio.set_pro_rate = psc724_set_pro_rate;
424 INIT_DELAYED_WORK(&spec->hp_work, psc724_update_hp_jack_state);
425 psc724_set_jack_detection(ice, true);
426 return 0;
427}
428
429static void psc724_exit(struct snd_ice1712 *ice)
430{
431 struct psc724_spec *spec = ice->spec;
432
433 cancel_delayed_work_sync(&spec->hp_work);
434}
435
436/* PSC724 has buggy EEPROM (no 96&192kHz, all FFh GPIOs), so override it here */
437static unsigned char psc724_eeprom[] __devinitdata = {
438 [ICE_EEP2_SYSCONF] = 0x42, /* 49.152MHz, 1 ADC, 3 DACs */
439 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
440 [ICE_EEP2_I2S] = 0xf0, /* I2S volume, 96kHz, 24bit */
441 [ICE_EEP2_SPDIF] = 0xc1, /* spdif out-en, out-int, no input */
442 /* GPIO outputs */
443 [ICE_EEP2_GPIO_DIR2] = 0x5f, /* MUTE_ALL,WM8766 MUTE/MODE/ML/MC/MD */
444 /* GPIO write enable */
445 [ICE_EEP2_GPIO_MASK] = 0xff, /* read-only */
446 [ICE_EEP2_GPIO_MASK1] = 0xff, /* read-only */
447 [ICE_EEP2_GPIO_MASK2] = 0xa0, /* MUTE_ALL,WM8766 MUTE/MODE/ML/MC/MD */
448 /* GPIO initial state */
449 [ICE_EEP2_GPIO_STATE2] = 0x20, /* unmuted, all WM8766 pins low */
450};
451
452struct snd_ice1712_card_info snd_vt1724_psc724_cards[] __devinitdata = {
453 {
454 .subvendor = VT1724_SUBDEVICE_PSC724,
455 .name = "Philips PSC724 Ultimate Edge",
456 .model = "psc724",
457 .chip_init = psc724_init,
458 .chip_exit = psc724_exit,
459 .build_controls = psc724_add_controls,
460 .eeprom_size = sizeof(psc724_eeprom),
461 .eeprom_data = psc724_eeprom,
462 },
463 {} /*terminator*/
464};
diff --git a/sound/pci/ice1712/psc724.h b/sound/pci/ice1712/psc724.h
new file mode 100644
index 000000000000..858e5fd0eebb
--- /dev/null
+++ b/sound/pci/ice1712/psc724.h
@@ -0,0 +1,13 @@
1#ifndef __SOUND_PSC724_H
2#define __SOUND_PSC724_H
3
4/* ID */
5#define PSC724_DEVICE_DESC \
6 "{Philips,PSC724 Ultimate Edge},"
7
8#define VT1724_SUBDEVICE_PSC724 0xab170619
9
10/* entry struct */
11extern struct snd_ice1712_card_info snd_vt1724_psc724_cards[];
12
13#endif /* __SOUND_PSC724_H */
diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c
index 1948632787e6..c85b2ff79115 100644
--- a/sound/pci/ice1712/quartet.c
+++ b/sound/pci/ice1712/quartet.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <asm/io.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/init.h> 27#include <linux/init.h>
@@ -47,7 +46,7 @@ struct qtet_kcontrol_private {
47 unsigned int bit; 46 unsigned int bit;
48 void (*set_register)(struct snd_ice1712 *ice, unsigned int val); 47 void (*set_register)(struct snd_ice1712 *ice, unsigned int val);
49 unsigned int (*get_register)(struct snd_ice1712 *ice); 48 unsigned int (*get_register)(struct snd_ice1712 *ice);
50 unsigned char *texts[2]; 49 unsigned char * const texts[2];
51}; 50};
52 51
53enum { 52enum {
@@ -63,7 +62,7 @@ enum {
63 OUT34_MON12, 62 OUT34_MON12,
64}; 63};
65 64
66static char *ext_clock_names[3] = {"IEC958 In", "Word Clock 1xFS", 65static const char * const ext_clock_names[3] = {"IEC958 In", "Word Clock 1xFS",
67 "Word Clock 256xFS"}; 66 "Word Clock 256xFS"};
68 67
69/* chip address on I2C bus */ 68/* chip address on I2C bus */
@@ -551,7 +550,8 @@ static int qtet_mute_put(struct snd_kcontrol *kcontrol,
551static int qtet_ain12_enum_info(struct snd_kcontrol *kcontrol, 550static int qtet_ain12_enum_info(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_info *uinfo) 551 struct snd_ctl_elem_info *uinfo)
553{ 552{
554 static char *texts[3] = {"Line In 1/2", "Mic", "Mic + Low-cut"}; 553 static const char * const texts[3] =
554 {"Line In 1/2", "Mic", "Mic + Low-cut"};
555 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 555 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
556 uinfo->count = 1; 556 uinfo->count = 1;
557 uinfo->value.enumerated.items = ARRAY_SIZE(texts); 557 uinfo->value.enumerated.items = ARRAY_SIZE(texts);
@@ -816,7 +816,7 @@ static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card,
816} 816}
817 817
818static void __devinit add_slaves(struct snd_card *card, 818static void __devinit add_slaves(struct snd_card *card,
819 struct snd_kcontrol *master, char **list) 819 struct snd_kcontrol *master, char * const *list)
820{ 820{
821 for (; *list; list++) { 821 for (; *list; list++) {
822 struct snd_kcontrol *slave = ctl_find(card, *list); 822 struct snd_kcontrol *slave = ctl_find(card, *list);
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index b508bb360b97..a1b79758766b 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -21,7 +21,6 @@
21 * 21 *
22 */ 22 */
23 23
24#include <asm/io.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/init.h> 26#include <linux/init.h>
diff --git a/sound/pci/ice1712/se.c b/sound/pci/ice1712/se.c
index 69673b95869d..53b555f5bbea 100644
--- a/sound/pci/ice1712/se.c
+++ b/sound/pci/ice1712/se.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <asm/io.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/init.h> 27#include <linux/init.h>
@@ -253,7 +252,7 @@ static void se200pci_WM8776_set_input_volume(struct snd_ice1712 *ice,
253 se200pci_WM8776_write(ice, 0x0f, vol2 | 0x100); 252 se200pci_WM8776_write(ice, 0x0f, vol2 | 0x100);
254} 253}
255 254
256static const char *se200pci_sel[] = { 255static const char * const se200pci_sel[] = {
257 "LINE-IN", "CD-IN", "MIC-IN", "ALL-MIX", NULL 256 "LINE-IN", "CD-IN", "MIC-IN", "ALL-MIX", NULL
258}; 257};
259 258
@@ -278,7 +277,7 @@ static void se200pci_WM8776_set_afl(struct snd_ice1712 *ice, unsigned int afl)
278 se200pci_WM8776_write(ice, 0x16, 0x001); 277 se200pci_WM8776_write(ice, 0x16, 0x001);
279} 278}
280 279
281static const char *se200pci_agc[] = { 280static const char * const se200pci_agc[] = {
282 "Off", "LimiterMode", "ALCMode", NULL 281 "Off", "LimiterMode", "ALCMode", NULL
283}; 282};
284 283
@@ -352,7 +351,7 @@ static void se200pci_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate)
352} 351}
353 352
354struct se200pci_control { 353struct se200pci_control {
355 char *name; 354 const char *name;
356 enum { 355 enum {
357 WM8766, 356 WM8766,
358 WM8776in, 357 WM8776in,
@@ -363,7 +362,7 @@ struct se200pci_control {
363 } target; 362 } target;
364 enum { VOLUME1, VOLUME2, BOOLEAN, ENUM } type; 363 enum { VOLUME1, VOLUME2, BOOLEAN, ENUM } type;
365 int ch; 364 int ch;
366 const char **member; 365 const char * const *member;
367 const char *comment; 366 const char *comment;
368}; 367};
369 368
@@ -421,7 +420,7 @@ static const struct se200pci_control se200pci_cont[] = {
421 420
422static int se200pci_get_enum_count(int n) 421static int se200pci_get_enum_count(int n)
423{ 422{
424 const char **member; 423 const char * const *member;
425 int c; 424 int c;
426 425
427 member = se200pci_cont[n].member; 426 member = se200pci_cont[n].member;
diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c
index 4c551e147c08..8a0a8393ad9e 100644
--- a/sound/pci/ice1712/vt1720_mobo.c
+++ b/sound/pci/ice1712/vt1720_mobo.c
@@ -21,7 +21,6 @@
21 * 21 *
22 */ 22 */
23 23
24#include <asm/io.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/init.h> 26#include <linux/init.h>
diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c
new file mode 100644
index 000000000000..8072adeecf68
--- /dev/null
+++ b/sound/pci/ice1712/wm8766.c
@@ -0,0 +1,361 @@
1/*
2 * ALSA driver for ICEnsemble VT17xx
3 *
4 * Lowlevel functions for WM8766 codec
5 *
6 * Copyright (c) 2012 Ondrej Zary <linux@rainbow-software.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/delay.h>
25#include <sound/core.h>
26#include <sound/control.h>
27#include <sound/tlv.h>
28#include "wm8766.h"
29
30/* low-level access */
31
32static void snd_wm8766_write(struct snd_wm8766 *wm, u16 addr, u16 data)
33{
34 if (addr < WM8766_REG_RESET)
35 wm->regs[addr] = data;
36 wm->ops.write(wm, addr, data);
37}
38
39/* mixer controls */
40
41static const DECLARE_TLV_DB_SCALE(wm8766_tlv, -12750, 50, 1);
42
43static struct snd_wm8766_ctl snd_wm8766_default_ctl[WM8766_CTL_COUNT] = {
44 [WM8766_CTL_CH1_VOL] = {
45 .name = "Channel 1 Playback Volume",
46 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
47 .tlv = wm8766_tlv,
48 .reg1 = WM8766_REG_DACL1,
49 .reg2 = WM8766_REG_DACR1,
50 .mask1 = WM8766_VOL_MASK,
51 .mask2 = WM8766_VOL_MASK,
52 .max = 0xff,
53 .flags = WM8766_FLAG_STEREO | WM8766_FLAG_VOL_UPDATE,
54 },
55 [WM8766_CTL_CH2_VOL] = {
56 .name = "Channel 2 Playback Volume",
57 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
58 .tlv = wm8766_tlv,
59 .reg1 = WM8766_REG_DACL2,
60 .reg2 = WM8766_REG_DACR2,
61 .mask1 = WM8766_VOL_MASK,
62 .mask2 = WM8766_VOL_MASK,
63 .max = 0xff,
64 .flags = WM8766_FLAG_STEREO | WM8766_FLAG_VOL_UPDATE,
65 },
66 [WM8766_CTL_CH3_VOL] = {
67 .name = "Channel 3 Playback Volume",
68 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
69 .tlv = wm8766_tlv,
70 .reg1 = WM8766_REG_DACL3,
71 .reg2 = WM8766_REG_DACR3,
72 .mask1 = WM8766_VOL_MASK,
73 .mask2 = WM8766_VOL_MASK,
74 .max = 0xff,
75 .flags = WM8766_FLAG_STEREO | WM8766_FLAG_VOL_UPDATE,
76 },
77 [WM8766_CTL_CH1_SW] = {
78 .name = "Channel 1 Playback Switch",
79 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
80 .reg1 = WM8766_REG_DACCTRL2,
81 .mask1 = WM8766_DAC2_MUTE1,
82 .flags = WM8766_FLAG_INVERT,
83 },
84 [WM8766_CTL_CH2_SW] = {
85 .name = "Channel 2 Playback Switch",
86 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
87 .reg1 = WM8766_REG_DACCTRL2,
88 .mask1 = WM8766_DAC2_MUTE2,
89 .flags = WM8766_FLAG_INVERT,
90 },
91 [WM8766_CTL_CH3_SW] = {
92 .name = "Channel 3 Playback Switch",
93 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
94 .reg1 = WM8766_REG_DACCTRL2,
95 .mask1 = WM8766_DAC2_MUTE3,
96 .flags = WM8766_FLAG_INVERT,
97 },
98 [WM8766_CTL_PHASE1_SW] = {
99 .name = "Channel 1 Phase Invert Playback Switch",
100 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
101 .reg1 = WM8766_REG_IFCTRL,
102 .mask1 = WM8766_PHASE_INVERT1,
103 },
104 [WM8766_CTL_PHASE2_SW] = {
105 .name = "Channel 2 Phase Invert Playback Switch",
106 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
107 .reg1 = WM8766_REG_IFCTRL,
108 .mask1 = WM8766_PHASE_INVERT2,
109 },
110 [WM8766_CTL_PHASE3_SW] = {
111 .name = "Channel 3 Phase Invert Playback Switch",
112 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
113 .reg1 = WM8766_REG_IFCTRL,
114 .mask1 = WM8766_PHASE_INVERT3,
115 },
116 [WM8766_CTL_DEEMPH1_SW] = {
117 .name = "Channel 1 Deemphasis Playback Switch",
118 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
119 .reg1 = WM8766_REG_DACCTRL2,
120 .mask1 = WM8766_DAC2_DEEMP1,
121 },
122 [WM8766_CTL_DEEMPH2_SW] = {
123 .name = "Channel 2 Deemphasis Playback Switch",
124 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
125 .reg1 = WM8766_REG_DACCTRL2,
126 .mask1 = WM8766_DAC2_DEEMP2,
127 },
128 [WM8766_CTL_DEEMPH3_SW] = {
129 .name = "Channel 3 Deemphasis Playback Switch",
130 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
131 .reg1 = WM8766_REG_DACCTRL2,
132 .mask1 = WM8766_DAC2_DEEMP3,
133 },
134 [WM8766_CTL_IZD_SW] = {
135 .name = "Infinite Zero Detect Playback Switch",
136 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
137 .reg1 = WM8766_REG_DACCTRL1,
138 .mask1 = WM8766_DAC_IZD,
139 },
140 [WM8766_CTL_ZC_SW] = {
141 .name = "Zero Cross Detect Playback Switch",
142 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
143 .reg1 = WM8766_REG_DACCTRL2,
144 .mask1 = WM8766_DAC2_ZCD,
145 .flags = WM8766_FLAG_INVERT,
146 },
147};
148
149/* exported functions */
150
151void snd_wm8766_init(struct snd_wm8766 *wm)
152{
153 int i;
154 static const u16 default_values[] = {
155 0x000, 0x100,
156 0x120, 0x000,
157 0x000, 0x100, 0x000, 0x100, 0x000,
158 0x000, 0x080,
159 };
160
161 memcpy(wm->ctl, snd_wm8766_default_ctl, sizeof(wm->ctl));
162
163 snd_wm8766_write(wm, WM8766_REG_RESET, 0x00); /* reset */
164 udelay(10);
165 /* load defaults */
166 for (i = 0; i < ARRAY_SIZE(default_values); i++)
167 snd_wm8766_write(wm, i, default_values[i]);
168}
169
170void snd_wm8766_resume(struct snd_wm8766 *wm)
171{
172 int i;
173
174 for (i = 0; i < WM8766_REG_COUNT; i++)
175 snd_wm8766_write(wm, i, wm->regs[i]);
176}
177
178void snd_wm8766_set_if(struct snd_wm8766 *wm, u16 dac)
179{
180 u16 val = wm->regs[WM8766_REG_IFCTRL] & ~WM8766_IF_MASK;
181
182 dac &= WM8766_IF_MASK;
183 snd_wm8766_write(wm, WM8766_REG_IFCTRL, val | dac);
184}
185
186void snd_wm8766_set_master_mode(struct snd_wm8766 *wm, u16 mode)
187{
188 u16 val = wm->regs[WM8766_REG_DACCTRL3] & ~WM8766_DAC3_MSTR_MASK;
189
190 mode &= WM8766_DAC3_MSTR_MASK;
191 snd_wm8766_write(wm, WM8766_REG_DACCTRL3, val | mode);
192}
193
194void snd_wm8766_set_power(struct snd_wm8766 *wm, u16 power)
195{
196 u16 val = wm->regs[WM8766_REG_DACCTRL3] & ~WM8766_DAC3_POWER_MASK;
197
198 power &= WM8766_DAC3_POWER_MASK;
199 snd_wm8766_write(wm, WM8766_REG_DACCTRL3, val | power);
200}
201
202void snd_wm8766_volume_restore(struct snd_wm8766 *wm)
203{
204 u16 val = wm->regs[WM8766_REG_DACR1];
205 /* restore volume after MCLK stopped */
206 snd_wm8766_write(wm, WM8766_REG_DACR1, val | WM8766_VOL_UPDATE);
207}
208
209/* mixer callbacks */
210
211static int snd_wm8766_volume_info(struct snd_kcontrol *kcontrol,
212 struct snd_ctl_elem_info *uinfo)
213{
214 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
215 int n = kcontrol->private_value;
216
217 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
218 uinfo->count = (wm->ctl[n].flags & WM8766_FLAG_STEREO) ? 2 : 1;
219 uinfo->value.integer.min = wm->ctl[n].min;
220 uinfo->value.integer.max = wm->ctl[n].max;
221
222 return 0;
223}
224
225static int snd_wm8766_enum_info(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_info *uinfo)
227{
228 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
229 int n = kcontrol->private_value;
230
231 return snd_ctl_enum_info(uinfo, 1, wm->ctl[n].max,
232 wm->ctl[n].enum_names);
233}
234
235static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_value *ucontrol)
237{
238 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
239 int n = kcontrol->private_value;
240 u16 val1, val2;
241
242 if (wm->ctl[n].get)
243 wm->ctl[n].get(wm, &val1, &val2);
244 else {
245 val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1;
246 val1 >>= __ffs(wm->ctl[n].mask1);
247 if (wm->ctl[n].flags & WM8766_FLAG_STEREO) {
248 val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2;
249 val2 >>= __ffs(wm->ctl[n].mask2);
250 if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE)
251 val2 &= ~WM8766_VOL_UPDATE;
252 }
253 }
254 if (wm->ctl[n].flags & WM8766_FLAG_INVERT) {
255 val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min);
256 val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min);
257 }
258 ucontrol->value.integer.value[0] = val1;
259 if (wm->ctl[n].flags & WM8766_FLAG_STEREO)
260 ucontrol->value.integer.value[1] = val2;
261
262 return 0;
263}
264
265static int snd_wm8766_ctl_put(struct snd_kcontrol *kcontrol,
266 struct snd_ctl_elem_value *ucontrol)
267{
268 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
269 int n = kcontrol->private_value;
270 u16 val, regval1, regval2;
271
272 /* this also works for enum because value is an union */
273 regval1 = ucontrol->value.integer.value[0];
274 regval2 = ucontrol->value.integer.value[1];
275 if (wm->ctl[n].flags & WM8766_FLAG_INVERT) {
276 regval1 = wm->ctl[n].max - (regval1 - wm->ctl[n].min);
277 regval2 = wm->ctl[n].max - (regval2 - wm->ctl[n].min);
278 }
279 if (wm->ctl[n].set)
280 wm->ctl[n].set(wm, regval1, regval2);
281 else {
282 val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1;
283 val |= regval1 << __ffs(wm->ctl[n].mask1);
284 /* both stereo controls in one register */
285 if (wm->ctl[n].flags & WM8766_FLAG_STEREO &&
286 wm->ctl[n].reg1 == wm->ctl[n].reg2) {
287 val &= ~wm->ctl[n].mask2;
288 val |= regval2 << __ffs(wm->ctl[n].mask2);
289 }
290 snd_wm8766_write(wm, wm->ctl[n].reg1, val);
291 /* stereo controls in different registers */
292 if (wm->ctl[n].flags & WM8766_FLAG_STEREO &&
293 wm->ctl[n].reg1 != wm->ctl[n].reg2) {
294 val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2;
295 val |= regval2 << __ffs(wm->ctl[n].mask2);
296 if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE)
297 val |= WM8766_VOL_UPDATE;
298 snd_wm8766_write(wm, wm->ctl[n].reg2, val);
299 }
300 }
301
302 return 0;
303}
304
305static int snd_wm8766_add_control(struct snd_wm8766 *wm, int num)
306{
307 struct snd_kcontrol_new cont;
308 struct snd_kcontrol *ctl;
309
310 memset(&cont, 0, sizeof(cont));
311 cont.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
312 cont.private_value = num;
313 cont.name = wm->ctl[num].name;
314 cont.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
315 if (wm->ctl[num].flags & WM8766_FLAG_LIM ||
316 wm->ctl[num].flags & WM8766_FLAG_ALC)
317 cont.access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
318 cont.tlv.p = NULL;
319 cont.get = snd_wm8766_ctl_get;
320 cont.put = snd_wm8766_ctl_put;
321
322 switch (wm->ctl[num].type) {
323 case SNDRV_CTL_ELEM_TYPE_INTEGER:
324 cont.info = snd_wm8766_volume_info;
325 cont.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
326 cont.tlv.p = wm->ctl[num].tlv;
327 break;
328 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
329 wm->ctl[num].max = 1;
330 if (wm->ctl[num].flags & WM8766_FLAG_STEREO)
331 cont.info = snd_ctl_boolean_stereo_info;
332 else
333 cont.info = snd_ctl_boolean_mono_info;
334 break;
335 case SNDRV_CTL_ELEM_TYPE_ENUMERATED:
336 cont.info = snd_wm8766_enum_info;
337 break;
338 default:
339 return -EINVAL;
340 }
341 ctl = snd_ctl_new1(&cont, wm);
342 if (!ctl)
343 return -ENOMEM;
344 wm->ctl[num].kctl = ctl;
345
346 return snd_ctl_add(wm->card, ctl);
347}
348
349int snd_wm8766_build_controls(struct snd_wm8766 *wm)
350{
351 int err, i;
352
353 for (i = 0; i < WM8766_CTL_COUNT; i++)
354 if (wm->ctl[i].name) {
355 err = snd_wm8766_add_control(wm, i);
356 if (err < 0)
357 return err;
358 }
359
360 return 0;
361}
diff --git a/sound/pci/ice1712/wm8766.h b/sound/pci/ice1712/wm8766.h
new file mode 100644
index 000000000000..c119f84bd2c2
--- /dev/null
+++ b/sound/pci/ice1712/wm8766.h
@@ -0,0 +1,163 @@
1#ifndef __SOUND_WM8766_H
2#define __SOUND_WM8766_H
3
4/*
5 * ALSA driver for ICEnsemble VT17xx
6 *
7 * Lowlevel functions for WM8766 codec
8 *
9 * Copyright (c) 2012 Ondrej Zary <linux@rainbow-software.org>
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; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#define WM8766_REG_DACL1 0x00
28#define WM8766_REG_DACR1 0x01
29#define WM8766_VOL_MASK 0x1ff /* incl. update bit */
30#define WM8766_VOL_UPDATE (1 << 8) /* update volume */
31#define WM8766_REG_DACCTRL1 0x02
32#define WM8766_DAC_MUTEALL (1 << 0)
33#define WM8766_DAC_DEEMPALL (1 << 1)
34#define WM8766_DAC_PDWN (1 << 2)
35#define WM8766_DAC_ATC (1 << 3)
36#define WM8766_DAC_IZD (1 << 4)
37#define WM8766_DAC_PL_MASK 0x1e0
38#define WM8766_DAC_PL_LL (1 << 5) /* L chan: L signal */
39#define WM8766_DAC_PL_LR (2 << 5) /* L chan: R signal */
40#define WM8766_DAC_PL_LB (3 << 5) /* L chan: both */
41#define WM8766_DAC_PL_RL (1 << 7) /* R chan: L signal */
42#define WM8766_DAC_PL_RR (2 << 7) /* R chan: R signal */
43#define WM8766_DAC_PL_RB (3 << 7) /* R chan: both */
44#define WM8766_REG_IFCTRL 0x03
45#define WM8766_IF_FMT_RIGHTJ (0 << 0)
46#define WM8766_IF_FMT_LEFTJ (1 << 0)
47#define WM8766_IF_FMT_I2S (2 << 0)
48#define WM8766_IF_FMT_DSP (3 << 0)
49#define WM8766_IF_DSP_LATE (1 << 2) /* in DSP mode */
50#define WM8766_IF_LRC_INVERTED (1 << 2) /* in other modes */
51#define WM8766_IF_BCLK_INVERTED (1 << 3)
52#define WM8766_IF_IWL_16BIT (0 << 4)
53#define WM8766_IF_IWL_20BIT (1 << 4)
54#define WM8766_IF_IWL_24BIT (2 << 4)
55#define WM8766_IF_IWL_32BIT (3 << 4)
56#define WM8766_IF_MASK 0x3f
57#define WM8766_PHASE_INVERT1 (1 << 6)
58#define WM8766_PHASE_INVERT2 (1 << 7)
59#define WM8766_PHASE_INVERT3 (1 << 8)
60#define WM8766_REG_DACL2 0x04
61#define WM8766_REG_DACR2 0x05
62#define WM8766_REG_DACL3 0x06
63#define WM8766_REG_DACR3 0x07
64#define WM8766_REG_MASTDA 0x08
65#define WM8766_REG_DACCTRL2 0x09
66#define WM8766_DAC2_ZCD (1 << 0)
67#define WM8766_DAC2_ZFLAG_ALL (0 << 1)
68#define WM8766_DAC2_ZFLAG_1 (1 << 1)
69#define WM8766_DAC2_ZFLAG_2 (2 << 1)
70#define WM8766_DAC2_ZFLAG_3 (3 << 1)
71#define WM8766_DAC2_MUTE1 (1 << 3)
72#define WM8766_DAC2_MUTE2 (1 << 4)
73#define WM8766_DAC2_MUTE3 (1 << 5)
74#define WM8766_DAC2_DEEMP1 (1 << 6)
75#define WM8766_DAC2_DEEMP2 (1 << 7)
76#define WM8766_DAC2_DEEMP3 (1 << 8)
77#define WM8766_REG_DACCTRL3 0x0a
78#define WM8766_DAC3_DACPD1 (1 << 1)
79#define WM8766_DAC3_DACPD2 (1 << 2)
80#define WM8766_DAC3_DACPD3 (1 << 3)
81#define WM8766_DAC3_PWRDNALL (1 << 4)
82#define WM8766_DAC3_POWER_MASK 0x1e
83#define WM8766_DAC3_MASTER (1 << 5)
84#define WM8766_DAC3_DAC128FS (0 << 6)
85#define WM8766_DAC3_DAC192FS (1 << 6)
86#define WM8766_DAC3_DAC256FS (2 << 6)
87#define WM8766_DAC3_DAC384FS (3 << 6)
88#define WM8766_DAC3_DAC512FS (4 << 6)
89#define WM8766_DAC3_DAC768FS (5 << 6)
90#define WM8766_DAC3_MSTR_MASK 0x1e0
91#define WM8766_REG_MUTE1 0x0c
92#define WM8766_MUTE1_MPD (1 << 6)
93#define WM8766_REG_MUTE2 0x0f
94#define WM8766_MUTE2_MPD (1 << 5)
95#define WM8766_REG_RESET 0x1f
96
97#define WM8766_REG_COUNT 0x10 /* don't cache the RESET register */
98
99struct snd_wm8766;
100
101struct snd_wm8766_ops {
102 void (*write)(struct snd_wm8766 *wm, u16 addr, u16 data);
103};
104
105enum snd_wm8766_ctl_id {
106 WM8766_CTL_CH1_VOL,
107 WM8766_CTL_CH2_VOL,
108 WM8766_CTL_CH3_VOL,
109 WM8766_CTL_CH1_SW,
110 WM8766_CTL_CH2_SW,
111 WM8766_CTL_CH3_SW,
112 WM8766_CTL_PHASE1_SW,
113 WM8766_CTL_PHASE2_SW,
114 WM8766_CTL_PHASE3_SW,
115 WM8766_CTL_DEEMPH1_SW,
116 WM8766_CTL_DEEMPH2_SW,
117 WM8766_CTL_DEEMPH3_SW,
118 WM8766_CTL_IZD_SW,
119 WM8766_CTL_ZC_SW,
120
121 WM8766_CTL_COUNT,
122};
123
124#define WM8766_ENUM_MAX 16
125
126#define WM8766_FLAG_STEREO (1 << 0)
127#define WM8766_FLAG_VOL_UPDATE (1 << 1)
128#define WM8766_FLAG_INVERT (1 << 2)
129#define WM8766_FLAG_LIM (1 << 3)
130#define WM8766_FLAG_ALC (1 << 4)
131
132struct snd_wm8766_ctl {
133 struct snd_kcontrol *kctl;
134 const char *name;
135 snd_ctl_elem_type_t type;
136 const char *const enum_names[WM8766_ENUM_MAX];
137 const unsigned int *tlv;
138 u16 reg1, reg2, mask1, mask2, min, max, flags;
139 void (*set)(struct snd_wm8766 *wm, u16 ch1, u16 ch2);
140 void (*get)(struct snd_wm8766 *wm, u16 *ch1, u16 *ch2);
141};
142
143enum snd_wm8766_agc_mode { WM8766_AGC_OFF, WM8766_AGC_LIM, WM8766_AGC_ALC };
144
145struct snd_wm8766 {
146 struct snd_card *card;
147 struct snd_wm8766_ctl ctl[WM8766_CTL_COUNT];
148 enum snd_wm8766_agc_mode agc_mode;
149 struct snd_wm8766_ops ops;
150 u16 regs[WM8766_REG_COUNT]; /* 9-bit registers */
151};
152
153
154
155void snd_wm8766_init(struct snd_wm8766 *wm);
156void snd_wm8766_resume(struct snd_wm8766 *wm);
157void snd_wm8766_set_if(struct snd_wm8766 *wm, u16 dac);
158void snd_wm8766_set_master_mode(struct snd_wm8766 *wm, u16 mode);
159void snd_wm8766_set_power(struct snd_wm8766 *wm, u16 power);
160void snd_wm8766_volume_restore(struct snd_wm8766 *wm);
161int snd_wm8766_build_controls(struct snd_wm8766 *wm);
162
163#endif /* __SOUND_WM8766_H */
diff --git a/sound/pci/ice1712/wm8776.c b/sound/pci/ice1712/wm8776.c
new file mode 100644
index 000000000000..a3c05fe5daf9
--- /dev/null
+++ b/sound/pci/ice1712/wm8776.c
@@ -0,0 +1,633 @@
1/*
2 * ALSA driver for ICEnsemble VT17xx
3 *
4 * Lowlevel functions for WM8776 codec
5 *
6 * Copyright (c) 2012 Ondrej Zary <linux@rainbow-software.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/delay.h>
25#include <sound/core.h>
26#include <sound/control.h>
27#include <sound/tlv.h>
28#include "wm8776.h"
29
30/* low-level access */
31
32static void snd_wm8776_write(struct snd_wm8776 *wm, u16 addr, u16 data)
33{
34 u8 bus_addr = addr << 1 | data >> 8; /* addr + 9th data bit */
35 u8 bus_data = data & 0xff; /* remaining 8 data bits */
36
37 if (addr < WM8776_REG_RESET)
38 wm->regs[addr] = data;
39 wm->ops.write(wm, bus_addr, bus_data);
40}
41
42/* register-level functions */
43
44static void snd_wm8776_activate_ctl(struct snd_wm8776 *wm,
45 const char *ctl_name,
46 bool active)
47{
48 struct snd_card *card = wm->card;
49 struct snd_kcontrol *kctl;
50 struct snd_kcontrol_volatile *vd;
51 struct snd_ctl_elem_id elem_id;
52 unsigned int index_offset;
53
54 memset(&elem_id, 0, sizeof(elem_id));
55 strncpy(elem_id.name, ctl_name, sizeof(elem_id.name));
56 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
57 kctl = snd_ctl_find_id(card, &elem_id);
58 if (!kctl)
59 return;
60 index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
61 vd = &kctl->vd[index_offset];
62 if (active)
63 vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
64 else
65 vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
66 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id);
67}
68
69static void snd_wm8776_update_agc_ctl(struct snd_wm8776 *wm)
70{
71 int i, flags_on = 0, flags_off = 0;
72
73 switch (wm->agc_mode) {
74 case WM8776_AGC_OFF:
75 flags_off = WM8776_FLAG_LIM | WM8776_FLAG_ALC;
76 break;
77 case WM8776_AGC_LIM:
78 flags_off = WM8776_FLAG_ALC;
79 flags_on = WM8776_FLAG_LIM;
80 break;
81 case WM8776_AGC_ALC_R:
82 case WM8776_AGC_ALC_L:
83 case WM8776_AGC_ALC_STEREO:
84 flags_off = WM8776_FLAG_LIM;
85 flags_on = WM8776_FLAG_ALC;
86 break;
87 }
88
89 for (i = 0; i < WM8776_CTL_COUNT; i++)
90 if (wm->ctl[i].flags & flags_off)
91 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, false);
92 else if (wm->ctl[i].flags & flags_on)
93 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, true);
94}
95
96static void snd_wm8776_set_agc(struct snd_wm8776 *wm, u16 agc, u16 nothing)
97{
98 u16 alc1 = wm->regs[WM8776_REG_ALCCTRL1] & ~WM8776_ALC1_LCT_MASK;
99 u16 alc2 = wm->regs[WM8776_REG_ALCCTRL2] & ~WM8776_ALC2_LCEN;
100
101 switch (agc) {
102 case 0: /* Off */
103 wm->agc_mode = WM8776_AGC_OFF;
104 break;
105 case 1: /* Limiter */
106 alc2 |= WM8776_ALC2_LCEN;
107 wm->agc_mode = WM8776_AGC_LIM;
108 break;
109 case 2: /* ALC Right */
110 alc1 |= WM8776_ALC1_LCSEL_ALCR;
111 alc2 |= WM8776_ALC2_LCEN;
112 wm->agc_mode = WM8776_AGC_ALC_R;
113 break;
114 case 3: /* ALC Left */
115 alc1 |= WM8776_ALC1_LCSEL_ALCL;
116 alc2 |= WM8776_ALC2_LCEN;
117 wm->agc_mode = WM8776_AGC_ALC_L;
118 break;
119 case 4: /* ALC Stereo */
120 alc1 |= WM8776_ALC1_LCSEL_ALCSTEREO;
121 alc2 |= WM8776_ALC2_LCEN;
122 wm->agc_mode = WM8776_AGC_ALC_STEREO;
123 break;
124 }
125 snd_wm8776_write(wm, WM8776_REG_ALCCTRL1, alc1);
126 snd_wm8776_write(wm, WM8776_REG_ALCCTRL2, alc2);
127 snd_wm8776_update_agc_ctl(wm);
128}
129
130static void snd_wm8776_get_agc(struct snd_wm8776 *wm, u16 *mode, u16 *nothing)
131{
132 *mode = wm->agc_mode;
133}
134
135/* mixer controls */
136
137static const DECLARE_TLV_DB_SCALE(wm8776_hp_tlv, -7400, 100, 1);
138static const DECLARE_TLV_DB_SCALE(wm8776_dac_tlv, -12750, 50, 1);
139static const DECLARE_TLV_DB_SCALE(wm8776_adc_tlv, -10350, 50, 1);
140static const DECLARE_TLV_DB_SCALE(wm8776_lct_tlv, -1600, 100, 0);
141static const DECLARE_TLV_DB_SCALE(wm8776_maxgain_tlv, 0, 400, 0);
142static const DECLARE_TLV_DB_SCALE(wm8776_ngth_tlv, -7800, 600, 0);
143static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_lim_tlv, -1200, 100, 0);
144static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_alc_tlv, -2100, 400, 0);
145
146static struct snd_wm8776_ctl snd_wm8776_default_ctl[WM8776_CTL_COUNT] = {
147 [WM8776_CTL_DAC_VOL] = {
148 .name = "Master Playback Volume",
149 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
150 .tlv = wm8776_dac_tlv,
151 .reg1 = WM8776_REG_DACLVOL,
152 .reg2 = WM8776_REG_DACRVOL,
153 .mask1 = WM8776_DACVOL_MASK,
154 .mask2 = WM8776_DACVOL_MASK,
155 .max = 0xff,
156 .flags = WM8776_FLAG_STEREO | WM8776_FLAG_VOL_UPDATE,
157 },
158 [WM8776_CTL_DAC_SW] = {
159 .name = "Master Playback Switch",
160 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
161 .reg1 = WM8776_REG_DACCTRL1,
162 .reg2 = WM8776_REG_DACCTRL1,
163 .mask1 = WM8776_DAC_PL_LL,
164 .mask2 = WM8776_DAC_PL_RR,
165 .flags = WM8776_FLAG_STEREO,
166 },
167 [WM8776_CTL_DAC_ZC_SW] = {
168 .name = "Master Zero Cross Detect Playback Switch",
169 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
170 .reg1 = WM8776_REG_DACCTRL1,
171 .mask1 = WM8776_DAC_DZCEN,
172 },
173 [WM8776_CTL_HP_VOL] = {
174 .name = "Headphone Playback Volume",
175 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
176 .tlv = wm8776_hp_tlv,
177 .reg1 = WM8776_REG_HPLVOL,
178 .reg2 = WM8776_REG_HPRVOL,
179 .mask1 = WM8776_HPVOL_MASK,
180 .mask2 = WM8776_HPVOL_MASK,
181 .min = 0x2f,
182 .max = 0x7f,
183 .flags = WM8776_FLAG_STEREO | WM8776_FLAG_VOL_UPDATE,
184 },
185 [WM8776_CTL_HP_SW] = {
186 .name = "Headphone Playback Switch",
187 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
188 .reg1 = WM8776_REG_PWRDOWN,
189 .mask1 = WM8776_PWR_HPPD,
190 .flags = WM8776_FLAG_INVERT,
191 },
192 [WM8776_CTL_HP_ZC_SW] = {
193 .name = "Headphone Zero Cross Detect Playback Switch",
194 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
195 .reg1 = WM8776_REG_HPLVOL,
196 .reg2 = WM8776_REG_HPRVOL,
197 .mask1 = WM8776_VOL_HPZCEN,
198 .mask2 = WM8776_VOL_HPZCEN,
199 .flags = WM8776_FLAG_STEREO,
200 },
201 [WM8776_CTL_AUX_SW] = {
202 .name = "AUX Playback Switch",
203 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
204 .reg1 = WM8776_REG_OUTMUX,
205 .mask1 = WM8776_OUTMUX_AUX,
206 },
207 [WM8776_CTL_BYPASS_SW] = {
208 .name = "Bypass Playback Switch",
209 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
210 .reg1 = WM8776_REG_OUTMUX,
211 .mask1 = WM8776_OUTMUX_BYPASS,
212 },
213 [WM8776_CTL_DAC_IZD_SW] = {
214 .name = "Infinite Zero Detect Playback Switch",
215 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
216 .reg1 = WM8776_REG_DACCTRL1,
217 .mask1 = WM8776_DAC_IZD,
218 },
219 [WM8776_CTL_PHASE_SW] = {
220 .name = "Phase Invert Playback Switch",
221 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
222 .reg1 = WM8776_REG_PHASESWAP,
223 .reg2 = WM8776_REG_PHASESWAP,
224 .mask1 = WM8776_PHASE_INVERTL,
225 .mask2 = WM8776_PHASE_INVERTR,
226 .flags = WM8776_FLAG_STEREO,
227 },
228 [WM8776_CTL_DEEMPH_SW] = {
229 .name = "Deemphasis Playback Switch",
230 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
231 .reg1 = WM8776_REG_DACCTRL2,
232 .mask1 = WM8776_DAC2_DEEMPH,
233 },
234 [WM8776_CTL_ADC_VOL] = {
235 .name = "Input Capture Volume",
236 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
237 .tlv = wm8776_adc_tlv,
238 .reg1 = WM8776_REG_ADCLVOL,
239 .reg2 = WM8776_REG_ADCRVOL,
240 .mask1 = WM8776_ADC_GAIN_MASK,
241 .mask2 = WM8776_ADC_GAIN_MASK,
242 .max = 0xff,
243 .flags = WM8776_FLAG_STEREO | WM8776_FLAG_VOL_UPDATE,
244 },
245 [WM8776_CTL_ADC_SW] = {
246 .name = "Input Capture Switch",
247 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
248 .reg1 = WM8776_REG_ADCMUX,
249 .reg2 = WM8776_REG_ADCMUX,
250 .mask1 = WM8776_ADC_MUTEL,
251 .mask2 = WM8776_ADC_MUTER,
252 .flags = WM8776_FLAG_STEREO | WM8776_FLAG_INVERT,
253 },
254 [WM8776_CTL_INPUT1_SW] = {
255 .name = "AIN1 Capture Switch",
256 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
257 .reg1 = WM8776_REG_ADCMUX,
258 .mask1 = WM8776_ADC_MUX_AIN1,
259 },
260 [WM8776_CTL_INPUT2_SW] = {
261 .name = "AIN2 Capture Switch",
262 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
263 .reg1 = WM8776_REG_ADCMUX,
264 .mask1 = WM8776_ADC_MUX_AIN2,
265 },
266 [WM8776_CTL_INPUT3_SW] = {
267 .name = "AIN3 Capture Switch",
268 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
269 .reg1 = WM8776_REG_ADCMUX,
270 .mask1 = WM8776_ADC_MUX_AIN3,
271 },
272 [WM8776_CTL_INPUT4_SW] = {
273 .name = "AIN4 Capture Switch",
274 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
275 .reg1 = WM8776_REG_ADCMUX,
276 .mask1 = WM8776_ADC_MUX_AIN4,
277 },
278 [WM8776_CTL_INPUT5_SW] = {
279 .name = "AIN5 Capture Switch",
280 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
281 .reg1 = WM8776_REG_ADCMUX,
282 .mask1 = WM8776_ADC_MUX_AIN5,
283 },
284 [WM8776_CTL_AGC_SEL] = {
285 .name = "AGC Select Capture Enum",
286 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
287 .enum_names = { "Off", "Limiter", "ALC Right", "ALC Left",
288 "ALC Stereo" },
289 .max = 5, /* .enum_names item count */
290 .set = snd_wm8776_set_agc,
291 .get = snd_wm8776_get_agc,
292 },
293 [WM8776_CTL_LIM_THR] = {
294 .name = "Limiter Threshold Capture Volume",
295 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
296 .tlv = wm8776_lct_tlv,
297 .reg1 = WM8776_REG_ALCCTRL1,
298 .mask1 = WM8776_ALC1_LCT_MASK,
299 .max = 15,
300 .flags = WM8776_FLAG_LIM,
301 },
302 [WM8776_CTL_LIM_ATK] = {
303 .name = "Limiter Attack Time Capture Enum",
304 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
305 .enum_names = { "0.25 ms", "0.5 ms", "1 ms", "2 ms", "4 ms",
306 "8 ms", "16 ms", "32 ms", "64 ms", "128 ms", "256 ms" },
307 .max = 11, /* .enum_names item count */
308 .reg1 = WM8776_REG_ALCCTRL3,
309 .mask1 = WM8776_ALC3_ATK_MASK,
310 .flags = WM8776_FLAG_LIM,
311 },
312 [WM8776_CTL_LIM_DCY] = {
313 .name = "Limiter Decay Time Capture Enum",
314 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
315 .enum_names = { "1.2 ms", "2.4 ms", "4.8 ms", "9.6 ms",
316 "19.2 ms", "38.4 ms", "76.8 ms", "154 ms", "307 ms",
317 "614 ms", "1.23 s" },
318 .max = 11, /* .enum_names item count */
319 .reg1 = WM8776_REG_ALCCTRL3,
320 .mask1 = WM8776_ALC3_DCY_MASK,
321 .flags = WM8776_FLAG_LIM,
322 },
323 [WM8776_CTL_LIM_TRANWIN] = {
324 .name = "Limiter Transient Window Capture Enum",
325 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
326 .enum_names = { "0 us", "62.5 us", "125 us", "250 us", "500 us",
327 "1 ms", "2 ms", "4 ms" },
328 .max = 8, /* .enum_names item count */
329 .reg1 = WM8776_REG_LIMITER,
330 .mask1 = WM8776_LIM_TRANWIN_MASK,
331 .flags = WM8776_FLAG_LIM,
332 },
333 [WM8776_CTL_LIM_MAXATTN] = {
334 .name = "Limiter Maximum Attenuation Capture Volume",
335 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
336 .tlv = wm8776_maxatten_lim_tlv,
337 .reg1 = WM8776_REG_LIMITER,
338 .mask1 = WM8776_LIM_MAXATTEN_MASK,
339 .min = 3,
340 .max = 12,
341 .flags = WM8776_FLAG_LIM | WM8776_FLAG_INVERT,
342 },
343 [WM8776_CTL_ALC_TGT] = {
344 .name = "ALC Target Level Capture Volume",
345 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
346 .tlv = wm8776_lct_tlv,
347 .reg1 = WM8776_REG_ALCCTRL1,
348 .mask1 = WM8776_ALC1_LCT_MASK,
349 .max = 15,
350 .flags = WM8776_FLAG_ALC,
351 },
352 [WM8776_CTL_ALC_ATK] = {
353 .name = "ALC Attack Time Capture Enum",
354 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
355 .enum_names = { "8.40 ms", "16.8 ms", "33.6 ms", "67.2 ms",
356 "134 ms", "269 ms", "538 ms", "1.08 s", "2.15 s",
357 "4.3 s", "8.6 s" },
358 .max = 11, /* .enum_names item count */
359 .reg1 = WM8776_REG_ALCCTRL3,
360 .mask1 = WM8776_ALC3_ATK_MASK,
361 .flags = WM8776_FLAG_ALC,
362 },
363 [WM8776_CTL_ALC_DCY] = {
364 .name = "ALC Decay Time Capture Enum",
365 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
366 .enum_names = { "33.5 ms", "67.0 ms", "134 ms", "268 ms",
367 "536 ms", "1.07 s", "2.14 s", "4.29 s", "8.58 s",
368 "17.2 s", "34.3 s" },
369 .max = 11, /* .enum_names item count */
370 .reg1 = WM8776_REG_ALCCTRL3,
371 .mask1 = WM8776_ALC3_DCY_MASK,
372 .flags = WM8776_FLAG_ALC,
373 },
374 [WM8776_CTL_ALC_MAXGAIN] = {
375 .name = "ALC Maximum Gain Capture Volume",
376 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
377 .tlv = wm8776_maxgain_tlv,
378 .reg1 = WM8776_REG_ALCCTRL1,
379 .mask1 = WM8776_ALC1_MAXGAIN_MASK,
380 .min = 1,
381 .max = 7,
382 .flags = WM8776_FLAG_ALC,
383 },
384 [WM8776_CTL_ALC_MAXATTN] = {
385 .name = "ALC Maximum Attenuation Capture Volume",
386 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
387 .tlv = wm8776_maxatten_alc_tlv,
388 .reg1 = WM8776_REG_LIMITER,
389 .mask1 = WM8776_LIM_MAXATTEN_MASK,
390 .min = 10,
391 .max = 15,
392 .flags = WM8776_FLAG_ALC | WM8776_FLAG_INVERT,
393 },
394 [WM8776_CTL_ALC_HLD] = {
395 .name = "ALC Hold Time Capture Enum",
396 .type = SNDRV_CTL_ELEM_TYPE_ENUMERATED,
397 .enum_names = { "0 ms", "2.67 ms", "5.33 ms", "10.6 ms",
398 "21.3 ms", "42.7 ms", "85.3 ms", "171 ms", "341 ms",
399 "683 ms", "1.37 s", "2.73 s", "5.46 s", "10.9 s",
400 "21.8 s", "43.7 s" },
401 .max = 16, /* .enum_names item count */
402 .reg1 = WM8776_REG_ALCCTRL2,
403 .mask1 = WM8776_ALC2_HOLD_MASK,
404 .flags = WM8776_FLAG_ALC,
405 },
406 [WM8776_CTL_NGT_SW] = {
407 .name = "Noise Gate Capture Switch",
408 .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
409 .reg1 = WM8776_REG_NOISEGATE,
410 .mask1 = WM8776_NGAT_ENABLE,
411 .flags = WM8776_FLAG_ALC,
412 },
413 [WM8776_CTL_NGT_THR] = {
414 .name = "Noise Gate Threshold Capture Volume",
415 .type = SNDRV_CTL_ELEM_TYPE_INTEGER,
416 .tlv = wm8776_ngth_tlv,
417 .reg1 = WM8776_REG_NOISEGATE,
418 .mask1 = WM8776_NGAT_THR_MASK,
419 .max = 7,
420 .flags = WM8776_FLAG_ALC,
421 },
422};
423
424/* exported functions */
425
426void snd_wm8776_init(struct snd_wm8776 *wm)
427{
428 int i;
429 static const u16 default_values[] = {
430 0x000, 0x100, 0x000,
431 0x000, 0x100, 0x000,
432 0x000, 0x090, 0x000, 0x000,
433 0x022, 0x022, 0x022,
434 0x008, 0x0cf, 0x0cf, 0x07b, 0x000,
435 0x032, 0x000, 0x0a6, 0x001, 0x001
436 };
437
438 memcpy(wm->ctl, snd_wm8776_default_ctl, sizeof(wm->ctl));
439
440 snd_wm8776_write(wm, WM8776_REG_RESET, 0x00); /* reset */
441 udelay(10);
442 /* load defaults */
443 for (i = 0; i < ARRAY_SIZE(default_values); i++)
444 snd_wm8776_write(wm, i, default_values[i]);
445}
446
447void snd_wm8776_resume(struct snd_wm8776 *wm)
448{
449 int i;
450
451 for (i = 0; i < WM8776_REG_COUNT; i++)
452 snd_wm8776_write(wm, i, wm->regs[i]);
453}
454
455void snd_wm8776_set_dac_if(struct snd_wm8776 *wm, u16 dac)
456{
457 snd_wm8776_write(wm, WM8776_REG_DACIFCTRL, dac);
458}
459
460void snd_wm8776_set_adc_if(struct snd_wm8776 *wm, u16 adc)
461{
462 snd_wm8776_write(wm, WM8776_REG_ADCIFCTRL, adc);
463}
464
465void snd_wm8776_set_master_mode(struct snd_wm8776 *wm, u16 mode)
466{
467 snd_wm8776_write(wm, WM8776_REG_MSTRCTRL, mode);
468}
469
470void snd_wm8776_set_power(struct snd_wm8776 *wm, u16 power)
471{
472 snd_wm8776_write(wm, WM8776_REG_PWRDOWN, power);
473}
474
475void snd_wm8776_volume_restore(struct snd_wm8776 *wm)
476{
477 u16 val = wm->regs[WM8776_REG_DACRVOL];
478 /* restore volume after MCLK stopped */
479 snd_wm8776_write(wm, WM8776_REG_DACRVOL, val | WM8776_VOL_UPDATE);
480}
481
482/* mixer callbacks */
483
484static int snd_wm8776_volume_info(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_info *uinfo)
486{
487 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
488 int n = kcontrol->private_value;
489
490 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
491 uinfo->count = (wm->ctl[n].flags & WM8776_FLAG_STEREO) ? 2 : 1;
492 uinfo->value.integer.min = wm->ctl[n].min;
493 uinfo->value.integer.max = wm->ctl[n].max;
494
495 return 0;
496}
497
498static int snd_wm8776_enum_info(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_info *uinfo)
500{
501 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
502 int n = kcontrol->private_value;
503
504 return snd_ctl_enum_info(uinfo, 1, wm->ctl[n].max,
505 wm->ctl[n].enum_names);
506}
507
508static int snd_wm8776_ctl_get(struct snd_kcontrol *kcontrol,
509 struct snd_ctl_elem_value *ucontrol)
510{
511 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
512 int n = kcontrol->private_value;
513 u16 val1, val2;
514
515 if (wm->ctl[n].get)
516 wm->ctl[n].get(wm, &val1, &val2);
517 else {
518 val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1;
519 val1 >>= __ffs(wm->ctl[n].mask1);
520 if (wm->ctl[n].flags & WM8776_FLAG_STEREO) {
521 val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2;
522 val2 >>= __ffs(wm->ctl[n].mask2);
523 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE)
524 val2 &= ~WM8776_VOL_UPDATE;
525 }
526 }
527 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) {
528 val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min);
529 val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min);
530 }
531 ucontrol->value.integer.value[0] = val1;
532 if (wm->ctl[n].flags & WM8776_FLAG_STEREO)
533 ucontrol->value.integer.value[1] = val2;
534
535 return 0;
536}
537
538static int snd_wm8776_ctl_put(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
540{
541 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
542 int n = kcontrol->private_value;
543 u16 val, regval1, regval2;
544
545 /* this also works for enum because value is an union */
546 regval1 = ucontrol->value.integer.value[0];
547 regval2 = ucontrol->value.integer.value[1];
548 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) {
549 regval1 = wm->ctl[n].max - (regval1 - wm->ctl[n].min);
550 regval2 = wm->ctl[n].max - (regval2 - wm->ctl[n].min);
551 }
552 if (wm->ctl[n].set)
553 wm->ctl[n].set(wm, regval1, regval2);
554 else {
555 val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1;
556 val |= regval1 << __ffs(wm->ctl[n].mask1);
557 /* both stereo controls in one register */
558 if (wm->ctl[n].flags & WM8776_FLAG_STEREO &&
559 wm->ctl[n].reg1 == wm->ctl[n].reg2) {
560 val &= ~wm->ctl[n].mask2;
561 val |= regval2 << __ffs(wm->ctl[n].mask2);
562 }
563 snd_wm8776_write(wm, wm->ctl[n].reg1, val);
564 /* stereo controls in different registers */
565 if (wm->ctl[n].flags & WM8776_FLAG_STEREO &&
566 wm->ctl[n].reg1 != wm->ctl[n].reg2) {
567 val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2;
568 val |= regval2 << __ffs(wm->ctl[n].mask2);
569 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE)
570 val |= WM8776_VOL_UPDATE;
571 snd_wm8776_write(wm, wm->ctl[n].reg2, val);
572 }
573 }
574
575 return 0;
576}
577
578static int snd_wm8776_add_control(struct snd_wm8776 *wm, int num)
579{
580 struct snd_kcontrol_new cont;
581 struct snd_kcontrol *ctl;
582
583 memset(&cont, 0, sizeof(cont));
584 cont.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
585 cont.private_value = num;
586 cont.name = wm->ctl[num].name;
587 cont.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
588 if (wm->ctl[num].flags & WM8776_FLAG_LIM ||
589 wm->ctl[num].flags & WM8776_FLAG_ALC)
590 cont.access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
591 cont.tlv.p = NULL;
592 cont.get = snd_wm8776_ctl_get;
593 cont.put = snd_wm8776_ctl_put;
594
595 switch (wm->ctl[num].type) {
596 case SNDRV_CTL_ELEM_TYPE_INTEGER:
597 cont.info = snd_wm8776_volume_info;
598 cont.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
599 cont.tlv.p = wm->ctl[num].tlv;
600 break;
601 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
602 wm->ctl[num].max = 1;
603 if (wm->ctl[num].flags & WM8776_FLAG_STEREO)
604 cont.info = snd_ctl_boolean_stereo_info;
605 else
606 cont.info = snd_ctl_boolean_mono_info;
607 break;
608 case SNDRV_CTL_ELEM_TYPE_ENUMERATED:
609 cont.info = snd_wm8776_enum_info;
610 break;
611 default:
612 return -EINVAL;
613 }
614 ctl = snd_ctl_new1(&cont, wm);
615 if (!ctl)
616 return -ENOMEM;
617
618 return snd_ctl_add(wm->card, ctl);
619}
620
621int snd_wm8776_build_controls(struct snd_wm8776 *wm)
622{
623 int err, i;
624
625 for (i = 0; i < WM8776_CTL_COUNT; i++)
626 if (wm->ctl[i].name) {
627 err = snd_wm8776_add_control(wm, i);
628 if (err < 0)
629 return err;
630 }
631
632 return 0;
633}
diff --git a/sound/pci/ice1712/wm8776.h b/sound/pci/ice1712/wm8776.h
new file mode 100644
index 000000000000..93a2d6971154
--- /dev/null
+++ b/sound/pci/ice1712/wm8776.h
@@ -0,0 +1,226 @@
1#ifndef __SOUND_WM8776_H
2#define __SOUND_WM8776_H
3
4/*
5 * ALSA driver for ICEnsemble VT17xx
6 *
7 * Lowlevel functions for WM8776 codec
8 *
9 * Copyright (c) 2012 Ondrej Zary <linux@rainbow-software.org>
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; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#define WM8776_REG_HPLVOL 0x00
28#define WM8776_REG_HPRVOL 0x01
29#define WM8776_REG_HPMASTER 0x02
30#define WM8776_HPVOL_MASK 0x17f /* incl. update bit */
31#define WM8776_VOL_HPZCEN (1 << 7) /* zero cross detect */
32#define WM8776_VOL_UPDATE (1 << 8) /* update volume */
33#define WM8776_REG_DACLVOL 0x03
34#define WM8776_REG_DACRVOL 0x04
35#define WM8776_REG_DACMASTER 0x05
36#define WM8776_DACVOL_MASK 0x1ff /* incl. update bit */
37#define WM8776_REG_PHASESWAP 0x06
38#define WM8776_PHASE_INVERTL (1 << 0)
39#define WM8776_PHASE_INVERTR (1 << 1)
40#define WM8776_REG_DACCTRL1 0x07
41#define WM8776_DAC_DZCEN (1 << 0)
42#define WM8776_DAC_ATC (1 << 1)
43#define WM8776_DAC_IZD (1 << 2)
44#define WM8776_DAC_TOD (1 << 3)
45#define WM8776_DAC_PL_MASK 0xf0
46#define WM8776_DAC_PL_LL (1 << 4) /* L chan: L signal */
47#define WM8776_DAC_PL_LR (2 << 4) /* L chan: R signal */
48#define WM8776_DAC_PL_LB (3 << 4) /* L chan: both */
49#define WM8776_DAC_PL_RL (1 << 6) /* R chan: L signal */
50#define WM8776_DAC_PL_RR (2 << 6) /* R chan: R signal */
51#define WM8776_DAC_PL_RB (3 << 6) /* R chan: both */
52#define WM8776_REG_DACMUTE 0x08
53#define WM8776_DACMUTE (1 << 0)
54#define WM8776_REG_DACCTRL2 0x09
55#define WM8776_DAC2_DEEMPH (1 << 0)
56#define WM8776_DAC2_ZFLAG_DISABLE (0 << 1)
57#define WM8776_DAC2_ZFLAG_OWN (1 << 1)
58#define WM8776_DAC2_ZFLAG_BOTH (2 << 1)
59#define WM8776_DAC2_ZFLAG_EITHER (3 << 1)
60#define WM8776_REG_DACIFCTRL 0x0a
61#define WM8776_FMT_RIGHTJ (0 << 0)
62#define WM8776_FMT_LEFTJ (1 << 0)
63#define WM8776_FMT_I2S (2 << 0)
64#define WM8776_FMT_DSP (3 << 0)
65#define WM8776_FMT_DSP_LATE (1 << 2) /* in DSP mode */
66#define WM8776_FMT_LRC_INVERTED (1 << 2) /* in other modes */
67#define WM8776_FMT_BCLK_INVERTED (1 << 3)
68#define WM8776_FMT_16BIT (0 << 4)
69#define WM8776_FMT_20BIT (1 << 4)
70#define WM8776_FMT_24BIT (2 << 4)
71#define WM8776_FMT_32BIT (3 << 4)
72#define WM8776_REG_ADCIFCTRL 0x0b
73#define WM8776_FMT_ADCMCLK_INVERTED (1 << 6)
74#define WM8776_FMT_ADCHPD (1 << 8)
75#define WM8776_REG_MSTRCTRL 0x0c
76#define WM8776_IF_ADC256FS (2 << 0)
77#define WM8776_IF_ADC384FS (3 << 0)
78#define WM8776_IF_ADC512FS (4 << 0)
79#define WM8776_IF_ADC768FS (5 << 0)
80#define WM8776_IF_OVERSAMP64 (1 << 3)
81#define WM8776_IF_DAC128FS (0 << 4)
82#define WM8776_IF_DAC192FS (1 << 4)
83#define WM8776_IF_DAC256FS (2 << 4)
84#define WM8776_IF_DAC384FS (3 << 4)
85#define WM8776_IF_DAC512FS (4 << 4)
86#define WM8776_IF_DAC768FS (5 << 4)
87#define WM8776_IF_DAC_MASTER (1 << 7)
88#define WM8776_IF_ADC_MASTER (1 << 8)
89#define WM8776_REG_PWRDOWN 0x0d
90#define WM8776_PWR_PDWN (1 << 0)
91#define WM8776_PWR_ADCPD (1 << 1)
92#define WM8776_PWR_DACPD (1 << 2)
93#define WM8776_PWR_HPPD (1 << 3)
94#define WM8776_PWR_AINPD (1 << 6)
95#define WM8776_REG_ADCLVOL 0x0e
96#define WM8776_REG_ADCRVOL 0x0f
97#define WM8776_ADC_GAIN_MASK 0xff
98#define WM8776_ADC_ZCEN (1 << 8)
99#define WM8776_REG_ALCCTRL1 0x10
100#define WM8776_ALC1_LCT_MASK 0x0f /* 0=-16dB, 1=-15dB..15=-1dB */
101#define WM8776_ALC1_MAXGAIN_MASK 0x70 /* 0,1=0dB, 2=+4dB...7=+24dB */
102#define WM8776_ALC1_LCSEL_MASK 0x180
103#define WM8776_ALC1_LCSEL_LIMITER (0 << 7)
104#define WM8776_ALC1_LCSEL_ALCR (1 << 7)
105#define WM8776_ALC1_LCSEL_ALCL (2 << 7)
106#define WM8776_ALC1_LCSEL_ALCSTEREO (3 << 7)
107#define WM8776_REG_ALCCTRL2 0x11
108#define WM8776_ALC2_HOLD_MASK 0x0f /*0=0ms, 1=2.67ms, 2=5.33ms.. */
109#define WM8776_ALC2_ZCEN (1 << 7)
110#define WM8776_ALC2_LCEN (1 << 8)
111#define WM8776_REG_ALCCTRL3 0x12
112#define WM8776_ALC3_ATK_MASK 0x0f
113#define WM8776_ALC3_DCY_MASK 0xf0
114#define WM8776_ALC3_FDECAY (1 << 8)
115#define WM8776_REG_NOISEGATE 0x13
116#define WM8776_NGAT_ENABLE (1 << 0)
117#define WM8776_NGAT_THR_MASK 0x1c /*0=-78dB, 1=-72dB...7=-36dB */
118#define WM8776_REG_LIMITER 0x14
119#define WM8776_LIM_MAXATTEN_MASK 0x0f
120#define WM8776_LIM_TRANWIN_MASK 0x70 /*0=0us, 1=62.5us, 2=125us.. */
121#define WM8776_REG_ADCMUX 0x15
122#define WM8776_ADC_MUX_AIN1 (1 << 0)
123#define WM8776_ADC_MUX_AIN2 (1 << 1)
124#define WM8776_ADC_MUX_AIN3 (1 << 2)
125#define WM8776_ADC_MUX_AIN4 (1 << 3)
126#define WM8776_ADC_MUX_AIN5 (1 << 4)
127#define WM8776_ADC_MUTER (1 << 6)
128#define WM8776_ADC_MUTEL (1 << 7)
129#define WM8776_ADC_LRBOTH (1 << 8)
130#define WM8776_REG_OUTMUX 0x16
131#define WM8776_OUTMUX_DAC (1 << 0)
132#define WM8776_OUTMUX_AUX (1 << 1)
133#define WM8776_OUTMUX_BYPASS (1 << 2)
134#define WM8776_REG_RESET 0x17
135
136#define WM8776_REG_COUNT 0x17 /* don't cache the RESET register */
137
138struct snd_wm8776;
139
140struct snd_wm8776_ops {
141 void (*write)(struct snd_wm8776 *wm, u8 addr, u8 data);
142};
143
144enum snd_wm8776_ctl_id {
145 WM8776_CTL_DAC_VOL,
146 WM8776_CTL_DAC_SW,
147 WM8776_CTL_DAC_ZC_SW,
148 WM8776_CTL_HP_VOL,
149 WM8776_CTL_HP_SW,
150 WM8776_CTL_HP_ZC_SW,
151 WM8776_CTL_AUX_SW,
152 WM8776_CTL_BYPASS_SW,
153 WM8776_CTL_DAC_IZD_SW,
154 WM8776_CTL_PHASE_SW,
155 WM8776_CTL_DEEMPH_SW,
156 WM8776_CTL_ADC_VOL,
157 WM8776_CTL_ADC_SW,
158 WM8776_CTL_INPUT1_SW,
159 WM8776_CTL_INPUT2_SW,
160 WM8776_CTL_INPUT3_SW,
161 WM8776_CTL_INPUT4_SW,
162 WM8776_CTL_INPUT5_SW,
163 WM8776_CTL_AGC_SEL,
164 WM8776_CTL_LIM_THR,
165 WM8776_CTL_LIM_ATK,
166 WM8776_CTL_LIM_DCY,
167 WM8776_CTL_LIM_TRANWIN,
168 WM8776_CTL_LIM_MAXATTN,
169 WM8776_CTL_ALC_TGT,
170 WM8776_CTL_ALC_ATK,
171 WM8776_CTL_ALC_DCY,
172 WM8776_CTL_ALC_MAXGAIN,
173 WM8776_CTL_ALC_MAXATTN,
174 WM8776_CTL_ALC_HLD,
175 WM8776_CTL_NGT_SW,
176 WM8776_CTL_NGT_THR,
177
178 WM8776_CTL_COUNT,
179};
180
181#define WM8776_ENUM_MAX 16
182
183#define WM8776_FLAG_STEREO (1 << 0)
184#define WM8776_FLAG_VOL_UPDATE (1 << 1)
185#define WM8776_FLAG_INVERT (1 << 2)
186#define WM8776_FLAG_LIM (1 << 3)
187#define WM8776_FLAG_ALC (1 << 4)
188
189struct snd_wm8776_ctl {
190 const char *name;
191 snd_ctl_elem_type_t type;
192 const char *const enum_names[WM8776_ENUM_MAX];
193 const unsigned int *tlv;
194 u16 reg1, reg2, mask1, mask2, min, max, flags;
195 void (*set)(struct snd_wm8776 *wm, u16 ch1, u16 ch2);
196 void (*get)(struct snd_wm8776 *wm, u16 *ch1, u16 *ch2);
197};
198
199enum snd_wm8776_agc_mode {
200 WM8776_AGC_OFF,
201 WM8776_AGC_LIM,
202 WM8776_AGC_ALC_R,
203 WM8776_AGC_ALC_L,
204 WM8776_AGC_ALC_STEREO
205};
206
207struct snd_wm8776 {
208 struct snd_card *card;
209 struct snd_wm8776_ctl ctl[WM8776_CTL_COUNT];
210 enum snd_wm8776_agc_mode agc_mode;
211 struct snd_wm8776_ops ops;
212 u16 regs[WM8776_REG_COUNT]; /* 9-bit registers */
213};
214
215
216
217void snd_wm8776_init(struct snd_wm8776 *wm);
218void snd_wm8776_resume(struct snd_wm8776 *wm);
219void snd_wm8776_set_dac_if(struct snd_wm8776 *wm, u16 dac);
220void snd_wm8776_set_adc_if(struct snd_wm8776 *wm, u16 adc);
221void snd_wm8776_set_master_mode(struct snd_wm8776 *wm, u16 mode);
222void snd_wm8776_set_power(struct snd_wm8776 *wm, u16 power);
223void snd_wm8776_volume_restore(struct snd_wm8776 *wm);
224int snd_wm8776_build_controls(struct snd_wm8776 *wm);
225
226#endif /* __SOUND_WM8776_H */
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c
index e618f789026e..184163bbd732 100644
--- a/sound/pci/ice1712/wtm.c
+++ b/sound/pci/ice1712/wtm.c
@@ -25,7 +25,6 @@
25 25
26 26
27 27
28#include <linux/io.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
31#include <linux/init.h> 30#include <linux/init.h>
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index ff77b28f3da1..225dfd737265 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -90,7 +90,7 @@ config SND_USB_CAIAQ_INPUT
90 90
91config SND_USB_US122L 91config SND_USB_US122L
92 tristate "Tascam US-122L USB driver" 92 tristate "Tascam US-122L USB driver"
93 depends on X86 && EXPERIMENTAL 93 depends on X86
94 select SND_HWDEP 94 select SND_HWDEP
95 select SND_RAWMIDI 95 select SND_RAWMIDI
96 help 96 help
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 37428f74dbb6..8ca6edf29fee 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -173,11 +173,8 @@ static int init_pitch_v2(struct snd_usb_audio *chip, int iface,
173{ 173{
174 struct usb_device *dev = chip->dev; 174 struct usb_device *dev = chip->dev;
175 unsigned char data[1]; 175 unsigned char data[1];
176 unsigned int ep;
177 int err; 176 int err;
178 177
179 ep = get_endpoint(alts, 0)->bEndpointAddress;
180
181 data[0] = 1; 178 data[0] = 1;
182 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 179 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
183 USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT, 180 USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 88d8cebbb244..49c788d7de57 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -1457,6 +1457,40 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1457 } 1457 }
1458}, 1458},
1459{ 1459{
1460 /* Advanced mode of the Roland VG-99, with MIDI and 24-bit PCM at 44.1
1461 * kHz. In standard mode, the device has ID 0582:00b3, and offers
1462 * 16-bit PCM at 44.1 kHz with no MIDI.
1463 */
1464 USB_DEVICE(0x0582, 0x00b2),
1465 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1466 .vendor_name = "Roland",
1467 .product_name = "VG-99",
1468 .ifnum = QUIRK_ANY_INTERFACE,
1469 .type = QUIRK_COMPOSITE,
1470 .data = (const struct snd_usb_audio_quirk[]) {
1471 {
1472 .ifnum = 0,
1473 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1474 },
1475 {
1476 .ifnum = 1,
1477 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1478 },
1479 {
1480 .ifnum = 2,
1481 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1482 .data = & (const struct snd_usb_midi_endpoint_info) {
1483 .out_cables = 0x0003,
1484 .in_cables = 0x0003
1485 }
1486 },
1487 {
1488 .ifnum = -1
1489 }
1490 }
1491 }
1492},
1493{
1460 /* Roland SonicCell */ 1494 /* Roland SonicCell */
1461 USB_DEVICE(0x0582, 0x00c2), 1495 USB_DEVICE(0x0582, 0x00c2),
1462 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1496 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
@@ -2880,6 +2914,47 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2880 } 2914 }
2881}, 2915},
2882 2916
2917/* Reloop Play */
2918{
2919 USB_DEVICE(0x200c, 0x100b),
2920 .bInterfaceClass = USB_CLASS_PER_INTERFACE,
2921 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2922 .ifnum = QUIRK_ANY_INTERFACE,
2923 .type = QUIRK_COMPOSITE,
2924 .data = &(const struct snd_usb_audio_quirk[]) {
2925 {
2926 .ifnum = 0,
2927 .type = QUIRK_AUDIO_STANDARD_MIXER,
2928 },
2929 {
2930 .ifnum = 1,
2931 .type = QUIRK_AUDIO_FIXED_ENDPOINT,
2932 .data = &(const struct audioformat) {
2933 .formats = SNDRV_PCM_FMTBIT_S24_3LE,
2934 .channels = 4,
2935 .iface = 1,
2936 .altsetting = 1,
2937 .altset_idx = 1,
2938 .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
2939 .endpoint = 0x01,
2940 .ep_attr = USB_ENDPOINT_SYNC_ADAPTIVE,
2941 .rates = SNDRV_PCM_RATE_44100 |
2942 SNDRV_PCM_RATE_48000,
2943 .rate_min = 44100,
2944 .rate_max = 48000,
2945 .nr_rates = 2,
2946 .rate_table = (unsigned int[]) {
2947 44100, 48000
2948 }
2949 }
2950 },
2951 {
2952 .ifnum = -1
2953 }
2954 }
2955 }
2956},
2957
2883{ 2958{
2884 /* 2959 /*
2885 * Some USB MIDI devices don't have an audio control interface, 2960 * Some USB MIDI devices don't have an audio control interface,