31 #include <linux/pci.h>
32 #include <linux/capability.h>
34 #include <linux/slab.h>
45 #define EMU10K1_CAPTURE_DIGITAL_OUT
48 #define EMU10K1_SET_AC3_IEC958
51 #define EMU10K1_CENTER_LFE_FROM_FRONT
54 static bool high_res_gpr_volume;
56 MODULE_PARM_DESC(high_res_gpr_volume,
"GPR mixer controls use 31-bit range.");
62 static char *fxbuses[16] = {
81 static char *creative_ins[16] = {
88 "Optical IEC958 Left",
89 "Optical IEC958 Right",
92 "Coaxial IEC958 Left",
93 "Coaxial IEC958 Right",
100 static char *audigy_ins[16] = {
105 "Optical IEC958 Left",
106 "Optical IEC958 Right",
119 static char *creative_outs[32] = {
122 "Optical IEC958 Left",
123 "Optical IEC958 Right",
133 "AC97 Surround Left",
134 "AC97 Surround Right",
154 static char *audigy_outs[32] = {
155 "Digital Front Left",
156 "Digital Front Right",
162 "Digital Rear Right",
189 static const u32 bass_table[41][5] = {
190 { 0x3e4f844f, 0x84ed4cc3, 0x3cc69927, 0x7b03553a, 0xc4da8486 },
191 { 0x3e69a17a, 0x84c280fb, 0x3cd77cd4, 0x7b2f2a6f, 0xc4b08d1d },
192 { 0x3e82ff42, 0x849991d5, 0x3ce7466b, 0x7b5917c6, 0xc48863ee },
193 { 0x3e9bab3c, 0x847267f0, 0x3cf5ffe8, 0x7b813560, 0xc461f22c },
194 { 0x3eb3b275, 0x844ced29, 0x3d03b295, 0x7ba79a1c, 0xc43d223b },
195 { 0x3ecb2174, 0x84290c8b, 0x3d106714, 0x7bcc5ba3, 0xc419dfa5 },
196 { 0x3ee2044b, 0x8406b244, 0x3d1c2561, 0x7bef8e77, 0xc3f8170f },
197 { 0x3ef86698, 0x83e5cb96, 0x3d26f4d8, 0x7c114600, 0xc3d7b625 },
198 { 0x3f0e5390, 0x83c646c9, 0x3d30dc39, 0x7c319498, 0xc3b8ab97 },
199 { 0x3f23d60b, 0x83a81321, 0x3d39e1af, 0x7c508b9c, 0xc39ae704 },
200 { 0x3f38f884, 0x838b20d2, 0x3d420ad2, 0x7c6e3b75, 0xc37e58f1 },
201 { 0x3f4dc52c, 0x836f60ef, 0x3d495cab, 0x7c8ab3a6, 0xc362f2be },
202 { 0x3f6245e8, 0x8354c565, 0x3d4fdbb8, 0x7ca602d6, 0xc348a69b },
203 { 0x3f76845f, 0x833b40ec, 0x3d558bf0, 0x7cc036df, 0xc32f677c },
204 { 0x3f8a8a03, 0x8322c6fb, 0x3d5a70c4, 0x7cd95cd7, 0xc317290b },
205 { 0x3f9e6014, 0x830b4bc3, 0x3d5e8d25, 0x7cf1811a, 0xc2ffdfa5 },
206 { 0x3fb20fae, 0x82f4c420, 0x3d61e37f, 0x7d08af56, 0xc2e9804a },
207 { 0x3fc5a1cc, 0x82df2592, 0x3d6475c3, 0x7d1ef294, 0xc2d40096 },
208 { 0x3fd91f55, 0x82ca6632, 0x3d664564, 0x7d345541, 0xc2bf56b9 },
209 { 0x3fec9120, 0x82b67cac, 0x3d675356, 0x7d48e138, 0xc2ab796e },
210 { 0x40000000, 0x82a36037, 0x3d67a012, 0x7d5c9fc9, 0xc2985fee },
211 { 0x401374c7, 0x8291088a, 0x3d672b93, 0x7d6f99c3, 0xc28601f2 },
212 { 0x4026f857, 0x827f6dd7, 0x3d65f559, 0x7d81d77c, 0xc27457a3 },
213 { 0x403a939f, 0x826e88c5, 0x3d63fc63, 0x7d9360d4, 0xc2635996 },
214 { 0x404e4faf, 0x825e5266, 0x3d613f32, 0x7da43d42, 0xc25300c6 },
215 { 0x406235ba, 0x824ec434, 0x3d5dbbc3, 0x7db473d7, 0xc243468e },
216 { 0x40764f1f, 0x823fd80c, 0x3d596f8f, 0x7dc40b44, 0xc23424a2 },
217 { 0x408aa576, 0x82318824, 0x3d545787, 0x7dd309e2, 0xc2259509 },
218 { 0x409f4296, 0x8223cf0b, 0x3d4e7012, 0x7de175b5, 0xc2179218 },
219 { 0x40b430a0, 0x8216a7a1, 0x3d47b505, 0x7def5475, 0xc20a1670 },
220 { 0x40c97a0a, 0x820a0d12, 0x3d4021a1, 0x7dfcab8d, 0xc1fd1cf5 },
221 { 0x40df29a6, 0x81fdfad6, 0x3d37b08d, 0x7e098028, 0xc1f0a0ca },
222 { 0x40f54ab1, 0x81f26ca9, 0x3d2e5bd1, 0x7e15d72b, 0xc1e49d52 },
223 { 0x410be8da, 0x81e75e89, 0x3d241cce, 0x7e21b544, 0xc1d90e24 },
224 { 0x41231051, 0x81dcccb3, 0x3d18ec37, 0x7e2d1ee6, 0xc1cdef10 },
225 { 0x413acdd0, 0x81d2b39e, 0x3d0cc20a, 0x7e38184e, 0xc1c33c13 },
226 { 0x41532ea7, 0x81c90ffb, 0x3cff9585, 0x7e42a58b, 0xc1b8f15a },
227 { 0x416c40cd, 0x81bfdeb2, 0x3cf15d21, 0x7e4cca7c, 0xc1af0b3f },
228 { 0x418612ea, 0x81b71cdc, 0x3ce20e85, 0x7e568ad3, 0xc1a58640 },
229 { 0x41a0b465, 0x81aec7c5, 0x3cd19e7c, 0x7e5fea1e, 0xc19c5f03 },
230 { 0x41bc3573, 0x81a6dcea, 0x3cc000e9, 0x7e68ebc2, 0xc1939250 }
233 static const u32 treble_table[41][5] = {
234 { 0x0125cba9, 0xfed5debd, 0x00599b6c, 0x0d2506da, 0xfa85b354 },
235 { 0x0142f67e, 0xfeb03163, 0x0066cd0f, 0x0d14c69d, 0xfa914473 },
236 { 0x016328bd, 0xfe860158, 0x0075b7f2, 0x0d03eb27, 0xfa9d32d2 },
237 { 0x0186b438, 0xfe56c982, 0x00869234, 0x0cf27048, 0xfaa97fca },
238 { 0x01adf358, 0xfe21f5fe, 0x00999842, 0x0ce051c2, 0xfab62ca5 },
239 { 0x01d949fa, 0xfde6e287, 0x00af0d8d, 0x0ccd8b4a, 0xfac33aa7 },
240 { 0x02092669, 0xfda4d8bf, 0x00c73d4c, 0x0cba1884, 0xfad0ab07 },
241 { 0x023e0268, 0xfd5b0e4a, 0x00e27b54, 0x0ca5f509, 0xfade7ef2 },
242 { 0x0278645c, 0xfd08a2b0, 0x01012509, 0x0c911c63, 0xfaecb788 },
243 { 0x02b8e091, 0xfcac9d1a, 0x0123a262, 0x0c7b8a14, 0xfafb55df },
244 { 0x03001a9a, 0xfc45e9ce, 0x014a6709, 0x0c65398f, 0xfb0a5aff },
245 { 0x034ec6d7, 0xfbd3576b, 0x0175f397, 0x0c4e2643, 0xfb19c7e4 },
246 { 0x03a5ac15, 0xfb5393ee, 0x01a6d6ed, 0x0c364b94, 0xfb299d7c },
247 { 0x0405a562, 0xfac52968, 0x01ddafae, 0x0c1da4e2, 0xfb39dca5 },
248 { 0x046fa3fe, 0xfa267a66, 0x021b2ddd, 0x0c042d8d, 0xfb4a8631 },
249 { 0x04e4b17f, 0xf975be0f, 0x0260149f, 0x0be9e0f2, 0xfb5b9ae0 },
250 { 0x0565f220, 0xf8b0fbe5, 0x02ad3c29, 0x0bceba73, 0xfb6d1b60 },
251 { 0x05f4a745, 0xf7d60722, 0x030393d4, 0x0bb2b578, 0xfb7f084d },
252 { 0x06923236, 0xf6e279bd, 0x03642465, 0x0b95cd75, 0xfb916233 },
253 { 0x07401713, 0xf5d3aef9, 0x03d01283, 0x0b77fded, 0xfba42984 },
254 { 0x08000000, 0xf4a6bd88, 0x0448a161, 0x0b594278, 0xfbb75e9f },
255 { 0x08d3c097, 0xf3587131, 0x04cf35a4, 0x0b3996c9, 0xfbcb01cb },
256 { 0x09bd59a2, 0xf1e543f9, 0x05655880, 0x0b18f6b2, 0xfbdf1333 },
257 { 0x0abefd0f, 0xf04956ca, 0x060cbb12, 0x0af75e2c, 0xfbf392e8 },
258 { 0x0bdb123e, 0xee806984, 0x06c739fe, 0x0ad4c962, 0xfc0880dd },
259 { 0x0d143a94, 0xec85d287, 0x0796e150, 0x0ab134b0, 0xfc1ddce5 },
260 { 0x0e6d5664, 0xea547598, 0x087df0a0, 0x0a8c9cb6, 0xfc33a6ad },
261 { 0x0fe98a2a, 0xe7e6ba35, 0x097edf83, 0x0a66fe5b, 0xfc49ddc2 },
262 { 0x118c4421, 0xe536813a, 0x0a9c6248, 0x0a4056d7, 0xfc608185 },
263 { 0x1359422e, 0xe23d19eb, 0x0bd96efb, 0x0a18a3bf, 0xfc77912c },
264 { 0x1554982b, 0xdef33645, 0x0d3942bd, 0x09efe312, 0xfc8f0bc1 },
265 { 0x1782b68a, 0xdb50deb1, 0x0ebf676d, 0x09c6133f, 0xfca6f019 },
266 { 0x19e8715d, 0xd74d64fd, 0x106fb999, 0x099b3337, 0xfcbf3cd6 },
267 { 0x1c8b07b8, 0xd2df56ab, 0x124e6ec8, 0x096f4274, 0xfcd7f060 },
268 { 0x1f702b6d, 0xcdfc6e92, 0x14601c10, 0x0942410b, 0xfcf108e5 },
269 { 0x229e0933, 0xc89985cd, 0x16a9bcfa, 0x09142fb5, 0xfd0a8451 },
270 { 0x261b5118, 0xc2aa8409, 0x1930bab6, 0x08e50fdc, 0xfd24604d },
271 { 0x29ef3f5d, 0xbc224f28, 0x1bfaf396, 0x08b4e3aa, 0xfd3e9a3b },
272 { 0x2e21a59b, 0xb4f2ba46, 0x1f0ec2d6, 0x0883ae15, 0xfd592f33 },
273 { 0x32baf44b, 0xad0c7429, 0x227308a3, 0x085172eb, 0xfd741bfd },
274 { 0x37c4448b, 0xa45ef51d, 0x262f3267, 0x081e36dc, 0xfd8f5d14 }
278 static const u32 db_table[101] = {
279 0x00000000, 0x01571f82, 0x01674b41, 0x01783a1b, 0x0189f540,
280 0x019c8651, 0x01aff763, 0x01c45306, 0x01d9a446, 0x01eff6b8,
281 0x0207567a, 0x021fd03d, 0x0239714c, 0x02544792, 0x027061a1,
282 0x028dcebb, 0x02ac9edc, 0x02cce2bf, 0x02eeabe8, 0x03120cb0,
283 0x0337184e, 0x035de2df, 0x03868173, 0x03b10a18, 0x03dd93e9,
284 0x040c3713, 0x043d0cea, 0x04702ff3, 0x04a5bbf2, 0x04ddcdfb,
285 0x0518847f, 0x0555ff62, 0x05966005, 0x05d9c95d, 0x06206005,
286 0x066a4a52, 0x06b7b067, 0x0708bc4c, 0x075d9a01, 0x07b6779d,
287 0x08138561, 0x0874f5d5, 0x08dafde1, 0x0945d4ed, 0x09b5b4fd,
288 0x0a2adad1, 0x0aa58605, 0x0b25f936, 0x0bac7a24, 0x0c3951d8,
289 0x0ccccccc, 0x0d673b17, 0x0e08f093, 0x0eb24510, 0x0f639481,
290 0x101d3f2d, 0x10dfa9e6, 0x11ab3e3f, 0x12806ac3, 0x135fa333,
291 0x144960c5, 0x153e2266, 0x163e6cfe, 0x174acbb7, 0x1863d04d,
292 0x198a1357, 0x1abe349f, 0x1c00db77, 0x1d52b712, 0x1eb47ee6,
293 0x2026f30f, 0x21aadcb6, 0x23410e7e, 0x24ea64f9, 0x26a7c71d,
294 0x287a26c4, 0x2a62812c, 0x2c61df84, 0x2e795779, 0x30aa0bcf,
295 0x32f52cfe, 0x355bf9d8, 0x37dfc033, 0x3a81dda4, 0x3d43c038,
296 0x4026e73c, 0x432ce40f, 0x46575af8, 0x49a8040f, 0x4d20ac2a,
297 0x50c335d3, 0x54919a57, 0x588dead1, 0x5cba514a, 0x611911ea,
298 0x65ac8c2f, 0x6a773c39, 0x6f7bbc23, 0x74bcc56c, 0x7a3d3272,
309 static const u32 onoff_table[2] = {
310 0x00000000, 0x00000001
334 struct snd_emu10k1_fx8010_ctl *
ctl =
337 if (ctl->min == 0 && ctl->max == 1)
341 uinfo->
count = ctl->vcount;
350 struct snd_emu10k1_fx8010_ctl *ctl =
356 for (
i = 0;
i < ctl->vcount;
i++)
357 ucontrol->
value.integer.value[
i] = ctl->value[
i];
358 spin_unlock_irqrestore(&emu->reg_lock,
flags);
365 struct snd_emu10k1_fx8010_ctl *ctl =
368 unsigned int nval,
val;
373 for (i = 0; i < ctl->vcount; i++) {
374 nval = ucontrol->
value.integer.value[
i];
379 if (nval != ctl->value[i])
381 val = ctl->value[
i] = nval;
382 switch (ctl->translation) {
390 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
394 for (
j = 0;
j < 5;
j++)
398 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
402 for (j = 0; j < 5; j++)
411 spin_unlock_irqrestore(&emu->reg_lock,
flags);
419 static void snd_emu10k1_fx8010_interrupt(
struct snd_emu10k1 *emu)
421 struct snd_emu10k1_fx8010_irq *
irq, *nirq;
423 irq = emu->fx8010.irq_handlers;
428 irq->handler(emu, irq->private_data);
436 snd_fx8010_irq_handler_t *handler,
437 unsigned char gpr_running,
439 struct snd_emu10k1_fx8010_irq **r_irq)
441 struct snd_emu10k1_fx8010_irq *irq;
447 irq->handler = handler;
448 irq->gpr_running = gpr_running;
452 if (emu->fx8010.irq_handlers ==
NULL) {
453 emu->fx8010.irq_handlers = irq;
454 emu->dsp_interrupt = snd_emu10k1_fx8010_interrupt;
457 irq->next = emu->fx8010.irq_handlers;
458 emu->fx8010.irq_handlers = irq;
460 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags);
467 struct snd_emu10k1_fx8010_irq *irq)
469 struct snd_emu10k1_fx8010_irq *
tmp;
473 if ((tmp = emu->fx8010.irq_handlers) == irq) {
474 emu->fx8010.irq_handlers = tmp->next;
475 if (emu->fx8010.irq_handlers ==
NULL) {
477 emu->dsp_interrupt =
NULL;
480 while (tmp && tmp->next != irq)
483 tmp->next = tmp->next->next;
485 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags);
502 set_bit(*ptr, icode->code_valid);
503 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
504 code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff);
508 #define OP(icode, ptr, op, r, a, x, y) \
509 snd_emu10k1_write_op(icode, ptr, op, r, a, x, y)
519 set_bit(*ptr, icode->code_valid);
520 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
521 code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
525 #define A_OP(icode, ptr, op, r, a, x, y) \
526 snd_emu10k1_audigy_write_op(icode, ptr, op, r, a, x, y)
528 static void snd_emu10k1_efx_write(
struct snd_emu10k1 *emu,
unsigned int pc,
unsigned int data)
530 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
536 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
540 static int snd_emu10k1_gpr_poke(
struct snd_emu10k1 *emu,
546 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) {
547 if (!
test_bit(gpr, icode->gpr_valid))
556 static int snd_emu10k1_gpr_peek(
struct snd_emu10k1 *emu,
562 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) {
563 set_bit(gpr, icode->gpr_valid);
571 static int snd_emu10k1_tram_poke(
struct snd_emu10k1 *emu,
577 for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) {
578 if (!
test_bit(tram, icode->tram_valid))
594 static int snd_emu10k1_tram_peek(
struct snd_emu10k1 *emu,
600 memset(icode->tram_valid, 0,
sizeof(icode->tram_valid));
601 for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) {
602 set_bit(tram, icode->tram_valid);
617 static int snd_emu10k1_code_poke(
struct snd_emu10k1 *emu,
622 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) {
623 if (!
test_bit(pc / 2, icode->code_valid))
628 snd_emu10k1_efx_write(emu, pc + 0, lo);
629 snd_emu10k1_efx_write(emu, pc + 1, hi);
634 static int snd_emu10k1_code_peek(
struct snd_emu10k1 *emu,
639 memset(icode->code_valid, 0,
sizeof(icode->code_valid));
640 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) {
641 set_bit(pc / 2, icode->code_valid);
650 static struct snd_emu10k1_fx8010_ctl *
651 snd_emu10k1_look_for_ctl(
struct snd_emu10k1 *emu,
struct snd_ctl_elem_id *
id)
653 struct snd_emu10k1_fx8010_ctl *
ctl;
657 kcontrol = ctl->kcontrol;
658 if (kcontrol->
id.iface == id->
iface &&
660 kcontrol->
id.index == id->
index)
666 #define MAX_TLV_SIZE 256
668 static unsigned int *copy_tlv(
const unsigned int __user *_tlv)
670 unsigned int data[2];
682 memcpy(tlv, data,
sizeof(data));
690 static int copy_gctl(
struct snd_emu10k1 *emu,
697 if (emu->support_tlv)
706 static int copy_gctl_to_user(
struct snd_emu10k1 *emu,
713 if (emu->support_tlv)
720 static int snd_emu10k1_verify_controls(
struct snd_emu10k1 *emu,
730 i < icode->gpr_del_control_count; i++, _id++) {
733 if (snd_emu10k1_look_for_ctl(emu, &
id) ==
NULL)
745 if (snd_emu10k1_look_for_ctl(emu, &gctl->
id))
749 up_read(&emu->card->controls_rwsem);
753 up_read(&emu->card->controls_rwsem);
772 static void snd_emu10k1_ctl_private_free(
struct snd_kcontrol *kctl)
774 struct snd_emu10k1_fx8010_ctl *
ctl;
784 static int snd_emu10k1_add_controls(
struct snd_emu10k1 *emu,
789 struct snd_emu10k1_fx8010_ctl *
ctl, *nctl;
798 if (!val || !gctl || !nctl) {
813 if (! gctl->
id.name[0]) {
817 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->
id);
818 memset(&knew, 0,
sizeof(knew));
819 knew.iface = gctl->
id.iface;
820 knew.name = gctl->
id.name;
821 knew.index = gctl->
id.index;
822 knew.device = gctl->
id.device;
823 knew.subdevice = gctl->
id.subdevice;
824 knew.info = snd_emu10k1_gpr_ctl_info;
825 knew.tlv.p = copy_tlv(gctl->
tlv);
829 knew.get = snd_emu10k1_gpr_ctl_get;
830 knew.put = snd_emu10k1_gpr_ctl_put;
831 memset(nctl, 0,
sizeof(*nctl));
832 nctl->vcount = gctl->
vcount;
833 nctl->count = gctl->
count;
834 for (j = 0; j < 32; j++) {
835 nctl->gpr[
j] = gctl->
gpr[
j];
836 nctl->value[
j] = ~gctl->
value[
j];
839 nctl->min = gctl->
min;
840 nctl->max = gctl->
max;
849 knew.private_value = (
unsigned long)ctl;
857 ctl->kcontrol = kctl;
861 nctl->list = ctl->list;
862 nctl->kcontrol = ctl->kcontrol;
867 snd_emu10k1_gpr_ctl_put(ctl->kcontrol, val);
876 static int snd_emu10k1_del_controls(
struct snd_emu10k1 *emu,
882 struct snd_emu10k1_fx8010_ctl *
ctl;
886 i < icode->gpr_del_control_count; i++, _id++) {
890 ctl = snd_emu10k1_look_for_ctl(emu, &
id);
898 static int snd_emu10k1_list_controls(
struct snd_emu10k1 *emu,
901 unsigned int i = 0,
j;
902 unsigned int total = 0;
904 struct snd_emu10k1_fx8010_ctl *
ctl;
914 i < icode->gpr_list_control_count) {
915 memset(gctl, 0,
sizeof(*gctl));
916 id = &ctl->kcontrol->id;
917 gctl->
id.iface =
id->iface;
919 gctl->
id.index =
id->index;
920 gctl->
id.device =
id->device;
921 gctl->
id.subdevice =
id->subdevice;
922 gctl->
vcount = ctl->vcount;
923 gctl->
count = ctl->count;
924 for (j = 0; j < 32; j++) {
925 gctl->
gpr[
j] = ctl->gpr[
j];
926 gctl->
value[
j] = ctl->value[
j];
928 gctl->
min = ctl->min;
929 gctl->
max = ctl->max;
944 static int snd_emu10k1_icode_poke(
struct snd_emu10k1 *emu,
950 if ((err = snd_emu10k1_verify_controls(emu, icode)) < 0)
952 strlcpy(emu->fx8010.name, icode->
name,
sizeof(emu->fx8010.name));
960 if ((err = snd_emu10k1_del_controls(emu, icode)) < 0 ||
961 (err = snd_emu10k1_gpr_poke(emu, icode)) < 0 ||
962 (err = snd_emu10k1_tram_poke(emu, icode)) < 0 ||
963 (err = snd_emu10k1_code_poke(emu, icode)) < 0 ||
964 (err = snd_emu10k1_add_controls(emu, icode)) < 0)
976 static int snd_emu10k1_icode_peek(
struct snd_emu10k1 *emu,
984 err = snd_emu10k1_gpr_peek(emu, icode);
986 err = snd_emu10k1_tram_peek(emu, icode);
988 err = snd_emu10k1_code_peek(emu, icode);
990 err = snd_emu10k1_list_controls(emu, icode);
995 static int snd_emu10k1_ipcm_poke(
struct snd_emu10k1 *emu,
1000 struct snd_emu10k1_fx8010_pcm *
pcm;
1006 pcm = &emu->fx8010.pcm[ipcm->
substream];
1008 spin_lock_irq(&emu->reg_lock);
1032 for (i = 0; i < pcm->channels; i++)
1033 pcm->etram[i] = ipcm->
etram[i];
1036 spin_unlock_irq(&emu->reg_lock);
1041 static int snd_emu10k1_ipcm_peek(
struct snd_emu10k1 *emu,
1046 struct snd_emu10k1_fx8010_pcm *pcm;
1050 pcm = &emu->fx8010.pcm[ipcm->
substream];
1052 spin_lock_irq(&emu->reg_lock);
1062 for (i = 0; i < pcm->channels; i++)
1063 ipcm->
etram[i] = pcm->etram[i];
1066 spin_unlock_irq(&emu->reg_lock);
1071 #define SND_EMU10K1_GPR_CONTROLS 44
1072 #define SND_EMU10K1_INPUTS 12
1073 #define SND_EMU10K1_PLAYBACK_CHANNELS 8
1074 #define SND_EMU10K1_CAPTURE_CHANNELS 4
1078 const char *
name,
int gpr,
int defval)
1083 ctl->
gpr[0] = gpr + 0; ctl->
value[0] = defval;
1084 if (high_res_gpr_volume) {
1086 ctl->
max = 0x7fffffff;
1087 ctl->
tlv = snd_emu10k1_db_linear;
1092 ctl->
tlv = snd_emu10k1_db_scale1;
1099 const char *
name,
int gpr,
int defval)
1104 ctl->
gpr[0] = gpr + 0; ctl->
value[0] = defval;
1105 ctl->
gpr[1] = gpr + 1; ctl->
value[1] = defval;
1106 if (high_res_gpr_volume) {
1108 ctl->
max = 0x7fffffff;
1109 ctl->
tlv = snd_emu10k1_db_linear;
1114 ctl->
tlv = snd_emu10k1_db_scale1;
1121 const char *name,
int gpr,
int defval)
1126 ctl->
gpr[0] = gpr + 0; ctl->
value[0] = defval;
1134 const char *name,
int gpr,
int defval)
1139 ctl->
gpr[0] = gpr + 0; ctl->
value[0] = defval;
1140 ctl->
gpr[1] = gpr + 1; ctl->
value[1] = defval;
1151 static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
1153 u32 *ptr,
int tmp,
int bit_shifter16,
1154 int reg_in,
int reg_out)
1171 static int __devinit _snd_emu10k1_audigy_init_efx(
struct snd_emu10k1 *emu)
1173 int err,
i, z, gpr, nctl;
1175 const int playback = 10;
1177 const int stereo_mix = capture + 2;
1178 const int tmp = 0x88;
1187 kcalloc(512 + 256 + 256 + 2 * 1024,
sizeof(
u_int32_t),
1201 for (i = 0; i < 512; i++)
1205 for (i = 0; i < 256; i++)
1206 set_bit(i, icode->tram_valid);
1208 strcpy(icode->
name,
"Audigy DSP code for ALSA");
1211 gpr = stereo_mix + 10;
1212 gpr_map[gpr++] = 0x00007fff;
1213 gpr_map[gpr++] = 0x00008000;
1214 gpr_map[gpr++] = 0x0000ffff;
1215 bit_shifter16 =
gpr;
1228 snd_emu10k1_init_stereo_control(&controls[nctl++],
"PCM Front Playback Volume", gpr, 100);
1234 snd_emu10k1_init_stereo_control(&controls[nctl++],
"PCM Surround Playback Volume", gpr, 100);
1238 if (emu->card_capabilities->spk71) {
1241 snd_emu10k1_init_stereo_control(&controls[nctl++],
"PCM Side Playback Volume", gpr, 100);
1247 snd_emu10k1_init_mono_control(&controls[nctl++],
"PCM Center Playback Volume", gpr, 100);
1252 snd_emu10k1_init_mono_control(&controls[nctl++],
"PCM LFE Playback Volume", gpr, 100);
1261 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Wave Playback Volume", gpr, 100);
1267 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Synth Playback Volume", gpr, 100);
1273 snd_emu10k1_init_stereo_control(&controls[nctl++],
"PCM Capture Volume", gpr, 0);
1279 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Synth Capture Volume", gpr, 0);
1285 #define A_ADD_VOLUME_IN(var,vol,input) \
1286 A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1289 if (emu->card_capabilities->emu_model) {
1290 if (emu->card_capabilities->ca0108_chip) {
1300 snd_emu10k1_init_stereo_control(&controls[nctl++],
"EMU Capture Volume", gpr, 0);
1306 snd_emu10k1_init_stereo_control(&controls[nctl++],
"AMic Playback Volume", gpr, 0);
1311 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Mic Capture Volume", gpr, 0);
1320 snd_emu10k1_init_stereo_control(&controls[nctl++],
1321 emu->card_capabilities->ac97_chip ?
"Audigy CD Playback Volume" :
"CD Playback Volume",
1327 snd_emu10k1_init_stereo_control(&controls[nctl++],
1328 emu->card_capabilities->ac97_chip ?
"Audigy CD Capture Volume" :
"CD Capture Volume",
1346 snd_emu10k1_init_stereo_control(&controls[nctl++],
1347 emu->card_capabilities->ac97_chip ?
"Line2 Playback Volume" :
"Line Playback Volume",
1353 snd_emu10k1_init_stereo_control(&controls[nctl++],
1354 emu->card_capabilities->ac97_chip ?
"Line2 Capture Volume" :
"Line Capture Volume",
1361 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Analog Mix Playback Volume", gpr, 0);
1366 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Analog Mix Capture Volume", gpr, 0);
1372 snd_emu10k1_init_stereo_control(&controls[nctl++],
1373 emu->card_capabilities->ac97_chip ?
"Aux2 Playback Volume" :
"Aux Playback Volume",
1379 snd_emu10k1_init_stereo_control(&controls[nctl++],
1380 emu->card_capabilities->ac97_chip ?
"Aux2 Capture Volume" :
"Aux Capture Volume",
1387 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Front Playback Volume", gpr, 100);
1393 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Surround Playback Volume", gpr, 0);
1400 snd_emu10k1_init_mono_control(&controls[nctl++],
"Center Playback Volume", gpr, 0);
1405 snd_emu10k1_init_mono_control(&controls[nctl++],
"LFE Playback Volume", gpr, 0);
1408 if (emu->card_capabilities->spk71) {
1412 snd_emu10k1_init_stereo_control(&controls[nctl++],
"Side Playback Volume", gpr, 0);
1419 #define A_PUT_OUTPUT(out,src) A_OP(icode, &ptr, iACC3, A_EXTOUT(out), A_C_00000000, A_C_00000000, A_GPR(src))
1420 #define A_PUT_STEREO_OUTPUT(out1,out2,src) \
1421 {A_PUT_OUTPUT(out1,src); A_PUT_OUTPUT(out2,src+1);}
1423 #define _A_SWITCH(icode, ptr, dst, src, sw) \
1424 A_OP((icode), ptr, iMACINT0, dst, A_C_00000000, src, sw);
1425 #define A_SWITCH(icode, ptr, dst, src, sw) \
1426 _A_SWITCH(icode, ptr, A_GPR(dst), A_GPR(src), A_GPR(sw))
1427 #define _A_SWITCH_NEG(icode, ptr, dst, src) \
1428 A_OP((icode), ptr, iANDXOR, dst, src, A_C_00000001, A_C_00000001);
1429 #define A_SWITCH_NEG(icode, ptr, dst, src) \
1430 _A_SWITCH_NEG(icode, ptr, A_GPR(dst), A_GPR(src))
1442 if (emu->card_capabilities->spk71) {
1448 ctl = &controls[nctl + 0];
1450 strcpy(ctl->id.name,
"Tone Control - Bass");
1455 ctl->value[0] = ctl->value[1] = 20;
1457 ctl = &controls[nctl + 1];
1459 strcpy(ctl->id.name,
"Tone Control - Treble");
1464 ctl->value[0] = ctl->value[1] = 20;
1467 #define BASS_GPR 0x8c
1468 #define TREBLE_GPR 0x96
1470 for (z = 0; z < 5; z++) {
1472 for (j = 0; j < 2; j++) {
1477 for (z = 0; z < 4; z++) {
1479 for (j = 0; j < 2; j++) {
1480 k = 0xb0 + (z * 8) + (j * 4);
1481 l = 0xe0 + (z * 8) + (j * 4);
1509 for (z = 0; z < 8; z++) {
1512 A_SWITCH(icode, &ptr, tmp + 1, playback + z, tmp + 1);
1515 snd_emu10k1_init_stereo_onoff_control(controls + nctl++,
"Tone Control - Switch", gpr, 0);
1527 snd_emu10k1_init_mono_control(&controls[nctl++],
"Wave Master Playback Volume", gpr, 0);
1535 if (emu->card_capabilities->spk71)
1543 if (emu->card_capabilities->emu_model) {
1546 for (z = 0; z < 8; z++) {
1547 if (emu->card_capabilities->ca0108_chip) {
1557 gpr_map[gpr++] = 0x1008;
1558 gpr_map[gpr++] = 0xffff0000;
1559 for (z = 0; z < 2; z++) {
1564 A_SWITCH(icode, &ptr, tmp + 0, tmp + 2, gpr + z);
1567 if ((z==1) && (emu->card_capabilities->spdif_bug)) {
1584 #ifdef EMU10K1_CAPTURE_DIGITAL_OUT
1591 if (emu->card_capabilities->emu_model) {
1592 if (emu->card_capabilities->ca0108_chip) {
1594 for (z = 0; z < 0x10; z++) {
1595 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp,
1613 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_P16VIN(0x0),
A_FXBUS2(0) );
1615 gpr_map[gpr++] = 0x00000000;
1621 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(2) );
1623 gpr_map[gpr++] = 0x00000000;
1624 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(4) );
1626 gpr_map[gpr++] = 0x00000000;
1627 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(6) );
1631 gpr_map[gpr++] = 0x00000000;
1632 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(0x8) );
1635 gpr_map[gpr++] = 0x00000000;
1636 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(0xa) );
1638 gpr_map[gpr++] = 0x00000000;
1639 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(0
xc) );
1641 gpr_map[gpr++] = 0x00000000;
1642 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16,
A_GPR(gpr - 1),
A_FXBUS2(0
xe) );
1648 gpr_map[gpr++] = 0x00000000;
1649 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1655 gpr_map[gpr++] = 0x00000000;
1656 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1662 gpr_map[gpr++] = 0x00000000;
1663 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1669 gpr_map[gpr++] = 0x00000000;
1670 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1676 gpr_map[gpr++] = 0x00000000;
1677 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1683 gpr_map[gpr++] = 0x00000000;
1684 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1690 gpr_map[gpr++] = 0x00000000;
1691 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1697 gpr_map[gpr++] = 0x00000000;
1698 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1707 for (z = 4; z < 8; z++) {
1710 for (z = 0
xc; z < 0x10; z++) {
1717 for (z = 0; z < 16; z++) {
1734 A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0);
1736 seg = snd_enter_user();
1739 emu->support_tlv = 1;
1740 err = snd_emu10k1_icode_poke(emu, icode);
1741 emu->support_tlv = 0;
1742 snd_leave_user(seg);
1746 if (icode !=
NULL) {
1773 OP(icode, ptr,
iMAC0, dst, dst, src, vol);
1784 #define VOLUME(icode, ptr, dst, src, vol) \
1785 _volume(icode, ptr, GPR(dst), GPR(src), GPR(vol))
1786 #define VOLUME_IN(icode, ptr, dst, src, vol) \
1787 _volume(icode, ptr, GPR(dst), EXTIN(src), GPR(vol))
1788 #define VOLUME_ADD(icode, ptr, dst, src, vol) \
1789 _volume_add(icode, ptr, GPR(dst), GPR(src), GPR(vol))
1790 #define VOLUME_ADDIN(icode, ptr, dst, src, vol) \
1791 _volume_add(icode, ptr, GPR(dst), EXTIN(src), GPR(vol))
1792 #define VOLUME_OUT(icode, ptr, dst, src, vol) \
1793 _volume_out(icode, ptr, EXTOUT(dst), GPR(src), GPR(vol))
1794 #define _SWITCH(icode, ptr, dst, src, sw) \
1795 OP((icode), ptr, iMACINT0, dst, C_00000000, src, sw);
1796 #define SWITCH(icode, ptr, dst, src, sw) \
1797 _SWITCH(icode, ptr, GPR(dst), GPR(src), GPR(sw))
1798 #define SWITCH_IN(icode, ptr, dst, src, sw) \
1799 _SWITCH(icode, ptr, GPR(dst), EXTIN(src), GPR(sw))
1800 #define _SWITCH_NEG(icode, ptr, dst, src) \
1801 OP((icode), ptr, iANDXOR, dst, src, C_00000001, C_00000001);
1802 #define SWITCH_NEG(icode, ptr, dst, src) \
1803 _SWITCH_NEG(icode, ptr, GPR(dst), GPR(src))
1806 static int __devinit _snd_emu10k1_init_efx(
struct snd_emu10k1 *emu)
1819 kcalloc(256 + 160 + 160 + 2 * 512,
sizeof(
u_int32_t),
1835 for (i = 0; i < 256; i++)
1839 for (i = 0; i < 160; i++)
1840 set_bit(i, icode->tram_valid);
1842 strcpy(icode->
name,
"SB Live! FX8010 code for ALSA v1.2 by Jaroslav Kysela");
1885 gpr_map[gpr + 0] = 0xfffff000;
1886 gpr_map[gpr + 1] = 0xffff0000;
1887 gpr_map[gpr + 2] = 0x70000000;
1888 gpr_map[gpr + 3] = 0x00000007;
1889 gpr_map[gpr + 4] = 0x001f << 11;
1890 gpr_map[gpr + 5] = 0x001c << 11;
1891 gpr_map[gpr + 6] = (0x22 - 0x01) - 1;
1892 gpr_map[gpr + 7] = (0x22 - 0x06) - 1;
1893 gpr_map[gpr + 8] = 0x2000000 + (2<<11);
1894 gpr_map[gpr + 9] = 0x4000000 + (2<<11);
1895 gpr_map[gpr + 10] = 1<<11;
1896 gpr_map[gpr + 11] = (0x24 - 0x0a) - 1;
1897 gpr_map[gpr + 12] = 0;
1950 for (z = 0; z < 2; z++)
1951 VOLUME(icode, &ptr, playback + z, z, gpr + z);
1952 snd_emu10k1_init_stereo_control(controls + i++,
"Wave Playback Volume", gpr, 100);
1956 for (z = 0; z < 2; z++)
1957 VOLUME(icode, &ptr, playback + 2 + z, z, gpr + z);
1958 snd_emu10k1_init_stereo_control(controls + i++,
"Wave Surround Playback Volume", gpr, 0);
1964 VOLUME(icode, &ptr, playback + 4, tmp + 0, gpr);
1965 snd_emu10k1_init_mono_control(controls + i++,
"Wave Center Playback Volume", gpr++, 0);
1966 VOLUME(icode, &ptr, playback + 5, tmp + 0, gpr);
1967 snd_emu10k1_init_mono_control(controls + i++,
"Wave LFE Playback Volume", gpr++, 0);
1970 for (z = 0; z < 2; z++) {
1971 SWITCH(icode, &ptr, tmp + 0, z, gpr + 2 + z);
1972 VOLUME(icode, &ptr, capture + z, tmp + 0, gpr + z);
1974 snd_emu10k1_init_stereo_control(controls + i++,
"Wave Capture Volume", gpr, 0);
1975 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Wave Capture Switch", gpr + 2, 0);
1979 for (z = 0; z < 2; z++)
1980 VOLUME_ADD(icode, &ptr, playback + z, 2 + z, gpr + z);
1981 snd_emu10k1_init_stereo_control(controls + i++,
"Synth Playback Volume", gpr, 100);
1985 for (z = 0; z < 2; z++) {
1986 SWITCH(icode, &ptr, tmp + 0, 2 + z, gpr + 2 + z);
1987 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
1989 snd_emu10k1_init_stereo_control(controls + i++,
"Synth Capture Volume", gpr, 0);
1990 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Synth Capture Switch", gpr + 2, 0);
1994 for (z = 0; z < 2; z++)
1995 VOLUME_ADD(icode, &ptr, playback + 2 + z, 4 + z, gpr + z);
1996 snd_emu10k1_init_stereo_control(controls + i++,
"Surround Digital Playback Volume", gpr, 100);
2000 for (z = 0; z < 2; z++) {
2001 SWITCH(icode, &ptr, tmp + 0, 4 + z, gpr + 2 + z);
2002 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2004 snd_emu10k1_init_stereo_control(controls + i++,
"Surround Capture Volume", gpr, 0);
2005 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Surround Capture Switch", gpr + 2, 0);
2009 VOLUME_ADD(icode, &ptr, playback + 4, 6, gpr);
2010 snd_emu10k1_init_mono_control(controls + i++,
"Center Digital Playback Volume", gpr++, 100);
2013 VOLUME_ADD(icode, &ptr, playback + 5, 7, gpr);
2014 snd_emu10k1_init_mono_control(controls + i++,
"LFE Digital Playback Volume", gpr++, 100);
2017 for (z = 0; z < 2; z++)
2018 VOLUME_ADD(icode, &ptr, playback + z, 10 + z, gpr + z);
2019 snd_emu10k1_init_stereo_control(controls + i++,
"Front Playback Volume", gpr, 100);
2023 for (z = 0; z < 2; z++) {
2024 SWITCH(icode, &ptr, tmp + 0, 10 + z, gpr + 2);
2025 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2027 snd_emu10k1_init_stereo_control(controls + i++,
"Front Capture Volume", gpr, 0);
2028 snd_emu10k1_init_mono_onoff_control(controls + i++,
"Front Capture Switch", gpr + 2, 0);
2039 snd_emu10k1_init_stereo_control(controls + i++,
"AC97 Playback Volume", gpr-2, 0);
2043 snd_emu10k1_init_stereo_control(controls + i++,
"AC97 Capture Volume", gpr-2, 100);
2048 for (z = 0; z < 2; z++)
2054 for (z = 0; z < 2; z++) {
2056 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2065 for (z = 0; z < 2; z++)
2067 snd_emu10k1_init_stereo_control(controls + i++,
"Zoom Video Playback Volume", gpr, 0);
2071 for (z = 0; z < 2; z++) {
2073 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2075 snd_emu10k1_init_stereo_control(controls + i++,
"Zoom Video Capture Volume", gpr, 0);
2076 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Zoom Video Capture Switch", gpr + 2, 0);
2082 for (z = 0; z < 2; z++)
2088 for (z = 0; z < 2; z++) {
2090 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2099 for (z = 0; z < 2; z++)
2101 snd_emu10k1_init_stereo_control(controls + i++,
"Line LiveDrive Playback Volume", gpr, 0);
2105 for (z = 0; z < 2; z++) {
2107 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2109 snd_emu10k1_init_stereo_control(controls + i++,
"Line LiveDrive Capture Volume", gpr, 0);
2110 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Line LiveDrive Capture Switch", gpr + 2, 0);
2116 for (z = 0; z < 2; z++)
2122 for (z = 0; z < 2; z++) {
2124 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2133 for (z = 0; z < 2; z++)
2135 snd_emu10k1_init_stereo_control(controls + i++,
"Line2 LiveDrive Playback Volume", gpr, 0);
2136 controls[i-1].
id.index = 1;
2140 for (z = 0; z < 2; z++) {
2142 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
2144 snd_emu10k1_init_stereo_control(controls + i++,
"Line2 LiveDrive Capture Volume", gpr, 0);
2145 controls[i-1].
id.index = 1;
2146 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Line2 LiveDrive Capture Switch", gpr + 2, 0);
2147 controls[i-1].
id.index = 1;
2161 ctl = &controls[i + 0];
2163 strcpy(ctl->id.name,
"Tone Control - Bass");
2168 ctl->value[0] = ctl->value[1] = 20;
2169 ctl->tlv = snd_emu10k1_bass_treble_db_scale;
2171 ctl = &controls[i + 1];
2173 strcpy(ctl->id.name,
"Tone Control - Treble");
2178 ctl->value[0] = ctl->value[1] = 20;
2179 ctl->tlv = snd_emu10k1_bass_treble_db_scale;
2182 #define BASS_GPR 0x8c
2183 #define TREBLE_GPR 0x96
2185 for (z = 0; z < 5; z++) {
2187 for (j = 0; j < 2; j++) {
2192 for (z = 0; z < 3; z++) {
2194 for (j = 0; j < 2; j++) {
2195 k = 0xa0 + (z * 8) + (j * 4);
2196 l = 0xd0 + (z * 8) + (j * 4);
2224 for (z = 0; z < 6; z++) {
2227 SWITCH(icode, &ptr, tmp + 1, playback + z, tmp + 1);
2230 snd_emu10k1_init_stereo_onoff_control(controls + i++,
"Tone Control - Switch", gpr, 0);
2239 for (z = 0; z < 2; z++)
2246 for (z = 0; z < 2; z++) {
2247 SWITCH(icode, &ptr, tmp + 0, 8 + z, gpr + z);
2251 #ifdef EMU10K1_CAPTURE_DIGITAL_OUT
2263 for (z = 0; z < 2; z++) {
2265 SWITCH_NEG(icode, &ptr, tmp + 1, gpr + 2 + z);
2271 snd_emu10k1_init_stereo_control(controls + i++,
"Headphone Playback Volume", gpr + 0, 0);
2272 controls[i-1].
id.index = 1;
2273 snd_emu10k1_init_mono_onoff_control(controls + i++,
"Headphone Center Playback Switch", gpr + 2, 0);
2274 controls[i-1].
id.index = 1;
2275 snd_emu10k1_init_mono_onoff_control(controls + i++,
"Headphone LFE Playback Switch", gpr + 3, 0);
2276 controls[i-1].
id.index = 1;
2282 for (z = 0; z < 2; z++)
2286 for (z = 0; z < 2; z++)
2290 #ifndef EMU10K1_CENTER_LFE_FROM_FRONT
2300 #ifndef EMU10K1_CENTER_LFE_FROM_FRONT
2309 #ifndef EMU10K1_CAPTURE_DIGITAL_OUT
2310 for (z = 0; z < 2; z++)
2318 if (emu->card_capabilities->sblive51) {
2332 for (z = 4; z < 14; z++)
2335 for (z = 0; z < 16; z++)
2357 seg = snd_enter_user();
2360 emu->support_tlv = 1;
2361 err = snd_emu10k1_icode_poke(emu, icode);
2362 emu->support_tlv = 0;
2363 snd_leave_user(seg);
2365 err = snd_emu10k1_ipcm_poke(emu, ipcm);
2369 if (icode !=
NULL) {
2379 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
2381 return _snd_emu10k1_audigy_init_efx(emu);
2383 return _snd_emu10k1_init_efx(emu);
2396 int snd_emu10k1_fx8010_tone_control_activate(
struct snd_emu10k1 *emu,
int output)
2398 if (output < 0 || output >= 6)
2404 int snd_emu10k1_fx8010_tone_control_deactivate(
struct snd_emu10k1 *emu,
int output)
2406 if (output < 0 || output >= 6)
2419 size = (size - 1) >> 13;
2425 size = 0x2000 << size_reg;
2427 if ((emu->fx8010.etram_pages.bytes / 2) ==
size)
2429 spin_lock_irq(&emu->emu_lock);
2430 outl(HCFG_LOCKTANKCACHE_MASK |
inl(emu->port +
HCFG), emu->port +
HCFG);
2431 spin_unlock_irq(&emu->emu_lock);
2434 if (emu->fx8010.etram_pages.area !=
NULL) {
2436 emu->fx8010.etram_pages.area =
NULL;
2437 emu->fx8010.etram_pages.bytes = 0;
2442 size * 2, &emu->fx8010.etram_pages) < 0)
2444 memset(emu->fx8010.etram_pages.area, 0, size * 2);
2447 spin_lock_irq(&emu->emu_lock);
2448 outl(
inl(emu->port +
HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port +
HCFG);
2449 spin_unlock_irq(&emu->emu_lock);
2460 static void copy_string(
char *
dst,
char *
src,
char *null,
int idx)
2463 sprintf(dst,
"%s %02X", null, idx);
2471 char **fxbus, **extin, **extout;
2472 unsigned short fxbus_mask, extin_mask, extout_mask;
2478 extin = emu->audigy ? audigy_ins : creative_ins;
2479 extout = emu->audigy ? audigy_outs : creative_outs;
2480 fxbus_mask = emu->fx8010.fxbus_mask;
2481 extin_mask = emu->fx8010.extin_mask;
2482 extout_mask = emu->fx8010.extout_mask;
2483 for (res = 0; res < 16; res++, fxbus++, extin++, extout++) {
2484 copy_string(info->
fxbus_names[res], fxbus_mask & (1 << res) ? *fxbus :
NULL,
"FXBUS", res);
2485 copy_string(info->
extin_names[res], extin_mask & (1 << res) ? *extin :
NULL,
"Unused", res);
2486 copy_string(info->
extout_names[res], extout_mask & (1 << res) ? *extout :
NULL,
"Unused", res);
2488 for (res = 16; res < 32; res++, extout++)
2489 copy_string(info->
extout_names[res], extout_mask & (1 << res) ? *extout :
NULL,
"Unused", res);
2505 emu->support_tlv = 1;
2524 return PTR_ERR(icode);
2525 res = snd_emu10k1_icode_poke(emu, icode);
2531 return PTR_ERR(icode);
2532 res = snd_emu10k1_icode_peek(emu, icode);
2533 if (res == 0 &&
copy_to_user(argp, icode,
sizeof(*icode))) {
2542 return PTR_ERR(ipcm);
2543 res = snd_emu10k1_ipcm_poke(emu, ipcm);
2549 return PTR_ERR(ipcm);
2550 res = snd_emu10k1_ipcm_peek(emu, ipcm);
2551 if (res == 0 &&
copy_to_user(argp, ipcm,
sizeof(*ipcm))) {
2560 if (
get_user(addr, (
unsigned int __user *)argp))
2598 if (
get_user(addr, (
unsigned int __user *)argp))
2608 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg |= A_DBG_SINGLE_STEP | A_DBG_STEP_ADDR | addr);
2617 if (
put_user(addr, (
unsigned int __user *)argp))
2624 static int snd_emu10k1_fx8010_release(
struct snd_hwdep * hw,
struct file *file)
2636 if ((err =
snd_hwdep_new(emu->card,
"FX8010", device, &hw)) < 0)
2640 hw->
ops.open = snd_emu10k1_fx8010_open;
2641 hw->
ops.ioctl = snd_emu10k1_fx8010_ioctl;
2642 hw->
ops.release = snd_emu10k1_fx8010_release;
2649 #ifdef CONFIG_PM_SLEEP
2650 int __devinit snd_emu10k1_efx_alloc_pm_buffer(
struct snd_emu10k1 *emu)
2654 len = emu->audigy ? 0x200 : 0x100;
2656 if (! emu->saved_gpr)
2658 len = emu->audigy ? 0x100 : 0xa0;
2661 if (! emu->tram_val_saved || ! emu->tram_addr_saved)
2663 len = emu->audigy ? 2 * 1024 : 2 * 512;
2664 emu->saved_icode =
vmalloc(len * 4);
2665 if (! emu->saved_icode)
2670 void snd_emu10k1_efx_free_pm_buffer(
struct snd_emu10k1 *emu)
2672 kfree(emu->saved_gpr);
2673 kfree(emu->tram_val_saved);
2674 kfree(emu->tram_addr_saved);
2675 vfree(emu->saved_icode);
2681 void snd_emu10k1_efx_suspend(
struct snd_emu10k1 *emu)
2685 len = emu->audigy ? 0x200 : 0x100;
2686 for (i = 0; i < len; i++)
2689 len = emu->audigy ? 0x100 : 0xa0;
2690 for (i = 0; i < len; i++) {
2694 emu->tram_addr_saved[
i] >>= 12;
2695 emu->tram_addr_saved[
i] |=
2700 len = emu->audigy ? 2 * 1024 : 2 * 512;
2701 for (i = 0; i < len; i++)
2705 void snd_emu10k1_efx_resume(
struct snd_emu10k1 *emu)
2710 if (emu->fx8010.etram_pages.bytes > 0) {
2711 unsigned size, size_reg = 0;
2712 size = emu->fx8010.etram_pages.bytes / 2;
2713 size = (size - 1) >> 13;
2718 outl(HCFG_LOCKTANKCACHE_MASK |
inl(emu->port +
HCFG), emu->port +
HCFG);
2721 outl(
inl(emu->port +
HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port +
HCFG);
2729 len = emu->audigy ? 0x200 : 0x100;
2730 for (i = 0; i < len; i++)
2733 len = emu->audigy ? 0x100 : 0xa0;
2734 for (i = 0; i < len; i++) {
2736 emu->tram_val_saved[i]);
2739 emu->tram_addr_saved[i]);
2742 emu->tram_addr_saved[i] << 12);
2744 emu->tram_addr_saved[i] >> 20);
2748 len = emu->audigy ? 2 * 1024 : 2 * 512;
2749 for (i = 0; i < len; i++)
2750 snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]);