Lines Matching +full:tcb +full:- +full:capture

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
11 * --
14 * --
31 #if 0 /* for testing purposes - digital out -> capture */
34 #if 0 /* for testing purposes - set S/PDIF to AC3 output */
37 #if 0 /* for testing purposes - feed the front signal to Center/LFE outputs */
43 MODULE_PARM_DESC(high_res_gpr_volume, "GPR mixer controls use 31-bit range.");
117 /* 0x0a */ "PCM Capture Left",
118 /* 0x0b */ "PCM Capture Right",
119 /* 0x0c */ "MIC Capture",
160 /* 0x12 */ "ADC Capture Left",
161 /* 0x13 */ "ADC Capture Right",
290 static const DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
294 static const DECLARE_TLV_DB_SCALE(snd_emu10k1_bass_treble_db_scale, -1200, 60, 0);
307 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; in snd_emu10k1_gpr_ctl_info()
309 if (ctl->min == 0 && ctl->max == 1) in snd_emu10k1_gpr_ctl_info()
310 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_emu10k1_gpr_ctl_info()
312 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_emu10k1_gpr_ctl_info()
313 uinfo->count = ctl->vcount; in snd_emu10k1_gpr_ctl_info()
314 uinfo->value.integer.min = ctl->min; in snd_emu10k1_gpr_ctl_info()
315 uinfo->value.integer.max = ctl->max; in snd_emu10k1_gpr_ctl_info()
323 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; in snd_emu10k1_gpr_ctl_get()
327 spin_lock_irqsave(&emu->reg_lock, flags); in snd_emu10k1_gpr_ctl_get()
328 for (i = 0; i < ctl->vcount; i++) in snd_emu10k1_gpr_ctl_get()
329 ucontrol->value.integer.value[i] = ctl->value[i]; in snd_emu10k1_gpr_ctl_get()
330 spin_unlock_irqrestore(&emu->reg_lock, flags); in snd_emu10k1_gpr_ctl_get()
338 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; in snd_emu10k1_gpr_ctl_put()
344 spin_lock_irqsave(&emu->reg_lock, flags); in snd_emu10k1_gpr_ctl_put()
345 for (i = 0; i < ctl->vcount; i++) { in snd_emu10k1_gpr_ctl_put()
346 nval = ucontrol->value.integer.value[i]; in snd_emu10k1_gpr_ctl_put()
347 if (nval < ctl->min) in snd_emu10k1_gpr_ctl_put()
348 nval = ctl->min; in snd_emu10k1_gpr_ctl_put()
349 if (nval > ctl->max) in snd_emu10k1_gpr_ctl_put()
350 nval = ctl->max; in snd_emu10k1_gpr_ctl_put()
351 if (nval != ctl->value[i]) in snd_emu10k1_gpr_ctl_put()
353 val = ctl->value[i] = nval; in snd_emu10k1_gpr_ctl_put()
354 switch (ctl->translation) { in snd_emu10k1_gpr_ctl_put()
356 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, val); in snd_emu10k1_gpr_ctl_put()
359 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]); in snd_emu10k1_gpr_ctl_put()
362 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { in snd_emu10k1_gpr_ctl_put()
363 change = -EIO; in snd_emu10k1_gpr_ctl_put()
367 … snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]); in snd_emu10k1_gpr_ctl_put()
370 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { in snd_emu10k1_gpr_ctl_put()
371 change = -EIO; in snd_emu10k1_gpr_ctl_put()
375 …snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]); in snd_emu10k1_gpr_ctl_put()
378 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, onoff_table[val]); in snd_emu10k1_gpr_ctl_put()
383 spin_unlock_irqrestore(&emu->reg_lock, flags); in snd_emu10k1_gpr_ctl_put()
395 irq = emu->fx8010.irq_handlers; in snd_emu10k1_fx8010_interrupt()
397 nirq = irq->next; /* irq ptr can be removed from list */ in snd_emu10k1_fx8010_interrupt()
398 if (snd_emu10k1_ptr_read(emu, emu->gpr_base + irq->gpr_running, 0) & 0xffff0000) { in snd_emu10k1_fx8010_interrupt()
399 if (irq->handler) in snd_emu10k1_fx8010_interrupt()
400 irq->handler(emu, irq->private_data); in snd_emu10k1_fx8010_interrupt()
401 snd_emu10k1_ptr_write(emu, emu->gpr_base + irq->gpr_running, 0, 1); in snd_emu10k1_fx8010_interrupt()
415 irq->handler = handler; in snd_emu10k1_fx8010_register_irq_handler()
416 irq->gpr_running = gpr_running; in snd_emu10k1_fx8010_register_irq_handler()
417 irq->private_data = private_data; in snd_emu10k1_fx8010_register_irq_handler()
418 irq->next = NULL; in snd_emu10k1_fx8010_register_irq_handler()
419 spin_lock_irqsave(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_register_irq_handler()
420 if (emu->fx8010.irq_handlers == NULL) { in snd_emu10k1_fx8010_register_irq_handler()
421 emu->fx8010.irq_handlers = irq; in snd_emu10k1_fx8010_register_irq_handler()
422 emu->dsp_interrupt = snd_emu10k1_fx8010_interrupt; in snd_emu10k1_fx8010_register_irq_handler()
425 irq->next = emu->fx8010.irq_handlers; in snd_emu10k1_fx8010_register_irq_handler()
426 emu->fx8010.irq_handlers = irq; in snd_emu10k1_fx8010_register_irq_handler()
428 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_register_irq_handler()
438 spin_lock_irqsave(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_unregister_irq_handler()
439 if ((tmp = emu->fx8010.irq_handlers) == irq) { in snd_emu10k1_fx8010_unregister_irq_handler()
440 emu->fx8010.irq_handlers = tmp->next; in snd_emu10k1_fx8010_unregister_irq_handler()
441 if (emu->fx8010.irq_handlers == NULL) { in snd_emu10k1_fx8010_unregister_irq_handler()
443 emu->dsp_interrupt = NULL; in snd_emu10k1_fx8010_unregister_irq_handler()
446 while (tmp && tmp->next != irq) in snd_emu10k1_fx8010_unregister_irq_handler()
447 tmp = tmp->next; in snd_emu10k1_fx8010_unregister_irq_handler()
449 tmp->next = tmp->next->next; in snd_emu10k1_fx8010_unregister_irq_handler()
451 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_unregister_irq_handler()
466 code = icode->code + (*ptr) * 2; in snd_emu10k1_write_op()
467 set_bit(*ptr, icode->code_valid); in snd_emu10k1_write_op()
483 code = icode->code + (*ptr) * 2; in snd_emu10k1_audigy_write_op()
484 set_bit(*ptr, icode->code_valid); in snd_emu10k1_audigy_write_op()
495 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; in snd_emu10k1_efx_write()
501 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; in snd_emu10k1_efx_read()
512 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) { in snd_emu10k1_gpr_poke()
513 if (!test_bit(gpr, icode->gpr_valid)) in snd_emu10k1_gpr_poke()
516 val = icode->gpr_map[gpr]; in snd_emu10k1_gpr_poke()
517 else if (get_user(val, (__user u32 *)&icode->gpr_map[gpr])) in snd_emu10k1_gpr_poke()
518 return -EFAULT; in snd_emu10k1_gpr_poke()
519 snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val); in snd_emu10k1_gpr_poke()
530 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) { in snd_emu10k1_gpr_peek()
531 set_bit(gpr, icode->gpr_valid); in snd_emu10k1_gpr_peek()
532 val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0); in snd_emu10k1_gpr_peek()
533 if (put_user(val, (__user u32 *)&icode->gpr_map[gpr])) in snd_emu10k1_gpr_peek()
534 return -EFAULT; in snd_emu10k1_gpr_peek()
546 for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) { in snd_emu10k1_tram_poke()
547 if (!test_bit(tram, icode->tram_valid)) in snd_emu10k1_tram_poke()
550 val = icode->tram_data_map[tram]; in snd_emu10k1_tram_poke()
551 addr = icode->tram_addr_map[tram]; in snd_emu10k1_tram_poke()
553 if (get_user(val, (__user __u32 *)&icode->tram_data_map[tram]) || in snd_emu10k1_tram_poke()
554 get_user(addr, (__user __u32 *)&icode->tram_addr_map[tram])) in snd_emu10k1_tram_poke()
555 return -EFAULT; in snd_emu10k1_tram_poke()
558 if (!emu->audigy) { in snd_emu10k1_tram_poke()
574 memset(icode->tram_valid, 0, sizeof(icode->tram_valid)); in snd_emu10k1_tram_peek()
575 for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) { in snd_emu10k1_tram_peek()
576 set_bit(tram, icode->tram_valid); in snd_emu10k1_tram_peek()
578 if (!emu->audigy) { in snd_emu10k1_tram_peek()
584 if (put_user(val, (__user u32 *)&icode->tram_data_map[tram]) || in snd_emu10k1_tram_peek()
585 put_user(addr, (__user u32 *)&icode->tram_addr_map[tram])) in snd_emu10k1_tram_peek()
586 return -EFAULT; in snd_emu10k1_tram_peek()
597 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { in snd_emu10k1_code_poke()
598 if (!test_bit(pc / 2, icode->code_valid)) in snd_emu10k1_code_poke()
601 lo = icode->code[pc + 0]; in snd_emu10k1_code_poke()
602 hi = icode->code[pc + 1]; in snd_emu10k1_code_poke()
604 if (get_user(lo, (__user u32 *)&icode->code[pc + 0]) || in snd_emu10k1_code_poke()
605 get_user(hi, (__user u32 *)&icode->code[pc + 1])) in snd_emu10k1_code_poke()
606 return -EFAULT; in snd_emu10k1_code_poke()
619 memset(icode->code_valid, 0, sizeof(icode->code_valid)); in snd_emu10k1_code_peek()
620 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { in snd_emu10k1_code_peek()
621 set_bit(pc / 2, icode->code_valid); in snd_emu10k1_code_peek()
623 (__user u32 *)&icode->code[pc + 0])) in snd_emu10k1_code_peek()
624 return -EFAULT; in snd_emu10k1_code_peek()
626 (__user u32 *)&icode->code[pc + 1])) in snd_emu10k1_code_peek()
627 return -EFAULT; in snd_emu10k1_code_peek()
640 list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) { in snd_emu10k1_look_for_ctl()
641 kcontrol = ctl->kcontrol; in snd_emu10k1_look_for_ctl()
642 if (kcontrol->id.iface == id->iface && in snd_emu10k1_look_for_ctl()
643 !strcmp(kcontrol->id.name, id->name) && in snd_emu10k1_look_for_ctl()
644 kcontrol->id.index == id->index) in snd_emu10k1_look_for_ctl()
688 if (emu->support_tlv) { in copy_gctl()
692 return -EFAULT; in copy_gctl()
701 return -EFAULT; in copy_gctl()
702 dst->tlv = NULL; in copy_gctl()
715 if (emu->support_tlv) in copy_gctl_to_user()
731 return -EFAULT; in copy_ctl_elem_id()
745 for (i = 0; i < icode->gpr_del_control_count; i++) { in snd_emu10k1_verify_controls()
746 err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, in snd_emu10k1_verify_controls()
751 return -ENOENT; in snd_emu10k1_verify_controls()
755 return -ENOMEM; in snd_emu10k1_verify_controls()
757 for (i = 0; i < icode->gpr_add_control_count; i++) { in snd_emu10k1_verify_controls()
758 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i, in snd_emu10k1_verify_controls()
760 err = -EFAULT; in snd_emu10k1_verify_controls()
763 if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) in snd_emu10k1_verify_controls()
765 gctl_id = (struct snd_ctl_elem_id *)&gctl->id; in snd_emu10k1_verify_controls()
766 down_read(&emu->card->controls_rwsem); in snd_emu10k1_verify_controls()
767 if (snd_ctl_find_id(emu->card, gctl_id)) { in snd_emu10k1_verify_controls()
768 up_read(&emu->card->controls_rwsem); in snd_emu10k1_verify_controls()
769 err = -EEXIST; in snd_emu10k1_verify_controls()
772 up_read(&emu->card->controls_rwsem); in snd_emu10k1_verify_controls()
773 if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && in snd_emu10k1_verify_controls()
774 gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { in snd_emu10k1_verify_controls()
775 err = -EINVAL; in snd_emu10k1_verify_controls()
779 for (i = 0; i < icode->gpr_list_control_count; i++) { in snd_emu10k1_verify_controls()
781 if (copy_gctl(emu, gctl, icode->gpr_list_controls, i, in snd_emu10k1_verify_controls()
783 err = -EFAULT; in snd_emu10k1_verify_controls()
796 ctl = (struct snd_emu10k1_fx8010_ctl *) kctl->private_value; in snd_emu10k1_ctl_private_free()
797 kctl->private_value = 0; in snd_emu10k1_ctl_private_free()
798 list_del(&ctl->list); in snd_emu10k1_ctl_private_free()
800 kfree(kctl->tlv.p); in snd_emu10k1_ctl_private_free()
820 err = -ENOMEM; in snd_emu10k1_add_controls()
824 for (i = 0; i < icode->gpr_add_control_count; i++) { in snd_emu10k1_add_controls()
825 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i, in snd_emu10k1_add_controls()
827 err = -EFAULT; in snd_emu10k1_add_controls()
830 gctl_id = (struct snd_ctl_elem_id *)&gctl->id; in snd_emu10k1_add_controls()
831 if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && in snd_emu10k1_add_controls()
832 gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { in snd_emu10k1_add_controls()
833 err = -EINVAL; in snd_emu10k1_add_controls()
836 if (!*gctl_id->name) { in snd_emu10k1_add_controls()
837 err = -EINVAL; in snd_emu10k1_add_controls()
840 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); in snd_emu10k1_add_controls()
842 knew.iface = gctl_id->iface; in snd_emu10k1_add_controls()
843 knew.name = gctl_id->name; in snd_emu10k1_add_controls()
844 knew.index = gctl_id->index; in snd_emu10k1_add_controls()
845 knew.device = gctl_id->device; in snd_emu10k1_add_controls()
846 knew.subdevice = gctl_id->subdevice; in snd_emu10k1_add_controls()
848 knew.tlv.p = copy_tlv((const unsigned int __user *)gctl->tlv, in_kernel); in snd_emu10k1_add_controls()
855 nctl->vcount = gctl->vcount; in snd_emu10k1_add_controls()
856 nctl->count = gctl->count; in snd_emu10k1_add_controls()
858 nctl->gpr[j] = gctl->gpr[j]; in snd_emu10k1_add_controls()
859 nctl->value[j] = ~gctl->value[j]; /* inverted, we want to write new value in gpr_ctl_put() */ in snd_emu10k1_add_controls()
860 val->value.integer.value[j] = gctl->value[j]; in snd_emu10k1_add_controls()
862 nctl->min = gctl->min; in snd_emu10k1_add_controls()
863 nctl->max = gctl->max; in snd_emu10k1_add_controls()
864 nctl->translation = gctl->translation; in snd_emu10k1_add_controls()
868 err = -ENOMEM; in snd_emu10k1_add_controls()
874 if ((err = snd_ctl_add(emu->card, kctl = snd_ctl_new1(&knew, emu))) < 0) { in snd_emu10k1_add_controls()
879 kctl->private_free = snd_emu10k1_ctl_private_free; in snd_emu10k1_add_controls()
880 ctl->kcontrol = kctl; in snd_emu10k1_add_controls()
881 list_add_tail(&ctl->list, &emu->fx8010.gpr_ctl); in snd_emu10k1_add_controls()
884 nctl->list = ctl->list; in snd_emu10k1_add_controls()
885 nctl->kcontrol = ctl->kcontrol; in snd_emu10k1_add_controls()
887 snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_emu10k1_add_controls()
888 SNDRV_CTL_EVENT_MASK_INFO, &ctl->kcontrol->id); in snd_emu10k1_add_controls()
890 snd_emu10k1_gpr_ctl_put(ctl->kcontrol, val); in snd_emu10k1_add_controls()
906 struct snd_card *card = emu->card; in snd_emu10k1_del_controls()
909 for (i = 0; i < icode->gpr_del_control_count; i++) { in snd_emu10k1_del_controls()
910 err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, in snd_emu10k1_del_controls()
914 down_write(&card->controls_rwsem); in snd_emu10k1_del_controls()
917 snd_ctl_remove(card, ctl->kcontrol); in snd_emu10k1_del_controls()
918 up_write(&card->controls_rwsem); in snd_emu10k1_del_controls()
934 return -ENOMEM; in snd_emu10k1_list_controls()
936 list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) { in snd_emu10k1_list_controls()
938 if (icode->gpr_list_controls && in snd_emu10k1_list_controls()
939 i < icode->gpr_list_control_count) { in snd_emu10k1_list_controls()
941 id = &ctl->kcontrol->id; in snd_emu10k1_list_controls()
942 gctl->id.iface = (__force int)id->iface; in snd_emu10k1_list_controls()
943 strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name)); in snd_emu10k1_list_controls()
944 gctl->id.index = id->index; in snd_emu10k1_list_controls()
945 gctl->id.device = id->device; in snd_emu10k1_list_controls()
946 gctl->id.subdevice = id->subdevice; in snd_emu10k1_list_controls()
947 gctl->vcount = ctl->vcount; in snd_emu10k1_list_controls()
948 gctl->count = ctl->count; in snd_emu10k1_list_controls()
950 gctl->gpr[j] = ctl->gpr[j]; in snd_emu10k1_list_controls()
951 gctl->value[j] = ctl->value[j]; in snd_emu10k1_list_controls()
953 gctl->min = ctl->min; in snd_emu10k1_list_controls()
954 gctl->max = ctl->max; in snd_emu10k1_list_controls()
955 gctl->translation = ctl->translation; in snd_emu10k1_list_controls()
956 if (copy_gctl_to_user(emu, icode->gpr_list_controls, in snd_emu10k1_list_controls()
959 return -EFAULT; in snd_emu10k1_list_controls()
964 icode->gpr_list_control_total = total; in snd_emu10k1_list_controls()
975 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_icode_poke()
979 strlcpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name)); in snd_emu10k1_icode_poke()
980 /* stop FX processor - this may be dangerous, but it's better to miss in snd_emu10k1_icode_poke()
981 some samples than generate wrong ones - [jk] */ in snd_emu10k1_icode_poke()
982 if (emu->audigy) in snd_emu10k1_icode_poke()
983 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); in snd_emu10k1_icode_poke()
985 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_icode_poke()
1003 if (emu->audigy) in snd_emu10k1_icode_poke()
1004 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); in snd_emu10k1_icode_poke()
1006 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); in snd_emu10k1_icode_poke()
1008 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_icode_poke()
1017 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_icode_peek()
1018 strlcpy(icode->name, emu->fx8010.name, sizeof(icode->name)); in snd_emu10k1_icode_peek()
1027 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_icode_peek()
1038 if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) in snd_emu10k1_ipcm_poke()
1039 return -EINVAL; in snd_emu10k1_ipcm_poke()
1040 ipcm->substream = array_index_nospec(ipcm->substream, in snd_emu10k1_ipcm_poke()
1042 if (ipcm->channels > 32) in snd_emu10k1_ipcm_poke()
1043 return -EINVAL; in snd_emu10k1_ipcm_poke()
1044 pcm = &emu->fx8010.pcm[ipcm->substream]; in snd_emu10k1_ipcm_poke()
1045 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_ipcm_poke()
1046 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_poke()
1047 if (pcm->opened) { in snd_emu10k1_ipcm_poke()
1048 err = -EBUSY; in snd_emu10k1_ipcm_poke()
1051 if (ipcm->channels == 0) { /* remove */ in snd_emu10k1_ipcm_poke()
1052 pcm->valid = 0; in snd_emu10k1_ipcm_poke()
1055 if (ipcm->channels != 2) { in snd_emu10k1_ipcm_poke()
1056 err = -EINVAL; in snd_emu10k1_ipcm_poke()
1059 pcm->valid = 1; in snd_emu10k1_ipcm_poke()
1060 pcm->opened = 0; in snd_emu10k1_ipcm_poke()
1061 pcm->channels = ipcm->channels; in snd_emu10k1_ipcm_poke()
1062 pcm->tram_start = ipcm->tram_start; in snd_emu10k1_ipcm_poke()
1063 pcm->buffer_size = ipcm->buffer_size; in snd_emu10k1_ipcm_poke()
1064 pcm->gpr_size = ipcm->gpr_size; in snd_emu10k1_ipcm_poke()
1065 pcm->gpr_count = ipcm->gpr_count; in snd_emu10k1_ipcm_poke()
1066 pcm->gpr_tmpcount = ipcm->gpr_tmpcount; in snd_emu10k1_ipcm_poke()
1067 pcm->gpr_ptr = ipcm->gpr_ptr; in snd_emu10k1_ipcm_poke()
1068 pcm->gpr_trigger = ipcm->gpr_trigger; in snd_emu10k1_ipcm_poke()
1069 pcm->gpr_running = ipcm->gpr_running; in snd_emu10k1_ipcm_poke()
1070 for (i = 0; i < pcm->channels; i++) in snd_emu10k1_ipcm_poke()
1071 pcm->etram[i] = ipcm->etram[i]; in snd_emu10k1_ipcm_poke()
1074 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_poke()
1075 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_ipcm_poke()
1086 if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) in snd_emu10k1_ipcm_peek()
1087 return -EINVAL; in snd_emu10k1_ipcm_peek()
1088 ipcm->substream = array_index_nospec(ipcm->substream, in snd_emu10k1_ipcm_peek()
1090 pcm = &emu->fx8010.pcm[ipcm->substream]; in snd_emu10k1_ipcm_peek()
1091 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_ipcm_peek()
1092 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_peek()
1093 ipcm->channels = pcm->channels; in snd_emu10k1_ipcm_peek()
1094 ipcm->tram_start = pcm->tram_start; in snd_emu10k1_ipcm_peek()
1095 ipcm->buffer_size = pcm->buffer_size; in snd_emu10k1_ipcm_peek()
1096 ipcm->gpr_size = pcm->gpr_size; in snd_emu10k1_ipcm_peek()
1097 ipcm->gpr_ptr = pcm->gpr_ptr; in snd_emu10k1_ipcm_peek()
1098 ipcm->gpr_count = pcm->gpr_count; in snd_emu10k1_ipcm_peek()
1099 ipcm->gpr_tmpcount = pcm->gpr_tmpcount; in snd_emu10k1_ipcm_peek()
1100 ipcm->gpr_trigger = pcm->gpr_trigger; in snd_emu10k1_ipcm_peek()
1101 ipcm->gpr_running = pcm->gpr_running; in snd_emu10k1_ipcm_peek()
1102 for (i = 0; i < pcm->channels; i++) in snd_emu10k1_ipcm_peek()
1103 ipcm->etram[i] = pcm->etram[i]; in snd_emu10k1_ipcm_peek()
1104 ipcm->res1 = ipcm->res2 = 0; in snd_emu10k1_ipcm_peek()
1105 ipcm->pad = 0; in snd_emu10k1_ipcm_peek()
1106 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_peek()
1107 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_ipcm_peek()
1120 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_mono_control()
1121 strcpy(ctl->id.name, name); in snd_emu10k1_init_mono_control()
1122 ctl->vcount = ctl->count = 1; in snd_emu10k1_init_mono_control()
1123 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_mono_control()
1125 ctl->min = 0; in snd_emu10k1_init_mono_control()
1126 ctl->max = 0x7fffffff; in snd_emu10k1_init_mono_control()
1127 ctl->tlv = snd_emu10k1_db_linear; in snd_emu10k1_init_mono_control()
1128 ctl->translation = EMU10K1_GPR_TRANSLATION_NONE; in snd_emu10k1_init_mono_control()
1130 ctl->min = 0; in snd_emu10k1_init_mono_control()
1131 ctl->max = 100; in snd_emu10k1_init_mono_control()
1132 ctl->tlv = snd_emu10k1_db_scale1; in snd_emu10k1_init_mono_control()
1133 ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; in snd_emu10k1_init_mono_control()
1141 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_stereo_control()
1142 strcpy(ctl->id.name, name); in snd_emu10k1_init_stereo_control()
1143 ctl->vcount = ctl->count = 2; in snd_emu10k1_init_stereo_control()
1144 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_stereo_control()
1145 ctl->gpr[1] = gpr + 1; ctl->value[1] = defval; in snd_emu10k1_init_stereo_control()
1147 ctl->min = 0; in snd_emu10k1_init_stereo_control()
1148 ctl->max = 0x7fffffff; in snd_emu10k1_init_stereo_control()
1149 ctl->tlv = snd_emu10k1_db_linear; in snd_emu10k1_init_stereo_control()
1150 ctl->translation = EMU10K1_GPR_TRANSLATION_NONE; in snd_emu10k1_init_stereo_control()
1152 ctl->min = 0; in snd_emu10k1_init_stereo_control()
1153 ctl->max = 100; in snd_emu10k1_init_stereo_control()
1154 ctl->tlv = snd_emu10k1_db_scale1; in snd_emu10k1_init_stereo_control()
1155 ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; in snd_emu10k1_init_stereo_control()
1163 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_mono_onoff_control()
1164 strcpy(ctl->id.name, name); in snd_emu10k1_init_mono_onoff_control()
1165 ctl->vcount = ctl->count = 1; in snd_emu10k1_init_mono_onoff_control()
1166 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_mono_onoff_control()
1167 ctl->min = 0; in snd_emu10k1_init_mono_onoff_control()
1168 ctl->max = 1; in snd_emu10k1_init_mono_onoff_control()
1169 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; in snd_emu10k1_init_mono_onoff_control()
1176 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_stereo_onoff_control()
1177 strcpy(ctl->id.name, name); in snd_emu10k1_init_stereo_onoff_control()
1178 ctl->vcount = ctl->count = 2; in snd_emu10k1_init_stereo_onoff_control()
1179 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_stereo_onoff_control()
1180 ctl->gpr[1] = gpr + 1; ctl->value[1] = defval; in snd_emu10k1_init_stereo_onoff_control()
1181 ctl->min = 0; in snd_emu10k1_init_stereo_onoff_control()
1182 ctl->max = 1; in snd_emu10k1_init_stereo_onoff_control()
1183 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; in snd_emu10k1_init_stereo_onoff_control()
1187 * Used for emu1010 - conversion from 32-bit capture inputs from HANA
1188 * to 2 x 16-bit registers in audigy - their values are read via DMA.
1197 A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp + 1), A_GPR(bit_shifter16 - 1), A_C_00000000); in snd_emu10k1_audigy_dsp_convert_32_to_2x16()
1198 A_OP(icode, ptr, iTSTNEG, A_GPR(tmp + 2), A_GPR(tmp), A_C_80000000, A_GPR(bit_shifter16 - 2)); in snd_emu10k1_audigy_dsp_convert_32_to_2x16()
1200 A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp), A_GPR(bit_shifter16 - 3), A_C_00000000); in snd_emu10k1_audigy_dsp_convert_32_to_2x16()
1216 const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 voices */ in _snd_emu10k1_audigy_init_efx() local
1217 const int stereo_mix = capture + 2; in _snd_emu10k1_audigy_init_efx()
1224 err = -ENOMEM; in _snd_emu10k1_audigy_init_efx()
1229 icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024, in _snd_emu10k1_audigy_init_efx()
1231 if (!icode->gpr_map) in _snd_emu10k1_audigy_init_efx()
1238 gpr_map = icode->gpr_map; in _snd_emu10k1_audigy_init_efx()
1240 icode->tram_data_map = icode->gpr_map + 512; in _snd_emu10k1_audigy_init_efx()
1241 icode->tram_addr_map = icode->tram_data_map + 256; in _snd_emu10k1_audigy_init_efx()
1242 icode->code = icode->tram_addr_map + 256; in _snd_emu10k1_audigy_init_efx()
1246 set_bit(i, icode->gpr_valid); in _snd_emu10k1_audigy_init_efx()
1250 set_bit(i, icode->tram_valid); in _snd_emu10k1_audigy_init_efx()
1252 strcpy(icode->name, "Audigy DSP code for ALSA"); in _snd_emu10k1_audigy_init_efx()
1262 snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); in _snd_emu10k1_audigy_init_efx()
1282 if (emu->card_capabilities->spk71) { in _snd_emu10k1_audigy_init_efx()
1314 /* Wave (PCM) Capture */ in _snd_emu10k1_audigy_init_efx()
1315 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT)); in _snd_emu10k1_audigy_init_efx()
1316 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT)); in _snd_emu10k1_audigy_init_efx()
1317 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Capture Volume", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1320 /* Synth Capture */ in _snd_emu10k1_audigy_init_efx()
1321 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT)); in _snd_emu10k1_audigy_init_efx()
1322 …A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGH… in _snd_emu10k1_audigy_init_efx()
1323 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1332 /* emu1212 DSP 0 and DSP 1 Capture */ in _snd_emu10k1_audigy_init_efx()
1333 if (emu->card_capabilities->emu_model) { in _snd_emu10k1_audigy_init_efx()
1334 if (emu->card_capabilities->ca0108_chip) { in _snd_emu10k1_audigy_init_efx()
1337 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_GPR(tmp)); in _snd_emu10k1_audigy_init_efx()
1339 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr), A_GPR(tmp)); in _snd_emu10k1_audigy_init_efx()
1341 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_P16VIN(0x0)); in _snd_emu10k1_audigy_init_efx()
1342 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_P16VIN(0x1)); in _snd_emu10k1_audigy_init_efx()
1344 snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1347 /* AC'97 Playback Volume - used only for mic (renamed later) */ in _snd_emu10k1_audigy_init_efx()
1352 /* AC'97 Capture Volume - used only for mic */ in _snd_emu10k1_audigy_init_efx()
1353 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_AC97_L); in _snd_emu10k1_audigy_init_efx()
1354 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_AC97_R); in _snd_emu10k1_audigy_init_efx()
1355 snd_emu10k1_init_stereo_control(&controls[nctl++], "Mic Capture Volume", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1358 /* mic capture buffer */ in _snd_emu10k1_audigy_init_efx()
1365 emu->card_capabilities->ac97_chip ? "Audigy CD Playback Volume" : "CD Playback Volume", in _snd_emu10k1_audigy_init_efx()
1368 /* Audigy CD Capture Volume */ in _snd_emu10k1_audigy_init_efx()
1369 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_SPDIF_CD_L); in _snd_emu10k1_audigy_init_efx()
1370 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_SPDIF_CD_R); in _snd_emu10k1_audigy_init_efx()
1372 emu->card_capabilities->ac97_chip ? "Audigy CD Capture Volume" : "CD Capture Volume", in _snd_emu10k1_audigy_init_efx()
1381 /* Optical SPDIF Capture Volume */ in _snd_emu10k1_audigy_init_efx()
1382 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_OPT_SPDIF_L); in _snd_emu10k1_audigy_init_efx()
1383 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_OPT_SPDIF_R); in _snd_emu10k1_audigy_init_efx()
1384 …snd_emu10k1_init_stereo_control(&controls[nctl++], SNDRV_CTL_NAME_IEC958("Optical ",CAPTURE,VOLUME… in _snd_emu10k1_audigy_init_efx()
1391 emu->card_capabilities->ac97_chip ? "Line2 Playback Volume" : "Line Playback Volume", in _snd_emu10k1_audigy_init_efx()
1394 /* Line2 Capture Volume */ in _snd_emu10k1_audigy_init_efx()
1395 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_LINE2_L); in _snd_emu10k1_audigy_init_efx()
1396 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_LINE2_R); in _snd_emu10k1_audigy_init_efx()
1398 emu->card_capabilities->ac97_chip ? "Line2 Capture Volume" : "Line Capture Volume", in _snd_emu10k1_audigy_init_efx()
1407 /* Philips ADC Capture Volume */ in _snd_emu10k1_audigy_init_efx()
1408 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_ADC_L); in _snd_emu10k1_audigy_init_efx()
1409 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_ADC_R); in _snd_emu10k1_audigy_init_efx()
1410 snd_emu10k1_init_stereo_control(&controls[nctl++], "Analog Mix Capture Volume", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1417 emu->card_capabilities->ac97_chip ? "Aux2 Playback Volume" : "Aux Playback Volume", in _snd_emu10k1_audigy_init_efx()
1420 /* Aux2 Capture Volume */ in _snd_emu10k1_audigy_init_efx()
1421 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_AUX2_L); in _snd_emu10k1_audigy_init_efx()
1422 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_AUX2_R); in _snd_emu10k1_audigy_init_efx()
1424 emu->card_capabilities->ac97_chip ? "Aux2 Capture Volume" : "Aux Capture Volume", in _snd_emu10k1_audigy_init_efx()
1452 if (emu->card_capabilities->spk71) { in _snd_emu10k1_audigy_init_efx()
1486 if (emu->card_capabilities->spk71) { in _snd_emu10k1_audigy_init_efx()
1493 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_audigy_init_efx()
1494 strcpy(ctl->id.name, "Tone Control - Bass"); in _snd_emu10k1_audigy_init_efx()
1495 ctl->vcount = 2; in _snd_emu10k1_audigy_init_efx()
1496 ctl->count = 10; in _snd_emu10k1_audigy_init_efx()
1497 ctl->min = 0; in _snd_emu10k1_audigy_init_efx()
1498 ctl->max = 40; in _snd_emu10k1_audigy_init_efx()
1499 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_audigy_init_efx()
1500 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; in _snd_emu10k1_audigy_init_efx()
1502 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_audigy_init_efx()
1503 strcpy(ctl->id.name, "Tone Control - Treble"); in _snd_emu10k1_audigy_init_efx()
1504 ctl->vcount = 2; in _snd_emu10k1_audigy_init_efx()
1505 ctl->count = 10; in _snd_emu10k1_audigy_init_efx()
1506 ctl->min = 0; in _snd_emu10k1_audigy_init_efx()
1507 ctl->max = 40; in _snd_emu10k1_audigy_init_efx()
1508 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_audigy_init_efx()
1509 ctl->translation = EMU10K1_GPR_TRANSLATION_TREBLE; in _snd_emu10k1_audigy_init_efx()
1521 for (z = 0; z < 4; z++) { /* front/rear/center-lfe/side */ in _snd_emu10k1_audigy_init_efx()
1559 snd_emu10k1_init_stereo_onoff_control(controls + nctl++, "Tone Control - Switch", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1579 if (emu->card_capabilities->spk71) in _snd_emu10k1_audigy_init_efx()
1587 if (emu->card_capabilities->emu_model) { in _snd_emu10k1_audigy_init_efx()
1589 dev_info(emu->card->dev, "EMU outputs on\n"); in _snd_emu10k1_audigy_init_efx()
1591 if (emu->card_capabilities->ca0108_chip) { in _snd_emu10k1_audigy_init_efx()
1605 A_OP(icode, &ptr, iSKIP, A_GPR_COND, A_GPR_COND, A_GPR(gpr - 2), A_C_00000001); in _snd_emu10k1_audigy_init_efx()
1607 A_OP(icode, &ptr, iANDXOR, A_GPR(tmp + 2), A_GPR(tmp + 2), A_GPR(gpr - 1), A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1611 if ((z==1) && (emu->card_capabilities->spdif_bug)) { in _snd_emu10k1_audigy_init_efx()
1613 dev_info(emu->card->dev, in _snd_emu10k1_audigy_init_efx()
1615 emu->card_capabilities->name); in _snd_emu10k1_audigy_init_efx()
1616 …A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_0000000… in _snd_emu10k1_audigy_init_efx()
1617 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1633 A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_L, capture); in _snd_emu10k1_audigy_init_efx()
1634 A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_R, capture+1); in _snd_emu10k1_audigy_init_efx()
1637 if (emu->card_capabilities->emu_model) { in _snd_emu10k1_audigy_init_efx()
1638 if (emu->card_capabilities->ca0108_chip) { in _snd_emu10k1_audigy_init_efx()
1639 dev_info(emu->card->dev, "EMU2 inputs on\n"); in _snd_emu10k1_audigy_init_efx()
1647 dev_info(emu->card->dev, "EMU inputs on\n"); in _snd_emu10k1_audigy_init_efx()
1648 /* Capture 16 (originally 8) channels of S32_LE sound */ in _snd_emu10k1_audigy_init_efx()
1651 dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n", in _snd_emu10k1_audigy_init_efx()
1667 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1668 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1670 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1671 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x2), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1673 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1674 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x3), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1678 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1679 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x4), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1682 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1683 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x5), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1685 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1686 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x6), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1688 …snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBU… in _snd_emu10k1_audigy_init_efx()
1689 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000); in _snd_emu10k1_audigy_init_efx()
1690 /* Pavel Hofman - we still have voices, A_FXBUS2s, and in _snd_emu10k1_audigy_init_efx()
1691 * A_P16VINs available - in _snd_emu10k1_audigy_init_efx()
1692 * let's add 8 more capture channels - total of 16 in _snd_emu10k1_audigy_init_efx()
1697 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1699 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x8), in _snd_emu10k1_audigy_init_efx()
1704 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1706 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x9), in _snd_emu10k1_audigy_init_efx()
1711 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1713 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xa), in _snd_emu10k1_audigy_init_efx()
1718 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1720 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xb), in _snd_emu10k1_audigy_init_efx()
1725 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1727 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xc), in _snd_emu10k1_audigy_init_efx()
1732 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1734 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xd), in _snd_emu10k1_audigy_init_efx()
1739 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1741 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xe), in _snd_emu10k1_audigy_init_efx()
1746 A_GPR(gpr - 1), in _snd_emu10k1_audigy_init_efx()
1748 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xf), in _snd_emu10k1_audigy_init_efx()
1761 /* EFX capture - capture the 16 EXTINs */ in _snd_emu10k1_audigy_init_efx()
1762 /* Capture 16 channels of S16_LE sound */ in _snd_emu10k1_audigy_init_efx()
1775 err = -EIO; in _snd_emu10k1_audigy_init_efx()
1782 icode->gpr_add_control_count = nctl; in _snd_emu10k1_audigy_init_efx()
1783 icode->gpr_add_controls = controls; in _snd_emu10k1_audigy_init_efx()
1784 emu->support_tlv = 1; /* support TLV */ in _snd_emu10k1_audigy_init_efx()
1786 emu->support_tlv = 0; /* clear again */ in _snd_emu10k1_audigy_init_efx()
1791 kfree(icode->gpr_map); in _snd_emu10k1_audigy_init_efx()
1852 int err, i, z, gpr, tmp, playback, capture; in _snd_emu10k1_init_efx() local
1859 err = -ENOMEM; in _snd_emu10k1_init_efx()
1864 icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, in _snd_emu10k1_init_efx()
1866 if (!icode->gpr_map) in _snd_emu10k1_init_efx()
1879 gpr_map = icode->gpr_map; in _snd_emu10k1_init_efx()
1881 icode->tram_data_map = icode->gpr_map + 256; in _snd_emu10k1_init_efx()
1882 icode->tram_addr_map = icode->tram_data_map + 160; in _snd_emu10k1_init_efx()
1883 icode->code = icode->tram_addr_map + 160; in _snd_emu10k1_init_efx()
1887 set_bit(i, icode->gpr_valid); in _snd_emu10k1_init_efx()
1891 set_bit(i, icode->tram_valid); in _snd_emu10k1_init_efx()
1893 strcpy(icode->name, "SB Live! FX8010 code for ALSA v1.2 by Jaroslav Kysela"); in _snd_emu10k1_init_efx()
1898 capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); in _snd_emu10k1_init_efx()
1899 gpr = capture + SND_EMU10K1_CAPTURE_CHANNELS; in _snd_emu10k1_init_efx()
1904 snd_emu10k1_ptr_write(emu, DBG, 0, (emu->fx8010.dbg = 0) | EMU10K1_DBG_SINGLE_STEP); in _snd_emu10k1_init_efx()
1923 ipcm->substream = 0; in _snd_emu10k1_init_efx()
1924 ipcm->channels = 2; in _snd_emu10k1_init_efx()
1925 ipcm->tram_start = 0; in _snd_emu10k1_init_efx()
1926 ipcm->buffer_size = (64 * 1024) / 2; in _snd_emu10k1_init_efx()
1927 ipcm->gpr_size = gpr++; in _snd_emu10k1_init_efx()
1928 ipcm->gpr_ptr = gpr++; in _snd_emu10k1_init_efx()
1929 ipcm->gpr_count = gpr++; in _snd_emu10k1_init_efx()
1930 ipcm->gpr_tmpcount = gpr++; in _snd_emu10k1_init_efx()
1931 ipcm->gpr_trigger = gpr++; in _snd_emu10k1_init_efx()
1932 ipcm->gpr_running = gpr++; in _snd_emu10k1_init_efx()
1933 ipcm->etram[0] = 0; in _snd_emu10k1_init_efx()
1934 ipcm->etram[1] = 1; in _snd_emu10k1_init_efx()
1942 gpr_map[gpr + 6] = (0x22 - 0x01) - 1; /* skip at 01 to 22 */ in _snd_emu10k1_init_efx()
1943 gpr_map[gpr + 7] = (0x22 - 0x06) - 1; /* skip at 06 to 22 */ in _snd_emu10k1_init_efx()
1947 gpr_map[gpr + 11] = (0x24 - 0x0a) - 1; /* skip at 0a to 24 */ in _snd_emu10k1_init_efx()
1951 /* 00: */ OP(icode, &ptr, iMAC0, C_00000000, GPR(ipcm->gpr_trigger), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
1954 /* 02: */ OP(icode, &ptr, iMAC0, C_00000000, GPR(ipcm->gpr_running), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
1962 …/* 08: */ OP(icode, &ptr, iANDXOR, GPR(ipcm->gpr_running), GPR(ipcm->gpr_running), C_00000000, C_0… in _snd_emu10k1_init_efx()
1967 …/* 0c: */ OP(icode, &ptr, iANDXOR, GPR(tmp + 0), ETRAM_DATA(ipcm->etram[0]), GPR(gpr + 0), C_00000… in _snd_emu10k1_init_efx()
1973 …/* 11: */ OP(icode, &ptr, iANDXOR, GPR(tmp + 0), ETRAM_DATA(ipcm->etram[1]), GPR(gpr + 0), C_00000… in _snd_emu10k1_init_efx()
1979 /* 16: */ OP(icode, &ptr, iACC3, GPR(tmp + 0), GPR(ipcm->gpr_ptr), C_00000001, C_00000000); in _snd_emu10k1_init_efx()
1980 /* 17: */ OP(icode, &ptr, iMACINT0, C_00000000, GPR(tmp + 0), C_ffffffff, GPR(ipcm->gpr_size)); in _snd_emu10k1_init_efx()
1983 /* 1a: */ OP(icode, &ptr, iACC3, GPR(ipcm->gpr_ptr), GPR(tmp + 0), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
1985 …/* 1b: */ OP(icode, &ptr, iACC3, GPR(ipcm->gpr_tmpcount), GPR(ipcm->gpr_tmpcount), C_ffffffff, C_0… in _snd_emu10k1_init_efx()
1987 …/* 1d: */ OP(icode, &ptr, iACC3, GPR(ipcm->gpr_tmpcount), GPR(ipcm->gpr_count), C_00000000, C_0000… in _snd_emu10k1_init_efx()
1989 …/* 1f: */ OP(icode, &ptr, iANDXOR, GPR(ipcm->gpr_running), GPR(ipcm->gpr_running), C_00000001, C_0… in _snd_emu10k1_init_efx()
1991 …/* 20: */ OP(icode, &ptr, iANDXOR, GPR(ipcm->gpr_running), GPR(ipcm->gpr_running), C_00010000, C_0… in _snd_emu10k1_init_efx()
1994 …/* 22: */ OP(icode, &ptr, iMACINT1, ETRAM_ADDR(ipcm->etram[0]), GPR(gpr + 8), GPR_DBAC, C_ffffffff… in _snd_emu10k1_init_efx()
1995 …/* 23: */ OP(icode, &ptr, iMACINT1, ETRAM_ADDR(ipcm->etram[1]), GPR(gpr + 9), GPR_DBAC, C_ffffffff… in _snd_emu10k1_init_efx()
2020 /* Wave Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2023 VOLUME(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2025 snd_emu10k1_init_stereo_control(controls + i++, "Wave Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2026 snd_emu10k1_init_stereo_onoff_control(controls + i++, "Wave Capture Switch", gpr + 2, 0); in _snd_emu10k1_init_efx()
2035 /* Synth Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2038 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2040 snd_emu10k1_init_stereo_control(controls + i++, "Synth Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2041 snd_emu10k1_init_stereo_onoff_control(controls + i++, "Synth Capture Switch", gpr + 2, 0); in _snd_emu10k1_init_efx()
2050 /* Surround Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2053 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2055 snd_emu10k1_init_stereo_control(controls + i++, "Surround Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2056 snd_emu10k1_init_stereo_onoff_control(controls + i++, "Surround Capture Switch", gpr + 2, 0); in _snd_emu10k1_init_efx()
2073 /* Front Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2076 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2078 snd_emu10k1_init_stereo_control(controls + i++, "Front Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2079 snd_emu10k1_init_mono_onoff_control(controls + i++, "Front Capture Switch", gpr + 2, 0); in _snd_emu10k1_init_efx()
2086 if (emu->fx8010.extin_mask & ((1<<EXTIN_AC97_L)|(1<<EXTIN_AC97_R))) { in _snd_emu10k1_init_efx()
2090 snd_emu10k1_init_stereo_control(controls + i++, "AC97 Playback Volume", gpr-2, 0); in _snd_emu10k1_init_efx()
2091 /* AC'97 Capture Volume */ in _snd_emu10k1_init_efx()
2092 VOLUME_ADDIN(icode, &ptr, capture + 0, EXTIN_AC97_L, gpr); gpr++; in _snd_emu10k1_init_efx()
2093 VOLUME_ADDIN(icode, &ptr, capture + 1, EXTIN_AC97_R, gpr); gpr++; in _snd_emu10k1_init_efx()
2094 snd_emu10k1_init_stereo_control(controls + i++, "AC97 Capture Volume", gpr-2, 100); in _snd_emu10k1_init_efx()
2097 if (emu->fx8010.extin_mask & ((1<<EXTIN_SPDIF_CD_L)|(1<<EXTIN_SPDIF_CD_R))) { in _snd_emu10k1_init_efx()
2104 /* IEC958 TTL Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2107 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2109 …snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",CAPTURE,VOLUME), gpr,… in _snd_emu10k1_init_efx()
2110 …snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",CAPTURE,SWITCH)… in _snd_emu10k1_init_efx()
2114 if (emu->fx8010.extin_mask & ((1<<EXTIN_ZOOM_L)|(1<<EXTIN_ZOOM_R))) { in _snd_emu10k1_init_efx()
2121 /* Zoom Video Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2124 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2126 snd_emu10k1_init_stereo_control(controls + i++, "Zoom Video Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2127 snd_emu10k1_init_stereo_onoff_control(controls + i++, "Zoom Video Capture Switch", gpr + 2, 0); in _snd_emu10k1_init_efx()
2131 if (emu->fx8010.extin_mask & ((1<<EXTIN_TOSLINK_L)|(1<<EXTIN_TOSLINK_R))) { in _snd_emu10k1_init_efx()
2138 /* IEC958 Optical Capture Volume */ in _snd_emu10k1_init_efx()
2141 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2143 …snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",CAPTURE,VOLUME)… in _snd_emu10k1_init_efx()
2144 …snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",CAPTURE,S… in _snd_emu10k1_init_efx()
2148 if (emu->fx8010.extin_mask & ((1<<EXTIN_LINE1_L)|(1<<EXTIN_LINE1_R))) { in _snd_emu10k1_init_efx()
2155 /* Line LiveDrive Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2158 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2160 snd_emu10k1_init_stereo_control(controls + i++, "Line LiveDrive Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2161 …snd_emu10k1_init_stereo_onoff_control(controls + i++, "Line LiveDrive Capture Switch", gpr + 2, 0); in _snd_emu10k1_init_efx()
2165 if (emu->fx8010.extin_mask & ((1<<EXTIN_COAX_SPDIF_L)|(1<<EXTIN_COAX_SPDIF_R))) { in _snd_emu10k1_init_efx()
2172 /* IEC958 Coax Capture Volume + Switch */ in _snd_emu10k1_init_efx()
2175 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2177 …snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",CAPTURE,VOLUME), … in _snd_emu10k1_init_efx()
2178 …snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",CAPTURE,SWI… in _snd_emu10k1_init_efx()
2182 if (emu->fx8010.extin_mask & ((1<<EXTIN_LINE2_L)|(1<<EXTIN_LINE2_R))) { in _snd_emu10k1_init_efx()
2187 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2190 /* Line LiveDrive Capture Volume */ in _snd_emu10k1_init_efx()
2193 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); in _snd_emu10k1_init_efx()
2195 snd_emu10k1_init_stereo_control(controls + i++, "Line2 LiveDrive Capture Volume", gpr, 0); in _snd_emu10k1_init_efx()
2196 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2197 …snd_emu10k1_init_stereo_onoff_control(controls + i++, "Line2 LiveDrive Capture Switch", gpr + 2, 0… in _snd_emu10k1_init_efx()
2198 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2213 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_init_efx()
2214 strcpy(ctl->id.name, "Tone Control - Bass"); in _snd_emu10k1_init_efx()
2215 ctl->vcount = 2; in _snd_emu10k1_init_efx()
2216 ctl->count = 10; in _snd_emu10k1_init_efx()
2217 ctl->min = 0; in _snd_emu10k1_init_efx()
2218 ctl->max = 40; in _snd_emu10k1_init_efx()
2219 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_init_efx()
2220 ctl->tlv = snd_emu10k1_bass_treble_db_scale; in _snd_emu10k1_init_efx()
2221 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; in _snd_emu10k1_init_efx()
2223 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_init_efx()
2224 strcpy(ctl->id.name, "Tone Control - Treble"); in _snd_emu10k1_init_efx()
2225 ctl->vcount = 2; in _snd_emu10k1_init_efx()
2226 ctl->count = 10; in _snd_emu10k1_init_efx()
2227 ctl->min = 0; in _snd_emu10k1_init_efx()
2228 ctl->max = 40; in _snd_emu10k1_init_efx()
2229 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_init_efx()
2230 ctl->tlv = snd_emu10k1_bass_treble_db_scale; in _snd_emu10k1_init_efx()
2231 ctl->translation = EMU10K1_GPR_TRANSLATION_TREBLE; in _snd_emu10k1_init_efx()
2243 for (z = 0; z < 3; z++) { /* front/rear/center-lfe */ in _snd_emu10k1_init_efx()
2281 snd_emu10k1_init_stereo_onoff_control(controls + i++, "Tone Control - Switch", gpr, 0); in _snd_emu10k1_init_efx()
2287 if (emu->fx8010.extout_mask & ((1<<EXTOUT_AC97_L)|(1<<EXTOUT_AC97_R))) { in _snd_emu10k1_init_efx()
2294 if (emu->fx8010.extout_mask & ((1<<EXTOUT_TOSLINK_L)|(1<<EXTOUT_TOSLINK_R))) { in _snd_emu10k1_init_efx()
2311 if (emu->fx8010.extout_mask & ((1<<EXTOUT_HEADPHONE_L)|(1<<EXTOUT_HEADPHONE_R))) { in _snd_emu10k1_init_efx()
2323 controls[i-1].id.index = 1; /* AC'97 can have also Headphone control */ in _snd_emu10k1_init_efx()
2325 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2327 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2332 if (emu->fx8010.extout_mask & ((1<<EXTOUT_REAR_L)|(1<<EXTOUT_REAR_R))) in _snd_emu10k1_init_efx()
2336 if (emu->fx8010.extout_mask & ((1<<EXTOUT_AC97_REAR_L)|(1<<EXTOUT_AC97_REAR_R))) in _snd_emu10k1_init_efx()
2340 if (emu->fx8010.extout_mask & (1<<EXTOUT_AC97_CENTER)) { in _snd_emu10k1_init_efx()
2350 if (emu->fx8010.extout_mask & (1<<EXTOUT_AC97_LFE)) { in _snd_emu10k1_init_efx()
2362 OP(icode, &ptr, iACC3, EXTOUT(EXTOUT_ADC_CAP_L + z), GPR(capture + z), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
2365 if (emu->fx8010.extout_mask & (1<<EXTOUT_MIC_CAP)) in _snd_emu10k1_init_efx()
2366 OP(icode, &ptr, iACC3, EXTOUT(EXTOUT_MIC_CAP), GPR(capture + 2), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
2368 /* EFX capture - capture the 16 EXTINS */ in _snd_emu10k1_init_efx()
2369 if (emu->card_capabilities->sblive51) { in _snd_emu10k1_init_efx()
2374 * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture in _snd_emu10k1_init_efx()
2375 * 0 and 3, then the rest of the EXTINs to the corresponding FX capture in _snd_emu10k1_init_efx()
2393 err = -EIO; in _snd_emu10k1_init_efx()
2398 err = -EIO; in _snd_emu10k1_init_efx()
2406 if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0) in _snd_emu10k1_init_efx()
2408 icode->gpr_add_control_count = i; in _snd_emu10k1_init_efx()
2409 icode->gpr_add_controls = controls; in _snd_emu10k1_init_efx()
2410 emu->support_tlv = 1; /* support TLV */ in _snd_emu10k1_init_efx()
2412 emu->support_tlv = 0; /* clear again */ in _snd_emu10k1_init_efx()
2420 kfree(icode->gpr_map); in _snd_emu10k1_init_efx()
2428 spin_lock_init(&emu->fx8010.irq_lock); in snd_emu10k1_init_efx()
2429 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); in snd_emu10k1_init_efx()
2430 if (emu->audigy) in snd_emu10k1_init_efx()
2439 if (emu->audigy) in snd_emu10k1_free_efx()
2440 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg = A_DBG_SINGLE_STEP); in snd_emu10k1_free_efx()
2442 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg = EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_free_efx()
2449 return -EINVAL;
2450 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1);
2457 return -EINVAL;
2458 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0);
2469 size = (size - 1) >> 13; in snd_emu10k1_fx8010_tram_setup()
2477 if ((emu->fx8010.etram_pages.bytes / 2) == size) in snd_emu10k1_fx8010_tram_setup()
2479 spin_lock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2480 outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); in snd_emu10k1_fx8010_tram_setup()
2481 spin_unlock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2482 snd_emu10k1_ptr_write(emu, TCB, 0, 0); in snd_emu10k1_fx8010_tram_setup()
2484 if (emu->fx8010.etram_pages.area != NULL) { in snd_emu10k1_fx8010_tram_setup()
2485 snd_dma_free_pages(&emu->fx8010.etram_pages); in snd_emu10k1_fx8010_tram_setup()
2486 emu->fx8010.etram_pages.area = NULL; in snd_emu10k1_fx8010_tram_setup()
2487 emu->fx8010.etram_pages.bytes = 0; in snd_emu10k1_fx8010_tram_setup()
2491 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &emu->pci->dev, in snd_emu10k1_fx8010_tram_setup()
2492 size * 2, &emu->fx8010.etram_pages) < 0) in snd_emu10k1_fx8010_tram_setup()
2493 return -ENOMEM; in snd_emu10k1_fx8010_tram_setup()
2494 memset(emu->fx8010.etram_pages.area, 0, size * 2); in snd_emu10k1_fx8010_tram_setup()
2495 snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); in snd_emu10k1_fx8010_tram_setup()
2497 spin_lock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2498 outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); in snd_emu10k1_fx8010_tram_setup()
2499 spin_unlock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2525 info->internal_tram_size = emu->fx8010.itram_size; in snd_emu10k1_fx8010_info()
2526 info->external_tram_size = emu->fx8010.etram_pages.bytes / 2; in snd_emu10k1_fx8010_info()
2528 extin = emu->audigy ? audigy_ins : creative_ins; in snd_emu10k1_fx8010_info()
2529 extout = emu->audigy ? audigy_outs : creative_outs; in snd_emu10k1_fx8010_info()
2530 fxbus_mask = emu->fx8010.fxbus_mask; in snd_emu10k1_fx8010_info()
2531 extin_mask = emu->fx8010.extin_mask; in snd_emu10k1_fx8010_info()
2532 extout_mask = emu->fx8010.extout_mask; in snd_emu10k1_fx8010_info()
2534 copy_string(info->fxbus_names[res], fxbus_mask & (1 << res) ? *fxbus : NULL, "FXBUS", res); in snd_emu10k1_fx8010_info()
2535 copy_string(info->extin_names[res], extin_mask & (1 << res) ? *extin : NULL, "Unused", res); in snd_emu10k1_fx8010_info()
2536 copy_string(info->extout_names[res], extout_mask & (1 << res) ? *extout : NULL, "Unused", res); in snd_emu10k1_fx8010_info()
2539 copy_string(info->extout_names[res], extout_mask & (1 << res) ? *extout : NULL, "Unused", res); in snd_emu10k1_fx8010_info()
2540 info->gpr_controls = emu->fx8010.gpr_count; in snd_emu10k1_fx8010_info()
2545 struct snd_emu10k1 *emu = hw->private_data; in snd_emu10k1_fx8010_ioctl()
2555 emu->support_tlv = 1; in snd_emu10k1_fx8010_ioctl()
2560 return -ENOMEM; in snd_emu10k1_fx8010_ioctl()
2564 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2570 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2585 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2603 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2609 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2611 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2612 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_fx8010_ioctl()
2614 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_fx8010_ioctl()
2618 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2619 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2620 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg |= A_DBG_SINGLE_STEP); in snd_emu10k1_fx8010_ioctl()
2622 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg |= EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_fx8010_ioctl()
2626 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2627 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2628 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg = 0); in snd_emu10k1_fx8010_ioctl()
2630 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg = 0); in snd_emu10k1_fx8010_ioctl()
2634 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2635 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2636 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_ZC); in snd_emu10k1_fx8010_ioctl()
2638 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_ZC); in snd_emu10k1_fx8010_ioctl()
2640 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2641 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); in snd_emu10k1_fx8010_ioctl()
2643 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); in snd_emu10k1_fx8010_ioctl()
2647 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2649 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2651 return -EINVAL; in snd_emu10k1_fx8010_ioctl()
2652 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2653 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg |= A_DBG_SINGLE_STEP | addr); in snd_emu10k1_fx8010_ioctl()
2655 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg |= EMU10K1_DBG_SINGLE_STEP | addr); in snd_emu10k1_fx8010_ioctl()
2657 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2658 …snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg |= A_DBG_SINGLE_STEP | A_DBG_STEP_ADDR | addr… in snd_emu10k1_fx8010_ioctl()
2660 …snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg |= EMU10K1_DBG_SINGLE_STEP | EMU10K1_DBG_STEP |… in snd_emu10k1_fx8010_ioctl()
2663 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2668 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2671 return -ENOTTY; in snd_emu10k1_fx8010_ioctl()
2684 if ((err = snd_hwdep_new(emu->card, "FX8010", device, &hw)) < 0) in snd_emu10k1_fx8010_new()
2686 strcpy(hw->name, "EMU10K1 (FX8010)"); in snd_emu10k1_fx8010_new()
2687 hw->iface = SNDRV_HWDEP_IFACE_EMU10K1; in snd_emu10k1_fx8010_new()
2688 hw->ops.open = snd_emu10k1_fx8010_open; in snd_emu10k1_fx8010_new()
2689 hw->ops.ioctl = snd_emu10k1_fx8010_ioctl; in snd_emu10k1_fx8010_new()
2690 hw->ops.release = snd_emu10k1_fx8010_release; in snd_emu10k1_fx8010_new()
2691 hw->private_data = emu; in snd_emu10k1_fx8010_new()
2700 len = emu->audigy ? 0x200 : 0x100; in snd_emu10k1_efx_alloc_pm_buffer()
2701 emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL); in snd_emu10k1_efx_alloc_pm_buffer()
2702 if (! emu->saved_gpr) in snd_emu10k1_efx_alloc_pm_buffer()
2703 return -ENOMEM; in snd_emu10k1_efx_alloc_pm_buffer()
2704 len = emu->audigy ? 0x100 : 0xa0; in snd_emu10k1_efx_alloc_pm_buffer()
2705 emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL); in snd_emu10k1_efx_alloc_pm_buffer()
2706 emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL); in snd_emu10k1_efx_alloc_pm_buffer()
2707 if (! emu->tram_val_saved || ! emu->tram_addr_saved) in snd_emu10k1_efx_alloc_pm_buffer()
2708 return -ENOMEM; in snd_emu10k1_efx_alloc_pm_buffer()
2709 len = emu->audigy ? 2 * 1024 : 2 * 512; in snd_emu10k1_efx_alloc_pm_buffer()
2710 emu->saved_icode = vmalloc(array_size(len, 4)); in snd_emu10k1_efx_alloc_pm_buffer()
2711 if (! emu->saved_icode) in snd_emu10k1_efx_alloc_pm_buffer()
2712 return -ENOMEM; in snd_emu10k1_efx_alloc_pm_buffer()
2718 kfree(emu->saved_gpr); in snd_emu10k1_efx_free_pm_buffer()
2719 kfree(emu->tram_val_saved); in snd_emu10k1_efx_free_pm_buffer()
2720 kfree(emu->tram_addr_saved); in snd_emu10k1_efx_free_pm_buffer()
2721 vfree(emu->saved_icode); in snd_emu10k1_efx_free_pm_buffer()
2731 len = emu->audigy ? 0x200 : 0x100; in snd_emu10k1_efx_suspend()
2733 emu->saved_gpr[i] = snd_emu10k1_ptr_read(emu, emu->gpr_base + i, 0); in snd_emu10k1_efx_suspend()
2735 len = emu->audigy ? 0x100 : 0xa0; in snd_emu10k1_efx_suspend()
2737 emu->tram_val_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + i, 0); in snd_emu10k1_efx_suspend()
2738 emu->tram_addr_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + i, 0); in snd_emu10k1_efx_suspend()
2739 if (emu->audigy) { in snd_emu10k1_efx_suspend()
2740 emu->tram_addr_saved[i] >>= 12; in snd_emu10k1_efx_suspend()
2741 emu->tram_addr_saved[i] |= in snd_emu10k1_efx_suspend()
2746 len = emu->audigy ? 2 * 1024 : 2 * 512; in snd_emu10k1_efx_suspend()
2748 emu->saved_icode[i] = snd_emu10k1_efx_read(emu, i); in snd_emu10k1_efx_suspend()
2756 if (emu->fx8010.etram_pages.bytes > 0) { in snd_emu10k1_efx_resume()
2758 size = emu->fx8010.etram_pages.bytes / 2; in snd_emu10k1_efx_resume()
2759 size = (size - 1) >> 13; in snd_emu10k1_efx_resume()
2764 outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); in snd_emu10k1_efx_resume()
2765 snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); in snd_emu10k1_efx_resume()
2767 outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); in snd_emu10k1_efx_resume()
2770 if (emu->audigy) in snd_emu10k1_efx_resume()
2771 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); in snd_emu10k1_efx_resume()
2773 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_efx_resume()
2775 len = emu->audigy ? 0x200 : 0x100; in snd_emu10k1_efx_resume()
2777 snd_emu10k1_ptr_write(emu, emu->gpr_base + i, 0, emu->saved_gpr[i]); in snd_emu10k1_efx_resume()
2779 len = emu->audigy ? 0x100 : 0xa0; in snd_emu10k1_efx_resume()
2782 emu->tram_val_saved[i]); in snd_emu10k1_efx_resume()
2783 if (! emu->audigy) in snd_emu10k1_efx_resume()
2785 emu->tram_addr_saved[i]); in snd_emu10k1_efx_resume()
2788 emu->tram_addr_saved[i] << 12); in snd_emu10k1_efx_resume()
2790 emu->tram_addr_saved[i] >> 20); in snd_emu10k1_efx_resume()
2794 len = emu->audigy ? 2 * 1024 : 2 * 512; in snd_emu10k1_efx_resume()
2796 snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]); in snd_emu10k1_efx_resume()
2799 if (emu->audigy) in snd_emu10k1_efx_resume()
2800 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); in snd_emu10k1_efx_resume()
2802 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); in snd_emu10k1_efx_resume()