Lines Matching +full:adc +full:- +full:use +full:- +full:res
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * James Courtier-Dutton <James@superbug.co.uk>
25 #if 0 /* for testing purposes - digital out -> capture */
28 #if 0 /* for testing purposes - set S/PDIF to AC3 output */
31 #if 0 /* for testing purposes - feed the front signal to Center/LFE outputs */
37 MODULE_PARM_DESC(high_res_gpr_volume, "GPR mixer controls use 31-bit range.");
177 /* 0x12 */ "ADC Capture Left",
178 /* 0x13 */ "ADC Capture Right",
202 2, -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 1
319 static const DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
323 static const DECLARE_TLV_DB_SCALE(snd_emu10k1_bass_treble_db_scale, -1200, 60, 0);
336 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; in snd_emu10k1_gpr_ctl_info()
338 if (ctl->min == 0 && ctl->max == 1) in snd_emu10k1_gpr_ctl_info()
339 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_emu10k1_gpr_ctl_info()
341 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_emu10k1_gpr_ctl_info()
342 uinfo->count = ctl->vcount; in snd_emu10k1_gpr_ctl_info()
343 uinfo->value.integer.min = ctl->min; in snd_emu10k1_gpr_ctl_info()
344 uinfo->value.integer.max = ctl->max; in snd_emu10k1_gpr_ctl_info()
351 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; in snd_emu10k1_gpr_ctl_get()
354 for (i = 0; i < ctl->vcount; i++) in snd_emu10k1_gpr_ctl_get()
355 ucontrol->value.integer.value[i] = ctl->value[i]; in snd_emu10k1_gpr_ctl_get()
363 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; in snd_emu10k1_gpr_ctl_put()
368 for (i = 0; i < ctl->vcount; i++) { in snd_emu10k1_gpr_ctl_put()
369 nval = ucontrol->value.integer.value[i]; in snd_emu10k1_gpr_ctl_put()
370 if (nval < ctl->min) in snd_emu10k1_gpr_ctl_put()
371 nval = ctl->min; in snd_emu10k1_gpr_ctl_put()
372 if (nval > ctl->max) in snd_emu10k1_gpr_ctl_put()
373 nval = ctl->max; in snd_emu10k1_gpr_ctl_put()
374 if (nval != ctl->value[i]) in snd_emu10k1_gpr_ctl_put()
376 val = ctl->value[i] = nval; in snd_emu10k1_gpr_ctl_put()
377 switch (ctl->translation) { in snd_emu10k1_gpr_ctl_put()
379 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, val); in snd_emu10k1_gpr_ctl_put()
382 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, ~val); in snd_emu10k1_gpr_ctl_put()
385 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]); in snd_emu10k1_gpr_ctl_put()
388 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, in snd_emu10k1_gpr_ctl_put()
389 val == 100 ? 0x80000000 : -(int)db_table[val]); in snd_emu10k1_gpr_ctl_put()
392 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { in snd_emu10k1_gpr_ctl_put()
393 change = -EIO; in snd_emu10k1_gpr_ctl_put()
397 … 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()
400 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { in snd_emu10k1_gpr_ctl_put()
401 change = -EIO; in snd_emu10k1_gpr_ctl_put()
405 …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()
408 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, onoff_table[val]); in snd_emu10k1_gpr_ctl_put()
424 irq = emu->fx8010.irq_handlers; in snd_emu10k1_fx8010_interrupt()
426 nirq = irq->next; /* irq ptr can be removed from list */ in snd_emu10k1_fx8010_interrupt()
427 if (snd_emu10k1_ptr_read(emu, emu->gpr_base + irq->gpr_running, 0) & 0xffff0000) { in snd_emu10k1_fx8010_interrupt()
428 if (irq->handler) in snd_emu10k1_fx8010_interrupt()
429 irq->handler(emu, irq->private_data); in snd_emu10k1_fx8010_interrupt()
430 snd_emu10k1_ptr_write(emu, emu->gpr_base + irq->gpr_running, 0, 1); in snd_emu10k1_fx8010_interrupt()
444 irq->handler = handler; in snd_emu10k1_fx8010_register_irq_handler()
445 irq->gpr_running = gpr_running; in snd_emu10k1_fx8010_register_irq_handler()
446 irq->private_data = private_data; in snd_emu10k1_fx8010_register_irq_handler()
447 irq->next = NULL; in snd_emu10k1_fx8010_register_irq_handler()
448 spin_lock_irqsave(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_register_irq_handler()
449 if (emu->fx8010.irq_handlers == NULL) { in snd_emu10k1_fx8010_register_irq_handler()
450 emu->fx8010.irq_handlers = irq; in snd_emu10k1_fx8010_register_irq_handler()
451 emu->dsp_interrupt = snd_emu10k1_fx8010_interrupt; in snd_emu10k1_fx8010_register_irq_handler()
454 irq->next = emu->fx8010.irq_handlers; in snd_emu10k1_fx8010_register_irq_handler()
455 emu->fx8010.irq_handlers = irq; in snd_emu10k1_fx8010_register_irq_handler()
457 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_register_irq_handler()
467 spin_lock_irqsave(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_unregister_irq_handler()
468 tmp = emu->fx8010.irq_handlers; in snd_emu10k1_fx8010_unregister_irq_handler()
470 emu->fx8010.irq_handlers = tmp->next; in snd_emu10k1_fx8010_unregister_irq_handler()
471 if (emu->fx8010.irq_handlers == NULL) { in snd_emu10k1_fx8010_unregister_irq_handler()
473 emu->dsp_interrupt = NULL; in snd_emu10k1_fx8010_unregister_irq_handler()
476 while (tmp && tmp->next != irq) in snd_emu10k1_fx8010_unregister_irq_handler()
477 tmp = tmp->next; in snd_emu10k1_fx8010_unregister_irq_handler()
479 tmp->next = tmp->next->next; in snd_emu10k1_fx8010_unregister_irq_handler()
481 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags); in snd_emu10k1_fx8010_unregister_irq_handler()
496 code = icode->code + (*ptr) * 2; in snd_emu10k1_write_op()
497 set_bit(*ptr, icode->code_valid); in snd_emu10k1_write_op()
513 code = icode->code + (*ptr) * 2; in snd_emu10k1_audigy_write_op()
514 set_bit(*ptr, icode->code_valid); in snd_emu10k1_audigy_write_op()
525 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; in snd_emu10k1_efx_write()
531 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; in snd_emu10k1_efx_read()
542 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) { in snd_emu10k1_gpr_poke()
543 if (!test_bit(gpr, icode->gpr_valid)) in snd_emu10k1_gpr_poke()
546 val = icode->gpr_map[gpr]; in snd_emu10k1_gpr_poke()
547 else if (get_user(val, (__user u32 *)&icode->gpr_map[gpr])) in snd_emu10k1_gpr_poke()
548 return -EFAULT; in snd_emu10k1_gpr_poke()
549 snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val); in snd_emu10k1_gpr_poke()
560 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) { in snd_emu10k1_gpr_peek()
561 set_bit(gpr, icode->gpr_valid); in snd_emu10k1_gpr_peek()
562 val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0); in snd_emu10k1_gpr_peek()
563 if (put_user(val, (__user u32 *)&icode->gpr_map[gpr])) in snd_emu10k1_gpr_peek()
564 return -EFAULT; in snd_emu10k1_gpr_peek()
576 for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) { in snd_emu10k1_tram_poke()
577 if (!test_bit(tram, icode->tram_valid)) in snd_emu10k1_tram_poke()
580 val = icode->tram_data_map[tram]; in snd_emu10k1_tram_poke()
581 addr = icode->tram_addr_map[tram]; in snd_emu10k1_tram_poke()
583 if (get_user(val, (__user __u32 *)&icode->tram_data_map[tram]) || in snd_emu10k1_tram_poke()
584 get_user(addr, (__user __u32 *)&icode->tram_addr_map[tram])) in snd_emu10k1_tram_poke()
585 return -EFAULT; in snd_emu10k1_tram_poke()
588 if (!emu->audigy) { in snd_emu10k1_tram_poke()
604 memset(icode->tram_valid, 0, sizeof(icode->tram_valid)); in snd_emu10k1_tram_peek()
605 for (tram = 0; tram < (emu->audigy ? 0x100 : 0xa0); tram++) { in snd_emu10k1_tram_peek()
606 set_bit(tram, icode->tram_valid); in snd_emu10k1_tram_peek()
608 if (!emu->audigy) { in snd_emu10k1_tram_peek()
614 if (put_user(val, (__user u32 *)&icode->tram_data_map[tram]) || in snd_emu10k1_tram_peek()
615 put_user(addr, (__user u32 *)&icode->tram_addr_map[tram])) in snd_emu10k1_tram_peek()
616 return -EFAULT; in snd_emu10k1_tram_peek()
627 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { in snd_emu10k1_code_poke()
628 if (!test_bit(pc / 2, icode->code_valid)) in snd_emu10k1_code_poke()
631 lo = icode->code[pc + 0]; in snd_emu10k1_code_poke()
632 hi = icode->code[pc + 1]; in snd_emu10k1_code_poke()
634 if (get_user(lo, (__user u32 *)&icode->code[pc + 0]) || in snd_emu10k1_code_poke()
635 get_user(hi, (__user u32 *)&icode->code[pc + 1])) in snd_emu10k1_code_poke()
636 return -EFAULT; in snd_emu10k1_code_poke()
649 memset(icode->code_valid, 0, sizeof(icode->code_valid)); in snd_emu10k1_code_peek()
650 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { in snd_emu10k1_code_peek()
651 set_bit(pc / 2, icode->code_valid); in snd_emu10k1_code_peek()
653 (__user u32 *)&icode->code[pc + 0])) in snd_emu10k1_code_peek()
654 return -EFAULT; in snd_emu10k1_code_peek()
656 (__user u32 *)&icode->code[pc + 1])) in snd_emu10k1_code_peek()
657 return -EFAULT; in snd_emu10k1_code_peek()
670 list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) { in snd_emu10k1_look_for_ctl()
671 kcontrol = ctl->kcontrol; in snd_emu10k1_look_for_ctl()
672 if (kcontrol->id.iface == id->iface && in snd_emu10k1_look_for_ctl()
673 kcontrol->id.index == id->index && in snd_emu10k1_look_for_ctl()
674 !strcmp(kcontrol->id.name, id->name)) in snd_emu10k1_look_for_ctl()
718 if (emu->support_tlv) { in copy_gctl()
722 return -EFAULT; in copy_gctl()
731 return -EFAULT; in copy_gctl()
732 dst->tlv = NULL; in copy_gctl()
745 if (emu->support_tlv) in copy_gctl_to_user()
761 return -EFAULT; in copy_ctl_elem_id()
775 for (i = 0; i < icode->gpr_del_control_count; i++) { in snd_emu10k1_verify_controls()
776 err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, in snd_emu10k1_verify_controls()
781 return -ENOENT; in snd_emu10k1_verify_controls()
785 return -ENOMEM; in snd_emu10k1_verify_controls()
787 for (i = 0; i < icode->gpr_add_control_count; i++) { in snd_emu10k1_verify_controls()
788 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i, in snd_emu10k1_verify_controls()
790 err = -EFAULT; in snd_emu10k1_verify_controls()
793 if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) in snd_emu10k1_verify_controls()
795 gctl_id = (struct snd_ctl_elem_id *)&gctl->id; in snd_emu10k1_verify_controls()
796 if (snd_ctl_find_id(emu->card, gctl_id)) { in snd_emu10k1_verify_controls()
797 err = -EEXIST; in snd_emu10k1_verify_controls()
800 if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && in snd_emu10k1_verify_controls()
801 gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { in snd_emu10k1_verify_controls()
802 err = -EINVAL; in snd_emu10k1_verify_controls()
805 switch (gctl->translation) { in snd_emu10k1_verify_controls()
811 if (gctl->min != 0 || gctl->max != 100) { in snd_emu10k1_verify_controls()
812 err = -EINVAL; in snd_emu10k1_verify_controls()
818 if (gctl->min != 0 || gctl->max != 40) { in snd_emu10k1_verify_controls()
819 err = -EINVAL; in snd_emu10k1_verify_controls()
824 if (gctl->min != 0 || gctl->max != 1) { in snd_emu10k1_verify_controls()
825 err = -EINVAL; in snd_emu10k1_verify_controls()
830 err = -EINVAL; in snd_emu10k1_verify_controls()
834 for (i = 0; i < icode->gpr_list_control_count; i++) { in snd_emu10k1_verify_controls()
836 if (copy_gctl(emu, gctl, icode->gpr_list_controls, i, in snd_emu10k1_verify_controls()
838 err = -EFAULT; in snd_emu10k1_verify_controls()
851 ctl = (struct snd_emu10k1_fx8010_ctl *) kctl->private_value; in snd_emu10k1_ctl_private_free()
852 kctl->private_value = 0; in snd_emu10k1_ctl_private_free()
853 list_del(&ctl->list); in snd_emu10k1_ctl_private_free()
855 kfree(kctl->tlv.p); in snd_emu10k1_ctl_private_free()
875 err = -ENOMEM; in snd_emu10k1_add_controls()
879 for (i = 0; i < icode->gpr_add_control_count; i++) { in snd_emu10k1_add_controls()
880 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i, in snd_emu10k1_add_controls()
882 err = -EFAULT; in snd_emu10k1_add_controls()
885 gctl_id = (struct snd_ctl_elem_id *)&gctl->id; in snd_emu10k1_add_controls()
886 if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && in snd_emu10k1_add_controls()
887 gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { in snd_emu10k1_add_controls()
888 err = -EINVAL; in snd_emu10k1_add_controls()
891 if (!*gctl_id->name) { in snd_emu10k1_add_controls()
892 err = -EINVAL; in snd_emu10k1_add_controls()
895 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); in snd_emu10k1_add_controls()
897 knew.iface = gctl_id->iface; in snd_emu10k1_add_controls()
898 knew.name = gctl_id->name; in snd_emu10k1_add_controls()
899 knew.index = gctl_id->index; in snd_emu10k1_add_controls()
900 knew.device = gctl_id->device; in snd_emu10k1_add_controls()
901 knew.subdevice = gctl_id->subdevice; in snd_emu10k1_add_controls()
903 knew.tlv.p = copy_tlv((const unsigned int __user *)gctl->tlv, in_kernel); in snd_emu10k1_add_controls()
910 nctl->vcount = gctl->vcount; in snd_emu10k1_add_controls()
911 nctl->count = gctl->count; in snd_emu10k1_add_controls()
913 nctl->gpr[j] = gctl->gpr[j]; in snd_emu10k1_add_controls()
914 nctl->value[j] = ~gctl->value[j]; /* inverted, we want to write new value in gpr_ctl_put() */ in snd_emu10k1_add_controls()
915 val->value.integer.value[j] = gctl->value[j]; in snd_emu10k1_add_controls()
917 nctl->min = gctl->min; in snd_emu10k1_add_controls()
918 nctl->max = gctl->max; in snd_emu10k1_add_controls()
919 nctl->translation = gctl->translation; in snd_emu10k1_add_controls()
923 err = -ENOMEM; in snd_emu10k1_add_controls()
930 err = snd_ctl_add(emu->card, kctl); in snd_emu10k1_add_controls()
936 kctl->private_free = snd_emu10k1_ctl_private_free; in snd_emu10k1_add_controls()
937 ctl->kcontrol = kctl; in snd_emu10k1_add_controls()
938 list_add_tail(&ctl->list, &emu->fx8010.gpr_ctl); in snd_emu10k1_add_controls()
941 nctl->list = ctl->list; in snd_emu10k1_add_controls()
942 nctl->kcontrol = ctl->kcontrol; in snd_emu10k1_add_controls()
944 snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_emu10k1_add_controls()
945 SNDRV_CTL_EVENT_MASK_INFO, &ctl->kcontrol->id); in snd_emu10k1_add_controls()
947 snd_emu10k1_gpr_ctl_put(ctl->kcontrol, val); in snd_emu10k1_add_controls()
963 struct snd_card *card = emu->card; in snd_emu10k1_del_controls()
966 for (i = 0; i < icode->gpr_del_control_count; i++) { in snd_emu10k1_del_controls()
967 err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, in snd_emu10k1_del_controls()
973 snd_ctl_remove(card, ctl->kcontrol); in snd_emu10k1_del_controls()
989 return -ENOMEM; in snd_emu10k1_list_controls()
991 list_for_each_entry(ctl, &emu->fx8010.gpr_ctl, list) { in snd_emu10k1_list_controls()
993 if (icode->gpr_list_controls && in snd_emu10k1_list_controls()
994 i < icode->gpr_list_control_count) { in snd_emu10k1_list_controls()
996 id = &ctl->kcontrol->id; in snd_emu10k1_list_controls()
997 gctl->id.iface = (__force int)id->iface; in snd_emu10k1_list_controls()
998 strscpy(gctl->id.name, id->name, sizeof(gctl->id.name)); in snd_emu10k1_list_controls()
999 gctl->id.index = id->index; in snd_emu10k1_list_controls()
1000 gctl->id.device = id->device; in snd_emu10k1_list_controls()
1001 gctl->id.subdevice = id->subdevice; in snd_emu10k1_list_controls()
1002 gctl->vcount = ctl->vcount; in snd_emu10k1_list_controls()
1003 gctl->count = ctl->count; in snd_emu10k1_list_controls()
1005 gctl->gpr[j] = ctl->gpr[j]; in snd_emu10k1_list_controls()
1006 gctl->value[j] = ctl->value[j]; in snd_emu10k1_list_controls()
1008 gctl->min = ctl->min; in snd_emu10k1_list_controls()
1009 gctl->max = ctl->max; in snd_emu10k1_list_controls()
1010 gctl->translation = ctl->translation; in snd_emu10k1_list_controls()
1011 if (copy_gctl_to_user(emu, icode->gpr_list_controls, in snd_emu10k1_list_controls()
1014 return -EFAULT; in snd_emu10k1_list_controls()
1019 icode->gpr_list_control_total = total; in snd_emu10k1_list_controls()
1030 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_icode_poke()
1034 strscpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name)); in snd_emu10k1_icode_poke()
1035 /* stop FX processor - this may be dangerous, but it's better to miss in snd_emu10k1_icode_poke()
1036 some samples than generate wrong ones - [jk] */ in snd_emu10k1_icode_poke()
1037 if (emu->audigy) in snd_emu10k1_icode_poke()
1038 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); in snd_emu10k1_icode_poke()
1040 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_icode_poke()
1058 if (emu->audigy) in snd_emu10k1_icode_poke()
1059 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); in snd_emu10k1_icode_poke()
1061 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); in snd_emu10k1_icode_poke()
1063 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_icode_poke()
1072 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_icode_peek()
1073 strscpy(icode->name, emu->fx8010.name, sizeof(icode->name)); in snd_emu10k1_icode_peek()
1082 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_icode_peek()
1093 if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) in snd_emu10k1_ipcm_poke()
1094 return -EINVAL; in snd_emu10k1_ipcm_poke()
1095 ipcm->substream = array_index_nospec(ipcm->substream, in snd_emu10k1_ipcm_poke()
1097 if (ipcm->channels > 32) in snd_emu10k1_ipcm_poke()
1098 return -EINVAL; in snd_emu10k1_ipcm_poke()
1099 pcm = &emu->fx8010.pcm[ipcm->substream]; in snd_emu10k1_ipcm_poke()
1100 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_ipcm_poke()
1101 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_poke()
1102 if (pcm->opened) { in snd_emu10k1_ipcm_poke()
1103 err = -EBUSY; in snd_emu10k1_ipcm_poke()
1106 if (ipcm->channels == 0) { /* remove */ in snd_emu10k1_ipcm_poke()
1107 pcm->valid = 0; in snd_emu10k1_ipcm_poke()
1110 if (ipcm->channels != 2) { in snd_emu10k1_ipcm_poke()
1111 err = -EINVAL; in snd_emu10k1_ipcm_poke()
1114 pcm->valid = 1; in snd_emu10k1_ipcm_poke()
1115 pcm->opened = 0; in snd_emu10k1_ipcm_poke()
1116 pcm->channels = ipcm->channels; in snd_emu10k1_ipcm_poke()
1117 pcm->tram_start = ipcm->tram_start; in snd_emu10k1_ipcm_poke()
1118 pcm->buffer_size = ipcm->buffer_size; in snd_emu10k1_ipcm_poke()
1119 pcm->gpr_size = ipcm->gpr_size; in snd_emu10k1_ipcm_poke()
1120 pcm->gpr_count = ipcm->gpr_count; in snd_emu10k1_ipcm_poke()
1121 pcm->gpr_tmpcount = ipcm->gpr_tmpcount; in snd_emu10k1_ipcm_poke()
1122 pcm->gpr_ptr = ipcm->gpr_ptr; in snd_emu10k1_ipcm_poke()
1123 pcm->gpr_trigger = ipcm->gpr_trigger; in snd_emu10k1_ipcm_poke()
1124 pcm->gpr_running = ipcm->gpr_running; in snd_emu10k1_ipcm_poke()
1125 for (i = 0; i < pcm->channels; i++) in snd_emu10k1_ipcm_poke()
1126 pcm->etram[i] = ipcm->etram[i]; in snd_emu10k1_ipcm_poke()
1129 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_poke()
1130 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_ipcm_poke()
1141 if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) in snd_emu10k1_ipcm_peek()
1142 return -EINVAL; in snd_emu10k1_ipcm_peek()
1143 ipcm->substream = array_index_nospec(ipcm->substream, in snd_emu10k1_ipcm_peek()
1145 pcm = &emu->fx8010.pcm[ipcm->substream]; in snd_emu10k1_ipcm_peek()
1146 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_ipcm_peek()
1147 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_peek()
1148 ipcm->channels = pcm->channels; in snd_emu10k1_ipcm_peek()
1149 ipcm->tram_start = pcm->tram_start; in snd_emu10k1_ipcm_peek()
1150 ipcm->buffer_size = pcm->buffer_size; in snd_emu10k1_ipcm_peek()
1151 ipcm->gpr_size = pcm->gpr_size; in snd_emu10k1_ipcm_peek()
1152 ipcm->gpr_ptr = pcm->gpr_ptr; in snd_emu10k1_ipcm_peek()
1153 ipcm->gpr_count = pcm->gpr_count; in snd_emu10k1_ipcm_peek()
1154 ipcm->gpr_tmpcount = pcm->gpr_tmpcount; in snd_emu10k1_ipcm_peek()
1155 ipcm->gpr_trigger = pcm->gpr_trigger; in snd_emu10k1_ipcm_peek()
1156 ipcm->gpr_running = pcm->gpr_running; in snd_emu10k1_ipcm_peek()
1157 for (i = 0; i < pcm->channels; i++) in snd_emu10k1_ipcm_peek()
1158 ipcm->etram[i] = pcm->etram[i]; in snd_emu10k1_ipcm_peek()
1159 ipcm->res1 = ipcm->res2 = 0; in snd_emu10k1_ipcm_peek()
1160 ipcm->pad = 0; in snd_emu10k1_ipcm_peek()
1161 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_ipcm_peek()
1162 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_ipcm_peek()
1171 #define HR_VAL(v) ((v) * 0x80000000LL / 100 - 1)
1177 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_mono_control2()
1178 strcpy(ctl->id.name, name); in snd_emu10k1_init_mono_control2()
1179 ctl->vcount = ctl->count = 1; in snd_emu10k1_init_mono_control2()
1181 ctl->min = -1; in snd_emu10k1_init_mono_control2()
1182 ctl->max = 0x7fffffff; in snd_emu10k1_init_mono_control2()
1183 ctl->tlv = snd_emu10k1_db_linear; in snd_emu10k1_init_mono_control2()
1184 ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE; in snd_emu10k1_init_mono_control2()
1187 ctl->min = 0; in snd_emu10k1_init_mono_control2()
1188 ctl->max = 100; in snd_emu10k1_init_mono_control2()
1189 ctl->tlv = snd_emu10k1_db_scale1; in snd_emu10k1_init_mono_control2()
1190 ctl->translation = EMU10K1_GPR_TRANSLATION_NEG_TABLE100; in snd_emu10k1_init_mono_control2()
1192 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_mono_control2()
1201 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_stereo_control2()
1202 strcpy(ctl->id.name, name); in snd_emu10k1_init_stereo_control2()
1203 ctl->vcount = ctl->count = 2; in snd_emu10k1_init_stereo_control2()
1205 ctl->min = -1; in snd_emu10k1_init_stereo_control2()
1206 ctl->max = 0x7fffffff; in snd_emu10k1_init_stereo_control2()
1207 ctl->tlv = snd_emu10k1_db_linear; in snd_emu10k1_init_stereo_control2()
1208 ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE; in snd_emu10k1_init_stereo_control2()
1211 ctl->min = 0; in snd_emu10k1_init_stereo_control2()
1212 ctl->max = 100; in snd_emu10k1_init_stereo_control2()
1213 ctl->tlv = snd_emu10k1_db_scale1; in snd_emu10k1_init_stereo_control2()
1214 ctl->translation = EMU10K1_GPR_TRANSLATION_NEG_TABLE100; in snd_emu10k1_init_stereo_control2()
1216 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_stereo_control2()
1217 ctl->gpr[1] = gpr + 1; ctl->value[1] = defval; in snd_emu10k1_init_stereo_control2()
1226 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_mono_onoff_control()
1227 strcpy(ctl->id.name, name); in snd_emu10k1_init_mono_onoff_control()
1228 ctl->vcount = ctl->count = 1; in snd_emu10k1_init_mono_onoff_control()
1229 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_mono_onoff_control()
1230 ctl->min = 0; in snd_emu10k1_init_mono_onoff_control()
1231 ctl->max = 1; in snd_emu10k1_init_mono_onoff_control()
1232 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; in snd_emu10k1_init_mono_onoff_control()
1239 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in snd_emu10k1_init_stereo_onoff_control()
1240 strcpy(ctl->id.name, name); in snd_emu10k1_init_stereo_onoff_control()
1241 ctl->vcount = ctl->count = 2; in snd_emu10k1_init_stereo_onoff_control()
1242 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; in snd_emu10k1_init_stereo_onoff_control()
1243 ctl->gpr[1] = gpr + 1; ctl->value[1] = defval; in snd_emu10k1_init_stereo_onoff_control()
1244 ctl->min = 0; in snd_emu10k1_init_stereo_onoff_control()
1245 ctl->max = 1; in snd_emu10k1_init_stereo_onoff_control()
1246 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; in snd_emu10k1_init_stereo_onoff_control()
1250 * Used for emu1010 - conversion from 32-bit capture inputs from the FPGA
1251 * to 2 x 16-bit registers in Audigy - their values are read via DMA.
1266 // Left-shift once more. This is a separate step, as the in snd_emu10k1_audigy_dsp_convert_32_to_2x16()
1272 #define ENUM_GPR(name, size) name, name ## _dummy = name + (size) - 1
1302 err = -ENOMEM; in _snd_emu10k1_audigy_init_efx()
1307 icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024, in _snd_emu10k1_audigy_init_efx()
1309 if (!icode->gpr_map) in _snd_emu10k1_audigy_init_efx()
1316 gpr_map = icode->gpr_map; in _snd_emu10k1_audigy_init_efx()
1318 icode->tram_data_map = icode->gpr_map + 512; in _snd_emu10k1_audigy_init_efx()
1319 icode->tram_addr_map = icode->tram_data_map + 256; in _snd_emu10k1_audigy_init_efx()
1320 icode->code = icode->tram_addr_map + 256; in _snd_emu10k1_audigy_init_efx()
1323 memset(icode->gpr_valid, 0xff, 512 / 8); in _snd_emu10k1_audigy_init_efx()
1326 memset(icode->tram_valid, 0xff, 256 / 8); in _snd_emu10k1_audigy_init_efx()
1328 strcpy(icode->name, "Audigy DSP code for ALSA"); in _snd_emu10k1_audigy_init_efx()
1335 * playback = -gpr * FXBUS_PCM_LEFT_FRONT >> 31 in _snd_emu10k1_audigy_init_efx()
1351 if (emu->card_capabilities->spk71) { in _snd_emu10k1_audigy_init_efx()
1396 // which is necessary for bit-identical reproduction. in _snd_emu10k1_audigy_init_efx()
1407 if (emu->card_capabilities->emu_model) { in _snd_emu10k1_audigy_init_efx()
1410 if (emu->card_capabilities->ca0108_chip) { in _snd_emu10k1_audigy_init_efx()
1414 // need to be delayed as well; we use an auxiliary register for that. in _snd_emu10k1_audigy_init_efx()
1420 // need to be delayed as well; we use an auxiliary register for that. in _snd_emu10k1_audigy_init_efx()
1428 if (emu->card_capabilities->ac97_chip) { in _snd_emu10k1_audigy_init_efx()
1429 /* AC'97 Playback Volume - used only for mic (renamed later) */ in _snd_emu10k1_audigy_init_efx()
1434 /* AC'97 Capture Volume - used only for mic */ in _snd_emu10k1_audigy_init_efx()
1448 emu->card_capabilities->ac97_chip ? "Audigy CD Playback Volume" : "CD Playback Volume", in _snd_emu10k1_audigy_init_efx()
1455 emu->card_capabilities->ac97_chip ? "Audigy CD Capture Volume" : "CD Capture Volume", in _snd_emu10k1_audigy_init_efx()
1474 emu->card_capabilities->ac97_chip ? "Line2 Playback Volume" : "Line Playback Volume", in _snd_emu10k1_audigy_init_efx()
1481 emu->card_capabilities->ac97_chip ? "Line2 Capture Volume" : "Line Capture Volume", in _snd_emu10k1_audigy_init_efx()
1485 /* Philips ADC Playback Volume */ in _snd_emu10k1_audigy_init_efx()
1490 /* Philips ADC Capture Volume */ in _snd_emu10k1_audigy_init_efx()
1500 emu->card_capabilities->ac97_chip ? "Aux2 Playback Volume" : "Aux Playback Volume", in _snd_emu10k1_audigy_init_efx()
1507 emu->card_capabilities->ac97_chip ? "Aux2 Capture Volume" : "Aux Capture Volume", in _snd_emu10k1_audigy_init_efx()
1536 if (emu->card_capabilities->spk71) { in _snd_emu10k1_audigy_init_efx()
1565 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_audigy_init_efx()
1566 strcpy(ctl->id.name, "Tone Control - Bass"); in _snd_emu10k1_audigy_init_efx()
1567 ctl->vcount = 2; in _snd_emu10k1_audigy_init_efx()
1568 ctl->count = 10; in _snd_emu10k1_audigy_init_efx()
1569 ctl->min = 0; in _snd_emu10k1_audigy_init_efx()
1570 ctl->max = 40; in _snd_emu10k1_audigy_init_efx()
1571 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_audigy_init_efx()
1572 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; in _snd_emu10k1_audigy_init_efx()
1574 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_audigy_init_efx()
1575 strcpy(ctl->id.name, "Tone Control - Treble"); in _snd_emu10k1_audigy_init_efx()
1576 ctl->vcount = 2; in _snd_emu10k1_audigy_init_efx()
1577 ctl->count = 10; in _snd_emu10k1_audigy_init_efx()
1578 ctl->min = 0; in _snd_emu10k1_audigy_init_efx()
1579 ctl->max = 40; in _snd_emu10k1_audigy_init_efx()
1580 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_audigy_init_efx()
1581 ctl->translation = EMU10K1_GPR_TRANSLATION_TREBLE; in _snd_emu10k1_audigy_init_efx()
1592 snd_emu10k1_init_mono_onoff_control(controls + nctl++, "Tone Control - Switch", gpr, 0); in _snd_emu10k1_audigy_init_efx()
1596 for (z = 0; z < 4; z++) { /* front/rear/center-lfe/side */ in _snd_emu10k1_audigy_init_efx()
1623 gpr_map[gpr++] = ptr - ptr_skip; in _snd_emu10k1_audigy_init_efx()
1631 if (emu->card_capabilities->emu_model) { in _snd_emu10k1_audigy_init_efx()
1633 dev_info(emu->card->dev, "EMU outputs on\n"); in _snd_emu10k1_audigy_init_efx()
1635 if (emu->card_capabilities->ca0108_chip) { in _snd_emu10k1_audigy_init_efx()
1647 if (emu->card_capabilities->spk71) in _snd_emu10k1_audigy_init_efx()
1659 A_OP(icode, &ptr, iSKIP, A_GPR_COND, A_GPR_COND, A_GPR(gpr - 2), A_C_00000001); in _snd_emu10k1_audigy_init_efx()
1661 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()
1665 if ((z==1) && (emu->card_capabilities->spdif_bug)) { in _snd_emu10k1_audigy_init_efx()
1667 dev_info(emu->card->dev, in _snd_emu10k1_audigy_init_efx()
1669 emu->card_capabilities->name); in _snd_emu10k1_audigy_init_efx()
1670 …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()
1671 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()
1684 /* ADC buffer */ in _snd_emu10k1_audigy_init_efx()
1692 if (emu->card_capabilities->emu_model) { in _snd_emu10k1_audigy_init_efx()
1694 if (emu->card_capabilities->ca0108_chip) { in _snd_emu10k1_audigy_init_efx()
1695 dev_info(emu->card->dev, "EMU2 inputs on\n"); in _snd_emu10k1_audigy_init_efx()
1696 /* Note that the Tina[2] DSPs have 16 more EMU32 inputs which we don't use. */ in _snd_emu10k1_audigy_init_efx()
1701 // need to be delayed as well; we use an auxiliary register for that. in _snd_emu10k1_audigy_init_efx()
1711 dev_info(emu->card->dev, "EMU inputs on\n"); in _snd_emu10k1_audigy_init_efx()
1712 /* Note that the Alice2 DSPs have 6 I2S inputs which we don't use. */ in _snd_emu10k1_audigy_init_efx()
1715 dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n", in _snd_emu10k1_audigy_init_efx()
1720 * will need to also be delayed; we use an auxiliary register for that. */ in _snd_emu10k1_audigy_init_efx()
1737 /* EFX capture - capture the 16 EXTINs */ in _snd_emu10k1_audigy_init_efx()
1751 err = -EIO; in _snd_emu10k1_audigy_init_efx()
1759 icode->gpr_add_control_count = nctl; in _snd_emu10k1_audigy_init_efx()
1760 icode->gpr_add_controls = controls; in _snd_emu10k1_audigy_init_efx()
1761 emu->support_tlv = 1; /* support TLV */ in _snd_emu10k1_audigy_init_efx()
1763 emu->support_tlv = 0; /* clear again */ in _snd_emu10k1_audigy_init_efx()
1768 kfree(icode->gpr_map); in _snd_emu10k1_audigy_init_efx()
1779 /* Volumes are in the [-2^31, 0] range, zero being mute. */
1820 err = -ENOMEM; in _snd_emu10k1_init_efx()
1825 icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, in _snd_emu10k1_init_efx()
1827 if (!icode->gpr_map) in _snd_emu10k1_init_efx()
1840 gpr_map = icode->gpr_map; in _snd_emu10k1_init_efx()
1842 icode->tram_data_map = icode->gpr_map + 256; in _snd_emu10k1_init_efx()
1843 icode->tram_addr_map = icode->tram_data_map + 160; in _snd_emu10k1_init_efx()
1844 icode->code = icode->tram_addr_map + 160; in _snd_emu10k1_init_efx()
1847 memset(icode->gpr_valid, 0xff, 256 / 8); in _snd_emu10k1_init_efx()
1850 memset(icode->tram_valid, 0xff, 160 / 8); in _snd_emu10k1_init_efx()
1852 strcpy(icode->name, "SB Live! FX8010 code for ALSA v1.2 by Jaroslav Kysela"); in _snd_emu10k1_init_efx()
1879 ipcm->substream = 0; in _snd_emu10k1_init_efx()
1880 ipcm->channels = 2; in _snd_emu10k1_init_efx()
1881 ipcm->tram_start = 0; in _snd_emu10k1_init_efx()
1882 ipcm->buffer_size = (64 * 1024) / 2; in _snd_emu10k1_init_efx()
1883 ipcm->gpr_size = gpr++; in _snd_emu10k1_init_efx()
1884 ipcm->gpr_ptr = gpr++; in _snd_emu10k1_init_efx()
1885 ipcm->gpr_count = gpr++; in _snd_emu10k1_init_efx()
1886 ipcm->gpr_tmpcount = gpr++; in _snd_emu10k1_init_efx()
1887 ipcm->gpr_trigger = gpr++; in _snd_emu10k1_init_efx()
1888 ipcm->gpr_running = gpr++; in _snd_emu10k1_init_efx()
1889 ipcm->etram[0] = 0; in _snd_emu10k1_init_efx()
1890 ipcm->etram[1] = 1; in _snd_emu10k1_init_efx()
1898 gpr_map[gpr + 6] = (0x22 - 0x01) - 1; /* skip at 01 to 22 */ in _snd_emu10k1_init_efx()
1899 gpr_map[gpr + 7] = (0x22 - 0x06) - 1; /* skip at 06 to 22 */ in _snd_emu10k1_init_efx()
1903 gpr_map[gpr + 11] = (0x24 - 0x0a) - 1; /* skip at 0a to 24 */ in _snd_emu10k1_init_efx()
1907 /* 00: */ OP(icode, &ptr, iMAC0, C_00000000, GPR(ipcm->gpr_trigger), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
1910 /* 02: */ OP(icode, &ptr, iMAC0, C_00000000, GPR(ipcm->gpr_running), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
1918 …/* 08: */ OP(icode, &ptr, iANDXOR, GPR(ipcm->gpr_running), GPR(ipcm->gpr_running), C_00000000, C_0… in _snd_emu10k1_init_efx()
1923 …/* 0c: */ OP(icode, &ptr, iANDXOR, GPR(tmp + 0), ETRAM_DATA(ipcm->etram[0]), GPR(gpr + 0), C_00000… in _snd_emu10k1_init_efx()
1929 …/* 11: */ OP(icode, &ptr, iANDXOR, GPR(tmp + 0), ETRAM_DATA(ipcm->etram[1]), GPR(gpr + 0), C_00000… in _snd_emu10k1_init_efx()
1935 /* 16: */ OP(icode, &ptr, iACC3, GPR(tmp + 0), GPR(ipcm->gpr_ptr), C_00000001, C_00000000); in _snd_emu10k1_init_efx()
1936 /* 17: */ OP(icode, &ptr, iMACINT0, C_00000000, GPR(tmp + 0), C_ffffffff, GPR(ipcm->gpr_size)); in _snd_emu10k1_init_efx()
1939 /* 1a: */ OP(icode, &ptr, iACC3, GPR(ipcm->gpr_ptr), GPR(tmp + 0), C_00000000, C_00000000); in _snd_emu10k1_init_efx()
1941 …/* 1b: */ OP(icode, &ptr, iACC3, GPR(ipcm->gpr_tmpcount), GPR(ipcm->gpr_tmpcount), C_ffffffff, C_0… in _snd_emu10k1_init_efx()
1943 …/* 1d: */ OP(icode, &ptr, iACC3, GPR(ipcm->gpr_tmpcount), GPR(ipcm->gpr_count), C_00000000, C_0000… in _snd_emu10k1_init_efx()
1945 …/* 1f: */ OP(icode, &ptr, iANDXOR, GPR(ipcm->gpr_running), GPR(ipcm->gpr_running), C_00000001, C_0… in _snd_emu10k1_init_efx()
1947 …/* 20: */ OP(icode, &ptr, iANDXOR, GPR(ipcm->gpr_running), GPR(ipcm->gpr_running), C_00010000, C_0… in _snd_emu10k1_init_efx()
1950 …/* 22: */ OP(icode, &ptr, iMACINT1, ETRAM_ADDR(ipcm->etram[0]), GPR(gpr + 8), GPR_DBAC, C_ffffffff… in _snd_emu10k1_init_efx()
1951 …/* 23: */ OP(icode, &ptr, iMACINT1, ETRAM_ADDR(ipcm->etram[1]), GPR(gpr + 9), GPR_DBAC, C_ffffffff… in _snd_emu10k1_init_efx()
2042 if (emu->fx8010.extin_mask & ((1<<EXTIN_AC97_L)|(1<<EXTIN_AC97_R))) { in _snd_emu10k1_init_efx()
2046 snd_emu10k1_init_stereo_control(controls + i++, "AC97 Playback Volume", gpr-2, 0); in _snd_emu10k1_init_efx()
2050 snd_emu10k1_init_stereo_control(controls + i++, "AC97 Capture Volume", gpr-2, 100); in _snd_emu10k1_init_efx()
2053 if (emu->fx8010.extin_mask & ((1<<EXTIN_SPDIF_CD_L)|(1<<EXTIN_SPDIF_CD_R))) { in _snd_emu10k1_init_efx()
2070 if (emu->fx8010.extin_mask & ((1<<EXTIN_ZOOM_L)|(1<<EXTIN_ZOOM_R))) { in _snd_emu10k1_init_efx()
2087 if (emu->fx8010.extin_mask & ((1<<EXTIN_TOSLINK_L)|(1<<EXTIN_TOSLINK_R))) { in _snd_emu10k1_init_efx()
2104 if (emu->fx8010.extin_mask & ((1<<EXTIN_LINE1_L)|(1<<EXTIN_LINE1_R))) { in _snd_emu10k1_init_efx()
2121 if (emu->fx8010.extin_mask & ((1<<EXTIN_COAX_SPDIF_L)|(1<<EXTIN_COAX_SPDIF_R))) { in _snd_emu10k1_init_efx()
2138 if (emu->fx8010.extin_mask & ((1<<EXTIN_LINE2_L)|(1<<EXTIN_LINE2_R))) { in _snd_emu10k1_init_efx()
2143 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2152 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2154 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2162 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_init_efx()
2163 strcpy(ctl->id.name, "Tone Control - Bass"); in _snd_emu10k1_init_efx()
2164 ctl->vcount = 2; in _snd_emu10k1_init_efx()
2165 ctl->count = 10; in _snd_emu10k1_init_efx()
2166 ctl->min = 0; in _snd_emu10k1_init_efx()
2167 ctl->max = 40; in _snd_emu10k1_init_efx()
2168 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_init_efx()
2169 ctl->tlv = snd_emu10k1_bass_treble_db_scale; in _snd_emu10k1_init_efx()
2170 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; in _snd_emu10k1_init_efx()
2172 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; in _snd_emu10k1_init_efx()
2173 strcpy(ctl->id.name, "Tone Control - Treble"); in _snd_emu10k1_init_efx()
2174 ctl->vcount = 2; in _snd_emu10k1_init_efx()
2175 ctl->count = 10; in _snd_emu10k1_init_efx()
2176 ctl->min = 0; in _snd_emu10k1_init_efx()
2177 ctl->max = 40; in _snd_emu10k1_init_efx()
2178 ctl->value[0] = ctl->value[1] = 20; in _snd_emu10k1_init_efx()
2179 ctl->tlv = snd_emu10k1_bass_treble_db_scale; in _snd_emu10k1_init_efx()
2180 ctl->translation = EMU10K1_GPR_TRANSLATION_TREBLE; in _snd_emu10k1_init_efx()
2195 snd_emu10k1_init_mono_onoff_control(controls + i++, "Tone Control - Switch", gpr, 0); in _snd_emu10k1_init_efx()
2199 for (z = 0; z < 3; z++) { /* front/rear/center-lfe */ in _snd_emu10k1_init_efx()
2226 gpr_map[gpr++] = ptr - ptr_skip; in _snd_emu10k1_init_efx()
2234 if (emu->fx8010.extout_mask & ((1<<EXTOUT_AC97_L)|(1<<EXTOUT_AC97_R))) { in _snd_emu10k1_init_efx()
2241 if (emu->fx8010.extout_mask & ((1<<EXTOUT_TOSLINK_L)|(1<<EXTOUT_TOSLINK_R))) { in _snd_emu10k1_init_efx()
2258 if (emu->fx8010.extout_mask & ((1<<EXTOUT_HEADPHONE_L)|(1<<EXTOUT_HEADPHONE_R))) { in _snd_emu10k1_init_efx()
2270 controls[i-1].id.index = 1; /* AC'97 can have also Headphone control */ in _snd_emu10k1_init_efx()
2272 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2274 controls[i-1].id.index = 1; in _snd_emu10k1_init_efx()
2279 if (emu->fx8010.extout_mask & ((1<<EXTOUT_REAR_L)|(1<<EXTOUT_REAR_R))) in _snd_emu10k1_init_efx()
2283 if (emu->fx8010.extout_mask & ((1<<EXTOUT_AC97_REAR_L)|(1<<EXTOUT_AC97_REAR_R))) in _snd_emu10k1_init_efx()
2287 if (emu->fx8010.extout_mask & (1<<EXTOUT_AC97_CENTER)) { in _snd_emu10k1_init_efx()
2297 if (emu->fx8010.extout_mask & (1<<EXTOUT_AC97_LFE)) { in _snd_emu10k1_init_efx()
2312 if (emu->fx8010.extout_mask & (1<<EXTOUT_MIC_CAP)) in _snd_emu10k1_init_efx()
2315 /* EFX capture - capture the 16 EXTINS */ in _snd_emu10k1_init_efx()
2316 if (emu->card_capabilities->sblive51) { in _snd_emu10k1_init_efx()
2319 if (c != -1) in _snd_emu10k1_init_efx()
2330 err = -EIO; in _snd_emu10k1_init_efx()
2335 err = -EIO; in _snd_emu10k1_init_efx()
2343 err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size); in _snd_emu10k1_init_efx()
2346 icode->gpr_add_control_count = i; in _snd_emu10k1_init_efx()
2347 icode->gpr_add_controls = controls; in _snd_emu10k1_init_efx()
2348 emu->support_tlv = 1; /* support TLV */ in _snd_emu10k1_init_efx()
2350 emu->support_tlv = 0; /* clear again */ in _snd_emu10k1_init_efx()
2358 kfree(icode->gpr_map); in _snd_emu10k1_init_efx()
2366 spin_lock_init(&emu->fx8010.irq_lock); in snd_emu10k1_init_efx()
2367 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); in snd_emu10k1_init_efx()
2368 if (emu->audigy) in snd_emu10k1_init_efx()
2377 if (emu->audigy) in snd_emu10k1_free_efx()
2378 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg = A_DBG_SINGLE_STEP); in snd_emu10k1_free_efx()
2380 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg = EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_free_efx()
2383 #if 0 /* FIXME: who use them? */
2387 return -EINVAL;
2388 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1);
2395 return -EINVAL;
2396 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0);
2407 size = (size - 1) >> 13; in snd_emu10k1_fx8010_tram_setup()
2415 if ((emu->fx8010.etram_pages.bytes / 2) == size) in snd_emu10k1_fx8010_tram_setup()
2417 spin_lock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2418 outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); in snd_emu10k1_fx8010_tram_setup()
2419 spin_unlock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2422 if (emu->fx8010.etram_pages.area != NULL) { in snd_emu10k1_fx8010_tram_setup()
2423 snd_dma_free_pages(&emu->fx8010.etram_pages); in snd_emu10k1_fx8010_tram_setup()
2424 emu->fx8010.etram_pages.area = NULL; in snd_emu10k1_fx8010_tram_setup()
2425 emu->fx8010.etram_pages.bytes = 0; in snd_emu10k1_fx8010_tram_setup()
2429 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &emu->pci->dev, in snd_emu10k1_fx8010_tram_setup()
2430 size * 2, &emu->fx8010.etram_pages) < 0) in snd_emu10k1_fx8010_tram_setup()
2431 return -ENOMEM; in snd_emu10k1_fx8010_tram_setup()
2432 memset(emu->fx8010.etram_pages.area, 0, size * 2); in snd_emu10k1_fx8010_tram_setup()
2433 snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); in snd_emu10k1_fx8010_tram_setup()
2435 spin_lock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2436 outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); in snd_emu10k1_fx8010_tram_setup()
2437 spin_unlock_irq(&emu->emu_lock); in snd_emu10k1_fx8010_tram_setup()
2461 int res; in snd_emu10k1_fx8010_info() local
2463 info->internal_tram_size = emu->fx8010.itram_size; in snd_emu10k1_fx8010_info()
2464 info->external_tram_size = emu->fx8010.etram_pages.bytes / 2; in snd_emu10k1_fx8010_info()
2466 extin = emu->audigy ? snd_emu10k1_audigy_ins : snd_emu10k1_sblive_ins; in snd_emu10k1_fx8010_info()
2467 extout = emu->audigy ? snd_emu10k1_audigy_outs : snd_emu10k1_sblive_outs; in snd_emu10k1_fx8010_info()
2468 extin_mask = emu->audigy ? ~0 : emu->fx8010.extin_mask; in snd_emu10k1_fx8010_info()
2469 extout_mask = emu->audigy ? ~0 : emu->fx8010.extout_mask; in snd_emu10k1_fx8010_info()
2470 for (res = 0; res < 16; res++, fxbus++, extin++, extout++) { in snd_emu10k1_fx8010_info()
2471 copy_string(info->fxbus_names[res], *fxbus, "FXBUS", res); in snd_emu10k1_fx8010_info()
2472 copy_string(info->extin_names[res], extin_mask & (1 << res) ? *extin : NULL, "Unused", res); in snd_emu10k1_fx8010_info()
2473 copy_string(info->extout_names[res], extout_mask & (1 << res) ? *extout : NULL, "Unused", res); in snd_emu10k1_fx8010_info()
2475 for (res = 16; res < 32; res++, extout++) in snd_emu10k1_fx8010_info()
2476 copy_string(info->extout_names[res], extout_mask & (1 << res) ? *extout : NULL, "Unused", res); in snd_emu10k1_fx8010_info()
2477 info->gpr_controls = emu->fx8010.gpr_count; in snd_emu10k1_fx8010_info()
2482 struct snd_emu10k1 *emu = hw->private_data; in snd_emu10k1_fx8010_ioctl()
2488 int res; in snd_emu10k1_fx8010_ioctl() local
2492 emu->support_tlv = 1; in snd_emu10k1_fx8010_ioctl()
2497 return -ENOMEM; in snd_emu10k1_fx8010_ioctl()
2501 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2507 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2512 res = snd_emu10k1_icode_poke(emu, icode, false); in snd_emu10k1_fx8010_ioctl()
2514 return res; in snd_emu10k1_fx8010_ioctl()
2519 res = snd_emu10k1_icode_peek(emu, icode); in snd_emu10k1_fx8010_ioctl()
2520 if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { in snd_emu10k1_fx8010_ioctl()
2522 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2525 return res; in snd_emu10k1_fx8010_ioctl()
2530 res = snd_emu10k1_ipcm_poke(emu, ipcm); in snd_emu10k1_fx8010_ioctl()
2532 return res; in snd_emu10k1_fx8010_ioctl()
2537 res = snd_emu10k1_ipcm_peek(emu, ipcm); in snd_emu10k1_fx8010_ioctl()
2538 if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { in snd_emu10k1_fx8010_ioctl()
2540 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2543 return res; in snd_emu10k1_fx8010_ioctl()
2546 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2548 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2549 mutex_lock(&emu->fx8010.lock); in snd_emu10k1_fx8010_ioctl()
2550 res = snd_emu10k1_fx8010_tram_setup(emu, addr); in snd_emu10k1_fx8010_ioctl()
2551 mutex_unlock(&emu->fx8010.lock); in snd_emu10k1_fx8010_ioctl()
2552 return res; in snd_emu10k1_fx8010_ioctl()
2555 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2556 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2557 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg |= A_DBG_SINGLE_STEP); in snd_emu10k1_fx8010_ioctl()
2559 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg |= EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_fx8010_ioctl()
2563 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2564 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2565 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg = 0); in snd_emu10k1_fx8010_ioctl()
2567 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg = 0); in snd_emu10k1_fx8010_ioctl()
2571 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2572 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2573 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_ZC); in snd_emu10k1_fx8010_ioctl()
2575 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_ZC); in snd_emu10k1_fx8010_ioctl()
2577 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2578 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); in snd_emu10k1_fx8010_ioctl()
2580 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); in snd_emu10k1_fx8010_ioctl()
2584 return -EPERM; in snd_emu10k1_fx8010_ioctl()
2586 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2587 if (emu->audigy) { in snd_emu10k1_fx8010_ioctl()
2589 return -EINVAL; in snd_emu10k1_fx8010_ioctl()
2590 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg |= A_DBG_SINGLE_STEP); in snd_emu10k1_fx8010_ioctl()
2592 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_STEP | addr); in snd_emu10k1_fx8010_ioctl()
2595 return -EINVAL; in snd_emu10k1_fx8010_ioctl()
2596 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg |= EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_fx8010_ioctl()
2598 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_STEP | addr); in snd_emu10k1_fx8010_ioctl()
2602 if (emu->audigy) in snd_emu10k1_fx8010_ioctl()
2607 return -EFAULT; in snd_emu10k1_fx8010_ioctl()
2610 return -ENOTTY; in snd_emu10k1_fx8010_ioctl()
2623 err = snd_hwdep_new(emu->card, "FX8010", device, &hw); in snd_emu10k1_fx8010_new()
2626 strcpy(hw->name, "EMU10K1 (FX8010)"); in snd_emu10k1_fx8010_new()
2627 hw->iface = SNDRV_HWDEP_IFACE_EMU10K1; in snd_emu10k1_fx8010_new()
2628 hw->ops.open = snd_emu10k1_fx8010_open; in snd_emu10k1_fx8010_new()
2629 hw->ops.ioctl = snd_emu10k1_fx8010_ioctl; in snd_emu10k1_fx8010_new()
2630 hw->ops.release = snd_emu10k1_fx8010_release; in snd_emu10k1_fx8010_new()
2631 hw->private_data = emu; in snd_emu10k1_fx8010_new()
2640 len = emu->audigy ? 0x200 : 0x100; in snd_emu10k1_efx_alloc_pm_buffer()
2641 emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL); in snd_emu10k1_efx_alloc_pm_buffer()
2642 if (! emu->saved_gpr) in snd_emu10k1_efx_alloc_pm_buffer()
2643 return -ENOMEM; in snd_emu10k1_efx_alloc_pm_buffer()
2644 len = emu->audigy ? 0x100 : 0xa0; in snd_emu10k1_efx_alloc_pm_buffer()
2645 emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL); in snd_emu10k1_efx_alloc_pm_buffer()
2646 emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL); in snd_emu10k1_efx_alloc_pm_buffer()
2647 if (! emu->tram_val_saved || ! emu->tram_addr_saved) in snd_emu10k1_efx_alloc_pm_buffer()
2648 return -ENOMEM; in snd_emu10k1_efx_alloc_pm_buffer()
2649 len = emu->audigy ? 2 * 1024 : 2 * 512; in snd_emu10k1_efx_alloc_pm_buffer()
2650 emu->saved_icode = vmalloc(array_size(len, 4)); in snd_emu10k1_efx_alloc_pm_buffer()
2651 if (! emu->saved_icode) in snd_emu10k1_efx_alloc_pm_buffer()
2652 return -ENOMEM; in snd_emu10k1_efx_alloc_pm_buffer()
2658 kfree(emu->saved_gpr); in snd_emu10k1_efx_free_pm_buffer()
2659 kfree(emu->tram_val_saved); in snd_emu10k1_efx_free_pm_buffer()
2660 kfree(emu->tram_addr_saved); in snd_emu10k1_efx_free_pm_buffer()
2661 vfree(emu->saved_icode); in snd_emu10k1_efx_free_pm_buffer()
2671 len = emu->audigy ? 0x200 : 0x100; in snd_emu10k1_efx_suspend()
2673 emu->saved_gpr[i] = snd_emu10k1_ptr_read(emu, emu->gpr_base + i, 0); in snd_emu10k1_efx_suspend()
2675 len = emu->audigy ? 0x100 : 0xa0; in snd_emu10k1_efx_suspend()
2677 emu->tram_val_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + i, 0); in snd_emu10k1_efx_suspend()
2678 emu->tram_addr_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + i, 0); in snd_emu10k1_efx_suspend()
2679 if (emu->audigy) { in snd_emu10k1_efx_suspend()
2680 emu->tram_addr_saved[i] >>= 12; in snd_emu10k1_efx_suspend()
2681 emu->tram_addr_saved[i] |= in snd_emu10k1_efx_suspend()
2686 len = emu->audigy ? 2 * 1024 : 2 * 512; in snd_emu10k1_efx_suspend()
2688 emu->saved_icode[i] = snd_emu10k1_efx_read(emu, i); in snd_emu10k1_efx_suspend()
2696 if (emu->fx8010.etram_pages.bytes > 0) { in snd_emu10k1_efx_resume()
2698 size = emu->fx8010.etram_pages.bytes / 2; in snd_emu10k1_efx_resume()
2699 size = (size - 1) >> 13; in snd_emu10k1_efx_resume()
2704 outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); in snd_emu10k1_efx_resume()
2705 snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); in snd_emu10k1_efx_resume()
2707 outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); in snd_emu10k1_efx_resume()
2710 if (emu->audigy) in snd_emu10k1_efx_resume()
2711 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); in snd_emu10k1_efx_resume()
2713 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); in snd_emu10k1_efx_resume()
2715 len = emu->audigy ? 0x200 : 0x100; in snd_emu10k1_efx_resume()
2717 snd_emu10k1_ptr_write(emu, emu->gpr_base + i, 0, emu->saved_gpr[i]); in snd_emu10k1_efx_resume()
2719 len = emu->audigy ? 0x100 : 0xa0; in snd_emu10k1_efx_resume()
2722 emu->tram_val_saved[i]); in snd_emu10k1_efx_resume()
2723 if (! emu->audigy) in snd_emu10k1_efx_resume()
2725 emu->tram_addr_saved[i]); in snd_emu10k1_efx_resume()
2728 emu->tram_addr_saved[i] << 12); in snd_emu10k1_efx_resume()
2730 emu->tram_addr_saved[i] >> 20); in snd_emu10k1_efx_resume()
2734 len = emu->audigy ? 2 * 1024 : 2 * 512; in snd_emu10k1_efx_resume()
2736 snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]); in snd_emu10k1_efx_resume()
2739 if (emu->audigy) in snd_emu10k1_efx_resume()
2740 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); in snd_emu10k1_efx_resume()
2742 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); in snd_emu10k1_efx_resume()