diff options
Diffstat (limited to 'sound/pci/emu10k1/emufx.c')
-rw-r--r-- | sound/pci/emu10k1/emufx.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 646b5d972e6f..03e8c1678952 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
@@ -364,12 +364,18 @@ static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value | |||
364 | snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]); | 364 | snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]); |
365 | break; | 365 | break; |
366 | case EMU10K1_GPR_TRANSLATION_BASS: | 366 | case EMU10K1_GPR_TRANSLATION_BASS: |
367 | snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); | 367 | if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { |
368 | change = -EIO; | ||
369 | goto __error; | ||
370 | } | ||
368 | for (j = 0; j < 5; j++) | 371 | for (j = 0; j < 5; j++) |
369 | snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]); | 372 | snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]); |
370 | break; | 373 | break; |
371 | case EMU10K1_GPR_TRANSLATION_TREBLE: | 374 | case EMU10K1_GPR_TRANSLATION_TREBLE: |
372 | snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); | 375 | if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { |
376 | change = -EIO; | ||
377 | goto __error; | ||
378 | } | ||
373 | for (j = 0; j < 5; j++) | 379 | for (j = 0; j < 5; j++) |
374 | snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]); | 380 | snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]); |
375 | break; | 381 | break; |
@@ -412,8 +418,6 @@ int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, | |||
412 | snd_emu10k1_fx8010_irq_t *irq; | 418 | snd_emu10k1_fx8010_irq_t *irq; |
413 | unsigned long flags; | 419 | unsigned long flags; |
414 | 420 | ||
415 | snd_runtime_check(emu, return -EINVAL); | ||
416 | snd_runtime_check(handler, return -EINVAL); | ||
417 | irq = kmalloc(sizeof(*irq), GFP_ATOMIC); | 421 | irq = kmalloc(sizeof(*irq), GFP_ATOMIC); |
418 | if (irq == NULL) | 422 | if (irq == NULL) |
419 | return -ENOMEM; | 423 | return -ENOMEM; |
@@ -442,7 +446,6 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, | |||
442 | snd_emu10k1_fx8010_irq_t *tmp; | 446 | snd_emu10k1_fx8010_irq_t *tmp; |
443 | unsigned long flags; | 447 | unsigned long flags; |
444 | 448 | ||
445 | snd_runtime_check(irq, return -EINVAL); | ||
446 | spin_lock_irqsave(&emu->fx8010.irq_lock, flags); | 449 | spin_lock_irqsave(&emu->fx8010.irq_lock, flags); |
447 | if ((tmp = emu->fx8010.irq_handlers) == irq) { | 450 | if ((tmp = emu->fx8010.irq_handlers) == irq) { |
448 | emu->fx8010.irq_handlers = tmp->next; | 451 | emu->fx8010.irq_handlers = tmp->next; |
@@ -717,9 +720,15 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode | |||
717 | err = -EFAULT; | 720 | err = -EFAULT; |
718 | goto __error; | 721 | goto __error; |
719 | } | 722 | } |
720 | snd_runtime_check(gctl->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER || | 723 | if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && |
721 | gctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM, err = -EINVAL; goto __error); | 724 | gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { |
722 | snd_runtime_check(gctl->id.name[0] != '\0', err = -EINVAL; goto __error); | 725 | err = -EINVAL; |
726 | goto __error; | ||
727 | } | ||
728 | if (! gctl->id.name[0]) { | ||
729 | err = -EINVAL; | ||
730 | goto __error; | ||
731 | } | ||
723 | ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); | 732 | ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); |
724 | memset(&knew, 0, sizeof(knew)); | 733 | memset(&knew, 0, sizeof(knew)); |
725 | knew.iface = gctl->id.iface; | 734 | knew.iface = gctl->id.iface; |
@@ -783,7 +792,8 @@ static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode | |||
783 | 792 | ||
784 | for (i = 0, _id = icode->gpr_del_controls; | 793 | for (i = 0, _id = icode->gpr_del_controls; |
785 | i < icode->gpr_del_control_count; i++, _id++) { | 794 | i < icode->gpr_del_control_count; i++, _id++) { |
786 | snd_runtime_check(copy_from_user(&id, _id, sizeof(id)) == 0, return -EFAULT); | 795 | if (copy_from_user(&id, _id, sizeof(id))) |
796 | return -EFAULT; | ||
787 | down_write(&card->controls_rwsem); | 797 | down_write(&card->controls_rwsem); |
788 | ctl = snd_emu10k1_look_for_ctl(emu, &id); | 798 | ctl = snd_emu10k1_look_for_ctl(emu, &id); |
789 | if (ctl) | 799 | if (ctl) |
@@ -964,8 +974,8 @@ static int snd_emu10k1_ipcm_peek(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) | |||
964 | return err; | 974 | return err; |
965 | } | 975 | } |
966 | 976 | ||
967 | #define SND_EMU10K1_GPR_CONTROLS 41 | 977 | #define SND_EMU10K1_GPR_CONTROLS 44 |
968 | #define SND_EMU10K1_INPUTS 10 | 978 | #define SND_EMU10K1_INPUTS 12 |
969 | #define SND_EMU10K1_PLAYBACK_CHANNELS 8 | 979 | #define SND_EMU10K1_PLAYBACK_CHANNELS 8 |
970 | #define SND_EMU10K1_CAPTURE_CHANNELS 4 | 980 | #define SND_EMU10K1_CAPTURE_CHANNELS 4 |
971 | 981 | ||
@@ -1382,7 +1392,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1382 | A_SWITCH(icode, &ptr, tmp + 1, playback + SND_EMU10K1_PLAYBACK_CHANNELS + z, tmp + 1); | 1392 | A_SWITCH(icode, &ptr, tmp + 1, playback + SND_EMU10K1_PLAYBACK_CHANNELS + z, tmp + 1); |
1383 | if ((z==1) && (emu->card_capabilities->spdif_bug)) { | 1393 | if ((z==1) && (emu->card_capabilities->spdif_bug)) { |
1384 | /* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ | 1394 | /* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ |
1385 | snd_printk("Installing spdif_bug patch: %s\n", emu->card_capabilities->name); | 1395 | snd_printk(KERN_INFO "Installing spdif_bug patch: %s\n", emu->card_capabilities->name); |
1386 | A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_00000000); | 1396 | A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_00000000); |
1387 | A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000); | 1397 | A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000); |
1388 | } else { | 1398 | } else { |
@@ -1527,7 +1537,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) | |||
1527 | 1537 | ||
1528 | strcpy(icode->name, "SB Live! FX8010 code for ALSA v1.2 by Jaroslav Kysela"); | 1538 | strcpy(icode->name, "SB Live! FX8010 code for ALSA v1.2 by Jaroslav Kysela"); |
1529 | ptr = 0; i = 0; | 1539 | ptr = 0; i = 0; |
1530 | /* we have 10 inputs */ | 1540 | /* we have 12 inputs */ |
1531 | playback = SND_EMU10K1_INPUTS; | 1541 | playback = SND_EMU10K1_INPUTS; |
1532 | /* we have 6 playback channels and tone control doubles */ | 1542 | /* we have 6 playback channels and tone control doubles */ |
1533 | capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); | 1543 | capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); |
@@ -1551,6 +1561,8 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) | |||
1551 | OP(icode, &ptr, iMACINT0, GPR(7), C_00000000, FXBUS(FXBUS_PCM_LFE), C_00000004); | 1561 | OP(icode, &ptr, iMACINT0, GPR(7), C_00000000, FXBUS(FXBUS_PCM_LFE), C_00000004); |
1552 | OP(icode, &ptr, iMACINT0, GPR(8), C_00000000, C_00000000, C_00000000); /* S/PDIF left */ | 1562 | OP(icode, &ptr, iMACINT0, GPR(8), C_00000000, C_00000000, C_00000000); /* S/PDIF left */ |
1553 | OP(icode, &ptr, iMACINT0, GPR(9), C_00000000, C_00000000, C_00000000); /* S/PDIF right */ | 1563 | OP(icode, &ptr, iMACINT0, GPR(9), C_00000000, C_00000000, C_00000000); /* S/PDIF right */ |
1564 | OP(icode, &ptr, iMACINT0, GPR(10), C_00000000, FXBUS(FXBUS_PCM_LEFT_FRONT), C_00000004); | ||
1565 | OP(icode, &ptr, iMACINT0, GPR(11), C_00000000, FXBUS(FXBUS_PCM_RIGHT_FRONT), C_00000004); | ||
1554 | 1566 | ||
1555 | /* Raw S/PDIF PCM */ | 1567 | /* Raw S/PDIF PCM */ |
1556 | ipcm->substream = 0; | 1568 | ipcm->substream = 0; |
@@ -1697,6 +1709,21 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) | |||
1697 | VOLUME_ADD(icode, &ptr, playback + 5, 7, gpr); | 1709 | VOLUME_ADD(icode, &ptr, playback + 5, 7, gpr); |
1698 | snd_emu10k1_init_mono_control(controls + i++, "LFE Digital Playback Volume", gpr++, 100); | 1710 | snd_emu10k1_init_mono_control(controls + i++, "LFE Digital Playback Volume", gpr++, 100); |
1699 | 1711 | ||
1712 | /* Front Playback Volume */ | ||
1713 | for (z = 0; z < 2; z++) | ||
1714 | VOLUME_ADD(icode, &ptr, playback + z, 10 + z, gpr + z); | ||
1715 | snd_emu10k1_init_stereo_control(controls + i++, "Front Playback Volume", gpr, 100); | ||
1716 | gpr += 2; | ||
1717 | |||
1718 | /* Front Capture Volume + Switch */ | ||
1719 | for (z = 0; z < 2; z++) { | ||
1720 | SWITCH(icode, &ptr, tmp + 0, 10 + z, gpr + 2); | ||
1721 | VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); | ||
1722 | } | ||
1723 | snd_emu10k1_init_stereo_control(controls + i++, "Front Capture Volume", gpr, 0); | ||
1724 | snd_emu10k1_init_mono_onoff_control(controls + i++, "Front Capture Switch", gpr + 2, 0); | ||
1725 | gpr += 3; | ||
1726 | |||
1700 | /* | 1727 | /* |
1701 | * Process inputs | 1728 | * Process inputs |
1702 | */ | 1729 | */ |
@@ -2058,14 +2085,16 @@ void snd_emu10k1_free_efx(emu10k1_t *emu) | |||
2058 | #if 0 // FIXME: who use them? | 2085 | #if 0 // FIXME: who use them? |
2059 | int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) | 2086 | int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) |
2060 | { | 2087 | { |
2061 | snd_runtime_check(output >= 0 && output < 6, return -EINVAL); | 2088 | if (output < 0 || output >= 6) |
2089 | return -EINVAL; | ||
2062 | snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1); | 2090 | snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1); |
2063 | return 0; | 2091 | return 0; |
2064 | } | 2092 | } |
2065 | 2093 | ||
2066 | int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) | 2094 | int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) |
2067 | { | 2095 | { |
2068 | snd_runtime_check(output >= 0 && output < 6, return -EINVAL); | 2096 | if (output < 0 || output >= 6) |
2097 | return -EINVAL; | ||
2069 | snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0); | 2098 | snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0); |
2070 | return 0; | 2099 | return 0; |
2071 | } | 2100 | } |